Skip to content

Commit

Permalink
Support setting priorityClassName on pods
Browse files Browse the repository at this point in the history
  • Loading branch information
lawliet89 committed Apr 30, 2020
1 parent ee2827f commit 5631be6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
3 changes: 3 additions & 0 deletions templates/injector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ spec:
{{ template "injector.affinity" . }}
{{ template "injector.tolerations" . }}
{{ template "injector.nodeselector" . }}
{{- if .Values.injector.priorityClassName }}
priorityClassName: {{ .Values.injector.priorityClassName }}
{{- end }}
serviceAccountName: "{{ template "vault.fullname" . }}-agent-injector"
securityContext:
runAsNonRoot: true
Expand Down
3 changes: 3 additions & 0 deletions templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ spec:
{{ template "vault.affinity" . }}
{{ template "vault.tolerations" . }}
{{ template "vault.nodeselector" . }}
{{- if .Values.server.priorityClassName }}
priorityClassName: {{ .Values.server.priorityClassName }}
{{- end }}
terminationGracePeriodSeconds: 10
serviceAccountName: {{ template "vault.fullname" . }}
{{ if .Values.server.shareProcessNamespace }}
Expand Down
22 changes: 22 additions & 0 deletions test/unit/injector-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,25 @@ load _helpers
yq -r '.spec.template.spec.nodeSelector' | tee /dev/stderr)
[ "${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" ]
}
26 changes: 24 additions & 2 deletions test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ load _helpers
. | tee /dev/stderr |
yq -r '.spec.template.spec.shareProcessNamespace' | tee /dev/stderr)

[ "${actual}" = "null" ]
[ "${actual}" = "null" ]
}

@test "server/standalone-StatefulSet: shareProcessNamespace enabled" {
Expand All @@ -724,7 +724,7 @@ load _helpers
. | tee /dev/stderr |
yq -r '.spec.template.spec.shareProcessNamespace' | tee /dev/stderr)

[ "${actual}" = "true" ]
[ "${actual}" = "true" ]
}

# extra labels
Expand Down Expand Up @@ -958,3 +958,25 @@ load _helpers
yq -r '.spec.template.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
[ "${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" ]
}
6 changes: 6 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ injector:
# beta.kubernetes.io/arch: amd64
nodeSelector: null

# Priority class for injector pods
priorityClassName: ""

server:
# Resource requests, limits, etc. for the server cluster placement. This
# should map directly to the value of the resources field for a PodSpec.
Expand Down Expand Up @@ -227,6 +230,9 @@ server:
# beta.kubernetes.io/arch: amd64
nodeSelector: {}

# Priority class for server pods
priorityClassName: ""

# Extra labels to attach to the server pods
# This should be a multi-line string mapping directly to the a map of
# the labels to apply to the server pods
Expand Down

0 comments on commit 5631be6

Please sign in to comment.