Support setting priorityClassName on pods (#282)

This commit is contained in:
Yong Wen Chua 2020-05-01 09:37:27 +08:00 committed by GitHub
parent ee2827f710
commit c8b18d1876
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 2 deletions

View file

@ -27,6 +27,9 @@ spec:
{{ template "injector.affinity" . }} {{ template "injector.affinity" . }}
{{ template "injector.tolerations" . }} {{ template "injector.tolerations" . }}
{{ template "injector.nodeselector" . }} {{ template "injector.nodeselector" . }}
{{- if .Values.injector.priorityClassName }}
priorityClassName: {{ .Values.injector.priorityClassName }}
{{- end }}
serviceAccountName: "{{ template "vault.fullname" . }}-agent-injector" serviceAccountName: "{{ template "vault.fullname" . }}-agent-injector"
securityContext: securityContext:
runAsNonRoot: true runAsNonRoot: true

View file

@ -37,6 +37,9 @@ spec:
{{ template "vault.affinity" . }} {{ template "vault.affinity" . }}
{{ template "vault.tolerations" . }} {{ template "vault.tolerations" . }}
{{ template "vault.nodeselector" . }} {{ template "vault.nodeselector" . }}
{{- if .Values.server.priorityClassName }}
priorityClassName: {{ .Values.server.priorityClassName }}
{{- end }}
terminationGracePeriodSeconds: 10 terminationGracePeriodSeconds: 10
serviceAccountName: {{ template "vault.fullname" . }} serviceAccountName: {{ template "vault.fullname" . }}
{{ if .Values.server.shareProcessNamespace }} {{ if .Values.server.shareProcessNamespace }}

View file

@ -425,3 +425,25 @@ load _helpers
yq -r '.spec.template.spec.nodeSelector' | tee /dev/stderr) yq -r '.spec.template.spec.nodeSelector' | tee /dev/stderr)
[ "${actual}" = "testing" ] [ "${actual}" = "testing" ]
} }
#--------------------------------------------------------------------
# priorityClassName
@test "injector/deployment: priorityClassName not set by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-deployment.yaml \
. | tee /dev/stderr |
yq '.spec.template.spec | .priorityClassName? == null' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "injector/deployment: priorityClassName can be set" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-deployment.yaml \
--set 'injector.priorityClassName=armaggeddon' \
. | tee /dev/stderr |
yq '.spec.template.spec | .priorityClassName == "armaggeddon"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

View file

@ -711,7 +711,7 @@ load _helpers
. | tee /dev/stderr | . | tee /dev/stderr |
yq -r '.spec.template.spec.shareProcessNamespace' | tee /dev/stderr) yq -r '.spec.template.spec.shareProcessNamespace' | tee /dev/stderr)
[ "${actual}" = "null" ] [ "${actual}" = "null" ]
} }
@test "server/standalone-StatefulSet: shareProcessNamespace enabled" { @test "server/standalone-StatefulSet: shareProcessNamespace enabled" {
@ -724,7 +724,7 @@ load _helpers
. | tee /dev/stderr | . | tee /dev/stderr |
yq -r '.spec.template.spec.shareProcessNamespace' | tee /dev/stderr) yq -r '.spec.template.spec.shareProcessNamespace' | tee /dev/stderr)
[ "${actual}" = "true" ] [ "${actual}" = "true" ]
} }
# extra labels # extra labels
@ -958,3 +958,25 @@ load _helpers
yq -r '.spec.template.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr) yq -r '.spec.template.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
[ "${actual}" = "true" ] [ "${actual}" = "true" ]
} }
#--------------------------------------------------------------------
# priorityClassName
@test "server/standalone-StatefulSet: priorityClassName not set by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq '.spec.template.spec | .priorityClassName? == null' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "server/standalone-StatefulSet: priorityClassName can be set" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.priorityClassName=armaggeddon' \
. | tee /dev/stderr |
yq '.spec.template.spec | .priorityClassName == "armaggeddon"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

View file

@ -103,6 +103,9 @@ injector:
# beta.kubernetes.io/arch: amd64 # beta.kubernetes.io/arch: amd64
nodeSelector: null nodeSelector: null
# Priority class for injector pods
priorityClassName: ""
server: server:
# Resource requests, limits, etc. for the server cluster placement. This # Resource requests, limits, etc. for the server cluster placement. This
# should map directly to the value of the resources field for a PodSpec. # should map directly to the value of the resources field for a PodSpec.
@ -227,6 +230,9 @@ server:
# beta.kubernetes.io/arch: amd64 # beta.kubernetes.io/arch: amd64
nodeSelector: {} nodeSelector: {}
# Priority class for server pods
priorityClassName: ""
# Extra labels to attach to the server pods # Extra labels to attach to the server pods
# This should be a multi-line string mapping directly to the a map of # This should be a multi-line string mapping directly to the a map of
# the labels to apply to the server pods # the labels to apply to the server pods