priorityclassname

This commit is contained in:
Stavros kois
2023-01-31 16:33:53 +02:00
parent 0afa67d1f5
commit a82b9c596a
4 changed files with 111 additions and 1 deletions

View File

@@ -0,0 +1,81 @@
suite: pod priority class name test
templates:
- common.yaml
tests:
- it: should pass with empty priorityClassName
set:
podOptions:
priorityClassName: ""
controllers:
controller-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: &deploymentDoc 0
isKind:
of: Deployment
- documentIndex: *deploymentDoc
isNull:
path: spec.template.spec.priorityClassName
- it: should pass with priorityClassName from "global"
set:
podOptions:
priorityClassName: some-priority-class
controllers:
controller-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: &deploymentDoc 0
isKind:
of: Deployment
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.priorityClassName
value: some-priority-class
- it: should pass with priorityClassName from "pod"
set:
podOptions:
priorityClassName: some-priority-class
controllers:
controller-name1:
enabled: true
primary: true
type: Deployment
podSpec:
priorityClassName: some-other-priority-class
asserts:
- documentIndex: &deploymentDoc 0
isKind:
of: Deployment
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.priorityClassName
value: some-other-priority-class
- it: should pass with priorityClassName from "pod" with tpl
set:
priorityclass: some-other-priority-class
podOptions:
priorityClassName: some-priority-class
controllers:
controller-name1:
enabled: true
primary: true
type: Deployment
podSpec:
priorityClassName: "{{ .Values.priorityclass }}"
asserts:
- documentIndex: &deploymentDoc 0
isKind:
of: Deployment
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.priorityClassName
value: some-other-priority-class

View File

@@ -16,6 +16,7 @@
| controllers.[controller-name].podSpec.enableServiceLinks | `boolean` | ❌ | ❌ | `{{ .Values.podOptions.enableServiceLinks }}` (false) | Pod's enableServiceLinks |
| controllers.[controller-name].podSpec.restartPolicy | `string` | ❌ | ✅ | `{{ .Values.podOptions.restartPolicy }}` (Always) | Pod's restartPolicy. (Always, Never, OnFailure) |
| controllers.[controller-name].podSpec.schedulerName | `string` | ❌ | ✅ | `{{ .Values.podOptions.schedulerName }}` ("") | Pod's schedulerName |
| controllers.[controller-name].podSpec.priorityClassName | `string` | ❌ | ✅ | `{{ .Values.podOptions.priorityClassName }}` ("") | Pod's priorityClassName |
---
@@ -58,4 +59,5 @@ controllers:
hostNetwork: false
enableServiceLinks: false
schedulerName: some-scheduler
priorityClassName: some-priority-class-name
```

View File

@@ -14,7 +14,10 @@ imagePullSecrets:
hostNetwork: {{ include "ix.v1.common.lib.pod.hostNetwork" (dict "rootCtx" $rootCtx "objectData" $objectData) }}
enableServiceLinks: {{ include "ix.v1.common.lib.pod.enableServiceLinks" (dict "rootCtx" $rootCtx "objectData" $objectData) }}
restartPolicy: {{ include "ix.v1.common.lib.pod.restartPolicy" (dict "rootCtx" $rootCtx "objectData" $objectData) }}
{{- with include "ix.v1.common.lib.pod.schedulerName" (dict "rootCtx" $rootCtx "objectData" $objectData) }}
{{- with (include "ix.v1.common.lib.pod.schedulerName" (dict "rootCtx" $rootCtx "objectData" $objectData)) }}
schedulerName: {{ . }}
{{- end -}}
{{- with (include "ix.v1.common.lib.pod.priorityClassName" (dict "rootCtx" $rootCtx "objectData" $objectData)) }}
priorityClassName: {{ . }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,24 @@
{{/* Returns Priority Class Name */}}
{{/* Call this template:
{{ include "ix.v1.common.lib.pod.priorityClassName" (dict "rootCtx" $ "objectData" $objectData) }}
rootCtx: The root context of the template. It is used to access the global context.
objectData: The object data to be used to render the Pod.
*/}}
{{- define "ix.v1.common.lib.pod.priorityClassName" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $className := "" -}}
{{/* Initialize from the "global" option */}}
{{- with $rootCtx.Values.podOptions.priorityClassName -}}
{{- $className = tpl . $rootCtx -}}
{{- end -}}
{{/* Override with pod's option */}}
{{- with $objectData.podSpec.priorityClassName -}}
{{- $className = tpl . $rootCtx -}}
{{- end -}}
{{- $className -}}
{{- end -}}