mirror of
https://github.com/truenas/charts.git
synced 2026-06-17 15:38:49 +08:00
termperiodsec
This commit is contained in:
@@ -31,9 +31,6 @@ tests:
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.priorityClassName
|
||||
@@ -51,9 +48,6 @@ tests:
|
||||
podSpec:
|
||||
priorityClassName: some-other-priority-class
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.priorityClassName
|
||||
@@ -61,7 +55,7 @@ tests:
|
||||
|
||||
- it: should pass with priorityClassName from "pod" with tpl
|
||||
set:
|
||||
priorityclass: some-other-priority-class
|
||||
priorityClass: some-other-priority-class
|
||||
podOptions:
|
||||
priorityClassName: some-priority-class
|
||||
controllers:
|
||||
@@ -70,11 +64,8 @@ tests:
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
priorityClassName: "{{ .Values.priorityclass }}"
|
||||
priorityClassName: "{{ .Values.priorityClass }}"
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.priorityClassName
|
||||
|
||||
@@ -32,9 +32,6 @@ tests:
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.restartPolicy
|
||||
@@ -52,9 +49,6 @@ tests:
|
||||
podSpec:
|
||||
restartPolicy: Always
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.restartPolicy
|
||||
@@ -93,9 +87,6 @@ tests:
|
||||
podSpec:
|
||||
restartPolicy: "{{ .Values.policy }}"
|
||||
asserts:
|
||||
- documentIndex: *jobDoc
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *jobDoc
|
||||
equal:
|
||||
path: spec.template.spec.restartPolicy
|
||||
|
||||
@@ -31,9 +31,6 @@ tests:
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.schedulerName
|
||||
@@ -51,9 +48,6 @@ tests:
|
||||
podSpec:
|
||||
schedulerName: some-other-scheduler
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.schedulerName
|
||||
@@ -72,9 +66,6 @@ tests:
|
||||
podSpec:
|
||||
schedulerName: "{{ .Values.scheduler }}"
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.schedulerName
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
suite: pod termination grace period test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with empty terminationGracePeriodSeconds
|
||||
set:
|
||||
podOptions:
|
||||
terminationGracePeriodSeconds: ""
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: DaemonSet
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &daemonSetDoc 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: *daemonSetDoc
|
||||
isNull:
|
||||
path: spec.template.spec.terminationGracePeriodSeconds
|
||||
|
||||
- it: should pass with terminationGracePeriodSeconds from "global"
|
||||
set:
|
||||
podOptions:
|
||||
terminationGracePeriodSeconds: 100
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: DaemonSet
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *daemonSetDoc
|
||||
equal:
|
||||
path: spec.template.spec.terminationGracePeriodSeconds
|
||||
value: 100
|
||||
|
||||
- it: should pass with terminationGracePeriodSeconds from "pod"
|
||||
set:
|
||||
podOptions:
|
||||
terminationGracePeriodSeconds: 100
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: DaemonSet
|
||||
podSpec:
|
||||
terminationGracePeriodSeconds: 150
|
||||
asserts:
|
||||
- documentIndex: *daemonSetDoc
|
||||
equal:
|
||||
path: spec.template.spec.terminationGracePeriodSeconds
|
||||
value: 150
|
||||
|
||||
- it: should pass with terminationGracePeriodSeconds from "pod" with tpl
|
||||
set:
|
||||
period: 125
|
||||
podOptions:
|
||||
terminationGracePeriodSeconds: 50
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: DaemonSet
|
||||
podSpec:
|
||||
terminationGracePeriodSeconds: "{{ .Values.period }}"
|
||||
asserts:
|
||||
- documentIndex: *daemonSetDoc
|
||||
equal:
|
||||
path: spec.template.spec.terminationGracePeriodSeconds
|
||||
value: 125
|
||||
@@ -1,23 +1,24 @@
|
||||
# Controllers
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------------------------- | :-------: | :------: | :-----------: | :---------------------------------------------------: | :----------------------------------------------------------------------------------- |
|
||||
| controllers | `dict` | ❌ | ❌ | `{}` | Define the controllers as dicts |
|
||||
| controllers.[controller-name] | `dict` | ✅ | ❌ | `{}` | Holds controller definition |
|
||||
| controllers.[controller-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the controller |
|
||||
| controllers.[controller-name].primary | `boolean` | ✅ | ❌ | `false` | Sets the controller as primary |
|
||||
| controllers.[controller-name].labels | `dict` | ❌ | ✅ | `{}` | Additional labels for controller |
|
||||
| controllers.[controller-name].annotations | `dict` | ❌ | ✅ | `{}` | Additional annotations for controller |
|
||||
| controllers.[controller-name].type | `string` | ✅ | ❌ | `""` | Define the kind of the controller (Deployment, DaemonSet, StatefulSet, CronJob, Job) |
|
||||
| controllers.[controller-name].podSpec | `dict` | ✅ | ❌ | `{}` | Holds the pod definition |
|
||||
| controllers.[controller-name].podSpec.labels | `dict` | ❌ | ✅ | `{}` | Pod Labels |
|
||||
| controllers.[controller-name].podSpec.annotations | `dict` | ❌ | ✅ | `{}` | Pod Annotations |
|
||||
| controllers.[controller-name].podSpec.hostNetwork | `boolean` | ❌ | ❌ | `{{ .Values.podOptions.hostNetwork }}` (false) | Pod's hostNetwork |
|
||||
| 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 |
|
||||
| controllers.[controller-name].podSpec.hostname | `string` | ❌ | ✅ | `""` | Pod's hostname |
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------------------------------------ | :-------: | :------: | :-----------: | :------------------------------------------------------------: | :----------------------------------------------------------------------------------- |
|
||||
| controllers | `dict` | ❌ | ❌ | `{}` | Define the controllers as dicts |
|
||||
| controllers.[controller-name] | `dict` | ✅ | ❌ | `{}` | Holds controller definition |
|
||||
| controllers.[controller-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the controller |
|
||||
| controllers.[controller-name].primary | `boolean` | ✅ | ❌ | `false` | Sets the controller as primary |
|
||||
| controllers.[controller-name].labels | `dict` | ❌ | ✅ | `{}` | Additional labels for controller |
|
||||
| controllers.[controller-name].annotations | `dict` | ❌ | ✅ | `{}` | Additional annotations for controller |
|
||||
| controllers.[controller-name].type | `string` | ✅ | ❌ | `""` | Define the kind of the controller (Deployment, DaemonSet, StatefulSet, CronJob, Job) |
|
||||
| controllers.[controller-name].podSpec | `dict` | ✅ | ❌ | `{}` | Holds the pod definition |
|
||||
| controllers.[controller-name].podSpec.labels | `dict` | ❌ | ✅ | `{}` | Pod Labels |
|
||||
| controllers.[controller-name].podSpec.annotations | `dict` | ❌ | ✅ | `{}` | Pod Annotations |
|
||||
| controllers.[controller-name].podSpec.hostNetwork | `boolean` | ❌ | ❌ | `{{ .Values.podOptions.hostNetwork }}` (false) | Pod's hostNetwork |
|
||||
| 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 |
|
||||
| controllers.[controller-name].podSpec.hostname | `string` | ❌ | ✅ | `""` | Pod's hostname |
|
||||
| controllers.[controller-name].podSpec.terminationGracePeriodSeconds | `int` | ❌ | ✅ | `{{ .Values.podOptions.terminationGracePeriodSeconds }}` (120) | Pod's terminationGracePeriodSeconds |
|
||||
|
||||
---
|
||||
|
||||
@@ -62,4 +63,5 @@ controllers:
|
||||
schedulerName: some-scheduler
|
||||
priorityClassName: some-priority-class-name
|
||||
hostname: some-hostname
|
||||
terminationGracePeriodSeconds: 100
|
||||
```
|
||||
|
||||
@@ -24,4 +24,7 @@ priorityClassName: {{ . }}
|
||||
{{- with (include "ix.v1.common.lib.pod.hostname" (dict "rootCtx" $rootCtx "objectData" $objectData)) }}
|
||||
hostname: {{ . }}
|
||||
{{- end }}
|
||||
{{- with (include "ix.v1.common.lib.pod.terminationGracePeriodSeconds" (dict "rootCtx" $rootCtx "objectData" $objectData)) }}
|
||||
terminationGracePeriodSeconds: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{{/* Returns Termination Grace Period Seconds */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.pod.terminationGracePeriodSeconds" (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.terminationGracePeriodSeconds" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $gracePeriod := "" -}}
|
||||
|
||||
{{/* Initialize from the "global" option */}}
|
||||
{{- with $rootCtx.Values.podOptions.terminationGracePeriodSeconds -}}
|
||||
{{- $gracePeriod = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Override with pod's option */}}
|
||||
{{- with $objectData.podSpec.terminationGracePeriodSeconds -}}
|
||||
{{- $gracePeriod = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Expand tpl */}}
|
||||
{{- if (kindIs "string" $gracePeriod) -}}
|
||||
{{- $gracePeriod = tpl $gracePeriod $rootCtx -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $gracePeriod -}}
|
||||
{{- end -}}
|
||||
@@ -119,7 +119,7 @@ podOptions:
|
||||
tolerations: []
|
||||
schedulerName: ""
|
||||
priorityClassName: ""
|
||||
terminationGracePeriodSeconds: 30
|
||||
terminationGracePeriodSeconds: 120
|
||||
# TODO: Add affinity
|
||||
# TODO: Add topologySpreadConstraints
|
||||
|
||||
|
||||
Reference in New Issue
Block a user