Skip to content

Commit

Permalink
Minor corrections in template (#4767)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Ariza Toledano committed Dec 17, 2020
1 parent 1e96197 commit 2239ec1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 71 deletions.
25 changes: 6 additions & 19 deletions template/CHART_NAME/templates/daemonset.yaml
Expand Up @@ -34,8 +34,8 @@ spec:
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "context" $) | nindent 10 }}
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" %%COMPONENT_NAME%% "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" %%COMPONENT_NAME%% "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.type "key" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.key "values" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.nodeSelector }}
Expand All @@ -48,7 +48,7 @@ spec:
priorityClassName: {{ .Values.%%MAIN_OBJECT_BLOCK%%.priorityClassName | quote }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext.enabled }}
securityContext: {{- omit .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext "enabled" | toYaml | nindent 12 }}
securityContext: {{- omit .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
initContainers:
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
Expand Down Expand Up @@ -107,25 +107,12 @@ spec:
resources: {{- toYaml .Values.%%MAIN_OBJECT_BLOCK%%.resources | nindent 12 }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.enabled }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
%%httpGet || command || etc%%
initialDelaySeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.failureThreshold }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe "enabled") "context" $) | nindent 12 }}
{{- else if .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
%%httpGet || command || etc%%
initialDelaySeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.failureThreshold }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe "enabled") "context" $) | nindent 12 }}
{{- else if .Values.%%MAIN_OBJECT_BLOCK%%.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
Expand Down
26 changes: 7 additions & 19 deletions template/CHART_NAME/templates/deployment.yaml
Expand Up @@ -35,8 +35,8 @@ spec:
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "context" $) | nindent 10 }}
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" %%COMPONENT_NAME%% "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" %%COMPONENT_NAME%% "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.type "key" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.key "values" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.nodeSelector }}
Expand All @@ -49,7 +49,7 @@ spec:
priorityClassName: {{ .Values.%%MAIN_OBJECT_BLOCK%%.priorityClassName | quote }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext.enabled }}
securityContext: {{- omit .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext "enabled" | toYaml | nindent 12 }}
securityContext: {{- omit .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
initContainers:
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
Expand Down Expand Up @@ -104,25 +104,13 @@ spec:
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.resources }}
resources: {{- toYaml .Values.%%MAIN_OBJECT_BLOCK%%.resources | nindent 12 }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
%%httpGet || command || etc%%
initialDelaySeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.failureThreshold }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe "enabled") "context" $) | nindent 12 }}
{{- else if .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
%%httpGet || command || etc%%
initialDelaySeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.failureThreshold }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe "enabled") "context" $) | nindent 12 }}
{{- else if .Values.%%MAIN_OBJECT_BLOCK%%.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
Expand Down
1 change: 0 additions & 1 deletion template/CHART_NAME/templates/service.yaml
Expand Up @@ -27,4 +27,3 @@ spec:
protocol: bar
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
app.kubernetes.io/component: %%COMPONENT_NAME%%
type: ClusterIP
34 changes: 10 additions & 24 deletions template/CHART_NAME/templates/statefulset.yaml
Expand Up @@ -37,8 +37,8 @@ spec:
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "context" $) | nindent 10 }}
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" %%COMPONENT_NAME%% "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" %%COMPONENT_NAME%% "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.type "key" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.key "values" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.nodeSelector }}
Expand All @@ -51,7 +51,7 @@ spec:
priorityClassName: {{ .Values.%%MAIN_OBJECT_BLOCK%%.priorityClassName | quote }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext.enabled }}
securityContext: {{- omit .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext "enabled" | toYaml | nindent 12 }}
securityContext: {{- omit .Values.%%MAIN_OBJECT_BLOCK%%.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
initContainers:
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
Expand All @@ -60,8 +60,9 @@ spec:
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
command:
- %%commands%%
securityContext:
runAsUser: 0
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.%%MAIN_OBJECT_BLOCK%%.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -106,25 +107,13 @@ spec:
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.resources }}
resources: {{- toYaml .Values.%%MAIN_OBJECT_BLOCK%%.resources | nindent 12 }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
%%httpGet || command || etc%%
initialDelaySeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.failureThreshold }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.%%MAIN_OBJECT_BLOCK%%.livenessProbe "enabled") "context" $) | nindent 12 }}
{{- else if .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
%%httpGet || command || etc%%
initialDelaySeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.failureThreshold }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.%%MAIN_OBJECT_BLOCK%%.readinessProbe "enabled") "context" $) | nindent 12 }}
{{- else if .Values.%%MAIN_OBJECT_BLOCK%%.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
Expand All @@ -138,9 +127,6 @@ spec:
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.sidecars "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.sidecars "context" $) | nindent 8 }}
{{- end }}
volumes:
- name: foo
hostPath:
Expand Down
20 changes: 12 additions & 8 deletions template/CHART_NAME/values.yaml
Expand Up @@ -74,15 +74,15 @@ service:
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes
livenessProbe:
enabled: true
path: "/path"
%%httpGet || command || etc%%
initialDelaySeconds: foo
periodSeconds: bar
timeoutSeconds: foo
failureThreshold: bar
successThreshold: foo
readinessProbe:
enabled: true
path: "/path"
%%httpGet || command || etc%%
initialDelaySeconds: foo
periodSeconds: bar
timeoutSeconds: foo
Expand Down Expand Up @@ -115,14 +115,17 @@ service:
# cpu: 200m
# memory: 10Mi

## SecurityContext configuration
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
## %%MAIN_CONTAINER_NAME%% containers' Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
##
containerSecurityContext:
enabled: true
runAsUser: 1001
runAsNonRoot: true

## %%MAIN_CONTAINER_NAME%% pods' Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
##
podSecurityContext:
enabled: true
fsGroup: 1001
Expand Down Expand Up @@ -210,12 +213,13 @@ service:
updateStrategy:
type: RollingUpdate

## An array to add extra env vars
## For example:
## Additional environment variables to set
## Example:
## extraEnvVars:
## - name: FOO
## value: "bar"
##
extraEnvVars: []
# - name: BEARER_AUTH
# value: true

## ConfigMap with extra environment variables
##
Expand Down

0 comments on commit 2239ec1

Please sign in to comment.