Skip to content

Commit d9a3a37

Browse files
authored
UNSO-1979: add initContainers to UGC (#150)
* UNSO-1979: add initContainers to UGC * UNSO-1979: add value render template
1 parent a37d3c4 commit d9a3a37

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

charts/sophora-ugc/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 2.0.4
18+
version: 2.0.5
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/sophora-ugc/templates/_helpers.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,16 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
9494
{{- end }}
9595
app.kubernetes.io/managed-by: {{ .Release.Service }}
9696
{{- end }}
97+
98+
{{/*
99+
Renders a value that contains template.
100+
Usage:
101+
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
102+
*/}}
103+
{{- define "common.tplvalues.render" -}}
104+
{{- if typeIs "string" .value }}
105+
{{- tpl .value .context }}
106+
{{- else }}
107+
{{- tpl (.value | toYaml) .context }}
108+
{{- end }}
109+
{{- end -}}

charts/sophora-ugc/templates/deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ spec:
2828
{{- end }}
2929
securityContext:
3030
{{- toYaml .Values.podSecurityContext | nindent 8 }}
31+
initContainers:
32+
{{- if .Values.ugc.extraInitContainers }}
33+
{{ include "common.tplvalues.render" (dict "value" .Values.ugc.extraInitContainers "context" $) | nindent 8 }}
34+
{{- end }}
3135
containers:
3236
- name: {{ .Chart.Name }}
3337
image: "{{ .Values.ugc.image.repository }}:{{ .Values.ugc.image.tag | default .Chart.AppVersion }}"
@@ -80,6 +84,9 @@ spec:
8084
mountPath: /config/application
8185
resources:
8286
{{- toYaml .Values.resources | nindent 12 }}
87+
{{- if .Values.ugc.extraContainers }}
88+
{{ include "common.tplvalues.render" (dict "value" .Values.ugc.extraContainers "context" $) | nindent 8 }}
89+
{{- end }}
8390
volumes:
8491
- name: application-yml
8592
configMap:

charts/sophora-ugc/test-values.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,38 @@ ugc:
9797
rating:
9898
primaryTypes: ["sophora-content-nt:story"]
9999

100+
extraContainers:
101+
- name: cloud-sql-proxy
102+
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.10.1
103+
args:
104+
- "--private-ip"
105+
- "--structured-logs"
106+
- "--port=<DB_PORT>"
107+
- "<INSTANCE_CONNECTION_NAME>"
108+
109+
securityContext:
110+
runAsNonRoot: true
111+
resources:
112+
requests:
113+
memory: "2Gi"
114+
cpu: "1"
115+
116+
extraInitContainers:
117+
- name: cloud-sql-proxy
118+
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.10.1
119+
args:
120+
- "--private-ip"
121+
- "--structured-logs"
122+
- "--port=<DB_PORT>"
123+
- "<INSTANCE_CONNECTION_NAME>"
124+
125+
securityContext:
126+
runAsNonRoot: true
127+
resources:
128+
requests:
129+
memory: "2Gi"
130+
cpu: "1"
131+
100132

101133
ugcMultimedia:
102134
enabled: true

charts/sophora-ugc/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ ugc:
100100
database:
101101
url:
102102

103+
extraContainers: []
104+
extraInitContainers: []
105+
103106
ugcMultimedia:
104107
enabled: false
105108
image:

0 commit comments

Comments
 (0)