-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[app] init statefulset support (#312)
- Loading branch information
Showing
9 changed files
with
415 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
{{/* vim: set filetype=helm: */}} | ||
|
||
{{- define "app.resources.statefulset" -}} | ||
{{- if and .Values.app.workload.enabled (has .Values.app.workload.type (list "statefulset" "sts")) }} | ||
--- | ||
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }} | ||
kind: StatefulSet | ||
metadata: | ||
name: {{ template "common.names.fullname" . }} | ||
namespace: {{ include "common.names.namespace" . | quote }} | ||
labels: | ||
{{- include "common.labels.standard" . | nindent 4 }} | ||
{{- include "app.labels.component" . | nindent 4 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
serviceName: {{ template "common.names.fullname" . }} | ||
{{- if not .Values.autoscaling.enabled }} | ||
replicas: {{ .Values.replicaCount }} | ||
{{- end }} | ||
{{- if .Values.updateStrategy }} | ||
updateStrategy: {{- toYaml .Values.updateStrategy | nindent 4 }} | ||
{{- end }} | ||
minReadySeconds: {{ .Values.minReadySeconds }} | ||
podManagementPolicy: {{ .Values.podManagementPolicy }} | ||
{{- with .Values.persistentVolumeClaimRetentionPolicy }} | ||
persistentVolumeClaimRetentionPolicy: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "common.labels.matchLabels" . | nindent 6 }} | ||
{{- include "app.labels.component" . | nindent 6 }} | ||
template: | ||
metadata: | ||
annotations: | ||
{{- include "app.template.checksums" $ | indent 8 }} | ||
{{- if .Values.podAnnotations }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }} | ||
{{- end }} | ||
labels: | ||
{{- include "common.labels.standard" . | nindent 8 }} | ||
{{- include "app.labels.component" . | nindent 8 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.podLabels }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
{{- with .Values.enableServiceLinks }} | ||
enableServiceLinks: {{ . }} | ||
{{- end }} | ||
serviceAccountName: {{ template "app.serviceAccountName" . }} | ||
{{- if kindIs "bool" .Values.automountServiceAccountToken }} | ||
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} | ||
{{- end }} | ||
{{- include "app.imagePullSecrets" . | nindent 6 }} | ||
{{- if .Values.hostAliases }} | ||
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if kindIs "bool" .Values.hostNetwork }} | ||
hostNetwork: {{ .Values.hostNetwork }} | ||
{{- end }} | ||
{{- if .Values.dnsPolicy }} | ||
dnsPolicy: {{ .Values.dnsPolicy }} | ||
{{- end }} | ||
{{- if .Values.affinity }} | ||
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }} | ||
{{- else }} | ||
affinity: | ||
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "component" ._include.component "context" $) | nindent 10 }} | ||
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "component" ._include.component "context" $) | nindent 10 }} | ||
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }} | ||
{{- end }} | ||
{{- if .Values.nodeSelector }} | ||
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.nodeSelector "context" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.tolerations }} | ||
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.priorityClassName }} | ||
priorityClassName: {{ .Values.priorityClassName | quote }} | ||
{{- end }} | ||
{{- if .Values.schedulerName }} | ||
schedulerName: {{ .Values.schedulerName | quote }} | ||
{{- end }} | ||
{{- if .Values.topologySpreadConstraints }} | ||
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.podSecurityContext.enabled }} | ||
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.terminationGracePeriodSeconds }} | ||
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} | ||
{{- end }} | ||
initContainers: | ||
{{- if and .Values.volumePermissions .Values.persistence .Values.volumePermissions.command .Values.persistence.enabled }} | ||
- name: volume-permissions | ||
image: {{ include "app.volumePermissions.image" .Values }} | ||
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }} | ||
command: {{- include "common.tplvalues.render" (dict "value" .Values.volumePermissions.command "context" $) | nindent 12 -}} | ||
securityContext: {{- include "common.tplvalues.render" . | nindent 12 }} | ||
{{- if .Values.volumePermissions.resources }} | ||
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }} | ||
{{- end }} | ||
volumeMounts: | ||
{{- if .Values.persistence.enabled }} | ||
- name: {{ .Values.persistence.mountName }} | ||
mountPath: {{ .Values.persistence.mountPath }} | ||
{{- if .Values.persistence.subPath }} | ||
subPath: {{ .Values.persistence.subPath }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.initContainers -}} | ||
{{/* Use extendeded .Values.initContainers (use, values map) */}} | ||
{{- include "app.containers" (dict "initContainers" true "values" .Values.initContainers "top" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.extraInitContainers }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.extraInitContainers "context" $) | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ .Values.app.name }} | ||
image: {{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }} | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
{{- if .Values.containerSecurityContext.enabled }} | ||
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.diagnosticMode.enabled }} | ||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} | ||
{{- else if .Values.command }} | ||
command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.diagnosticMode.enabled }} | ||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} | ||
{{- else if .Values.args }} | ||
args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} | ||
{{- end }} | ||
env: | ||
{{- with .Values.env }} | ||
{{- include "app.tplvalues.named-list" (dict "valueKey" "value" "value" . "toString" true "context" $) | nindent 12 -}} | ||
{{- end }} | ||
{{- if .Values.extraEnvVars }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }} | ||
{{- end }} | ||
envFrom: | ||
{{- with .Values.envFrom }} | ||
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.extraEnvVarsCM }} | ||
- configMapRef: | ||
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }} | ||
{{- end }} | ||
{{- if .Values.extraEnvVarsSecret }} | ||
- secretRef: | ||
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }} | ||
{{- end }} | ||
{{- if .Values.resources }} | ||
resources: {{- toYaml .Values.resources | nindent 12 }} | ||
{{- end }} | ||
{{- with include "app.tplvalues.named-list" ( dict "value" .Values.containerPorts "valueKey" "containerPort" "context" $) }} | ||
ports: {{ . | nindent 12 }} | ||
{{- end }} | ||
{{- if not .Values.diagnosticMode.enabled }} | ||
{{- if .Values.customLivenessProbe }} | ||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }} | ||
{{- else if .Values.livenessProbe.enabled }} | ||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.customReadinessProbe }} | ||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }} | ||
{{- else if .Values.readinessProbe.enabled }} | ||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.customStartupProbe }} | ||
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }} | ||
{{- else if .Values.startupProbe.enabled }} | ||
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.lifecycleHooks }} | ||
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} | ||
{{- end }} | ||
volumeMounts: | ||
{{- if .Values.persistence.enabled }} | ||
- name: {{ .Values.persistence.mountName }} | ||
mountPath: {{ .Values.persistence.mountPath }} | ||
{{- if .Values.persistence.subPath }} | ||
subPath: {{ .Values.persistence.subPath }} | ||
{{- end }} | ||
{{- end }} | ||
{{- with .Values.volumeMounts }} | ||
{{- include "app.tplvalues.named-list" (dict "value" . "context" $) | nindent 12 -}} | ||
{{- end }} | ||
{{- if .Values.extraVolumeMounts }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.containers }} | ||
{{/* Use extendeded .Values.app.containers (use, values map) */}} | ||
{{- include "app.containers" (dict "values" .Values.containers "top" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.sidecars }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }} | ||
{{- end }} | ||
volumes: | ||
{{- if and .Values.persistence.enabled (or (eq .Values.persistence.type "pvc") .Values.persistence.emptyDir) }} | ||
- name: {{ .Values.persistence.mountName }} | ||
{{- if .Values.persistence.emptyDir }} | ||
emptyDir: {} | ||
{{- else }} | ||
persistentVolumeClaim: | ||
claimName: {{ default (include "common.names.fullname" $) .Values.persistence.existingClaim }} | ||
{{- end }} | ||
{{- end }} | ||
{{- with .Values.volumes }} | ||
{{- include "app.tplvalues.named-list" (dict "value" . "context" $) | nindent 8 -}} | ||
{{- end }} | ||
{{- if .Values.extraVolumes }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if and .Values.persistence.enabled (has .Values.persistence.type (list "sts" "statefulset")) }} | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: {{ .Values.persistence.mountName }} | ||
labels: | ||
{{- include "common.labels.matchLabels" . | nindent 8 }} | ||
{{- include "app.labels.component" . | nindent 8 }} | ||
{{- if or .Values.persistence.annotations .Values.commonAnnotations }} | ||
annotations: | ||
{{- if .Values.persistence.annotations }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.persistence.annotations "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
{{- end }} | ||
spec: | ||
accessModes: | ||
{{- range .Values.persistence.accessModes }} | ||
- {{ . | quote }} | ||
{{- end }} | ||
resources: | ||
requests: | ||
storage: {{ .Values.persistence.size | quote }} | ||
{{- if .Values.persistence.selector }} | ||
selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.persistence.dataSource }} | ||
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.dataSource "context" $) | nindent 8 }} | ||
{{- end }} | ||
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 6 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{/* Include the resource */}} | ||
{{- if eq "direct" (include "app.chart.mode" .) -}} | ||
{{- range $_, $component := concat (list "") $.Values.app.components -}} | ||
{{- $values := ternary $.Values (get $.Values "component") (eq $component "") | default dict -}} | ||
{{- include "app.statefulset" (dict "component" $component "values" $values "top" $) -}} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.