Skip to content

Commit

Permalink
Add node selector, toleration and affinity rules for jobs (#333)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Apr 8, 2024
1 parent 6675e10 commit 14ca5b0
Show file tree
Hide file tree
Showing 15 changed files with 9,928 additions and 2,029 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.21
- name: Set up Go 1.22
uses: actions/setup-go@v1
with:
go-version: '1.21'
go-version: '1.22'
id: go

- name: Check out code into the Go module directory
Expand All @@ -37,7 +37,7 @@ jobs:
sudo mv yqq /usr/local/bin/yqq
pip3 install yq
# install kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.21.1/bin/linux/amd64/kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.25.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
BASEIMAGE_PROD ?= gcr.io/distroless/static-debian12
BASEIMAGE_DBG ?= debian:bookworm

GO_VERSION ?= 1.21
GO_VERSION ?= 1.22
BUILD_IMAGE ?= ghcr.io/appscode/golang-dev:$(GO_VERSION)
CHART_TEST_IMAGE ?= quay.io/helmpack/chart-testing:v3.8.0

Expand Down
16 changes: 16 additions & 0 deletions apis/installer/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ type CleanerRef struct {
// Security options the pod should run with.
// +optional
SecurityContext *core.SecurityContext `json:"securityContext"`
//+optional
NodeSelector map[string]string `json:"nodeSelector"`
// If specified, the pod's tolerations.
// +optional
Tolerations []core.Toleration `json:"tolerations"`
// If specified, the pod's scheduling constraints
// +optional
Affinity *core.Affinity `json:"affinity"`
}

type ServiceAccountSpec struct {
Expand Down Expand Up @@ -178,4 +186,12 @@ type CRDInstallerRef struct {
// Security options the pod should run with.
// +optional
SecurityContext *core.SecurityContext `json:"securityContext"`
//+optional
NodeSelector map[string]string `json:"nodeSelector"`
// If specified, the pod's tolerations.
// +optional
Tolerations []core.Toleration `json:"tolerations"`
// If specified, the pod's scheduling constraints
// +optional
Affinity *core.Affinity `json:"affinity"`
}
38 changes: 38 additions & 0 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions charts/stash-community/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ The following table lists the configurable parameters of the `stash-community` c
| crdInstaller.tag | Tag of the CRD installer image. By default, it will use the same tag as the operator. | <code>""</code> |
| crdInstaller.enabled | Use crd-installer job to install the Stash CRDs. Default is `true`. | <code>true</code> |
| crdInstaller.securityContext | Security options the Prometheus pushgateway container should run with | <code>{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":65534}</code> |
| crdInstaller.nodeSelector | Node labels for pod assignment | <code>{"kubernetes.io/os":"linux"}</code> |
| crdInstaller.tolerations | Tolerations for pod assignment | <code>[]</code> |
| crdInstaller.affinity | Affinity rules for pod assignment | <code>{}</code> |
| pushgateway.registry | Docker registry used to pull Prometheus pushgateway image | <code>prom</code> |
| pushgateway.repository | Prometheus pushgateway container image | <code>pushgateway</code> |
| pushgateway.tag | Prometheus pushgateway container image tag | <code>v1.4.2</code> |
Expand All @@ -75,6 +78,9 @@ The following table lists the configurable parameters of the `stash-community` c
| cleaner.tag | Webhook cleaner container image tag | <code>v1.22</code> |
| cleaner.skip | Skip generating cleaner YAML | <code>false</code> |
| cleaner.securityContext | Security options the Prometheus pushgateway container should run with | <code>{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":65534}</code> |
| cleaner.nodeSelector | Node labels for pod assignment | <code>{"kubernetes.io/os":"linux"}</code> |
| cleaner.tolerations | Tolerations for pod assignment | <code>[]</code> |
| cleaner.affinity | Affinity rules for pod assignment | <code>{}</code> |
| imagePullSecrets | Specify an array of imagePullSecrets. Secrets must be manually created in the namespace. <br> Example: <br> `helm template charts/stash \` <br> `--set imagePullSecrets[0].name=sec0 \` <br> `--set imagePullSecrets[1].name=sec1` | <code>[]</code> |
| imagePullPolicy | Container image pull policy | <code>IfNotPresent</code> |
| criticalAddon | If true, installs Stash operator as critical addon | <code>false</code> |
Expand Down
14 changes: 14 additions & 0 deletions charts/stash-community/templates/cleaner/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,18 @@ spec:
securityContext:
{{- toYaml .Values.cleaner.securityContext | nindent 10 }}
restartPolicy: Never
{{- if .Values.cleaner.tolerations }}
tolerations:
{{- with .Values.cleaner.tolerations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
{{- with .Values.cleaner.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cleaner.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ end }}
14 changes: 14 additions & 0 deletions charts/stash-community/templates/crd-installer/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@ spec:
securityContext:
{{- toYaml .Values.crdInstaller.securityContext | nindent 12 }}
restartPolicy: Never
{{- if .Values.crdInstaller.tolerations }}
tolerations:
{{- with .Values.crdInstaller.tolerations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
{{- with .Values.crdInstaller.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.crdInstaller.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ end }}
Loading

0 comments on commit 14ca5b0

Please sign in to comment.