Skip to content

Commit 6b23510

Browse files
authoredOct 16, 2024··
feat(sidecar): allow more than one container per pod (#148)
1 parent 293b6c3 commit 6b23510

File tree

10 files changed

+169
-68
lines changed

10 files changed

+169
-68
lines changed
 

‎dotnet/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v2
22
description: .NET Core Helm Chart
33
name: dotnet
4-
version: 13.1.1
4+
version: 13.2.0
55
dependencies:
66
- name: libchart
7-
version: 4.1.1
7+
version: 4.2.0
88
repository: file://../libchart

‎golang/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v2
22
description: golan Helm Chart
33
name: golang
4-
version: 17.1.1
4+
version: 17.2.0
55
dependencies:
66
- name: libchart
7-
version: 4.1.1
7+
version: 4.2.0
88
repository: file://../libchart

‎java/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v2
22
description: Java Helm Chart
33
name: java
4-
version: 10.1.1
4+
version: 10.2.0
55
dependencies:
66
- name: libchart
7-
version: 4.1.1
7+
version: 4.2.0
88
repository: file://../libchart

‎java/values.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,49 @@ image:
1313
# pullSecrets:
1414
# - secret1
1515
# - secret2
16+
sidecars: {}
17+
# - name: helper1
18+
# image:
19+
# repository: "repo"
20+
# tag: "123"
21+
# extraContainerPorts: [8088, 9099]
22+
# securityContext:
23+
# readOnlyRootFilesystem: true
24+
# allowPrivilegeEscalation: false
25+
# resources:
26+
# limits:
27+
# cpu: 100m
28+
# memory: 128Mi
29+
# requests:
30+
# cpu: 100m
31+
# memory: 128Mi
32+
# environment: { }
33+
# secrets: { }
34+
# volumeMounts: [ ]
35+
# # - name: secret-volume
36+
# # mountPath: /app/secrets
37+
# # readOnly: true
38+
# - name: helper2
39+
# image:
40+
# repository: "repo"
41+
# tag: "456"
42+
# extraContainerPorts: [8088, 9099]
43+
# securityContext:
44+
# readOnlyRootFilesystem: true
45+
# allowPrivilegeEscalation: false
46+
# resources:
47+
# limits:
48+
# cpu: 100m
49+
# memory: 128Mi
50+
# requests:
51+
# cpu: 100m
52+
# memory: 128Mi
53+
# environment: { }
54+
# secrets: { }
55+
# volumeMounts:
56+
# - name: secret-volume
57+
# mountPath: /app/secrets
58+
# readOnly: true
1659

1760
initContainers: {}
1861
# - name: network-proxy

‎libchart/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: library
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: 4.1.1
18+
version: 4.2.0
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

‎libchart/templates/_container.tpl

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{{- define "libchart.container" }}
2+
image: "{{ .image.repository }}:{{ .image.tag }}"
3+
imagePullPolicy: Always
4+
{{- if .command }}
5+
command:
6+
{{ toYaml .command | nindent 6 }}
7+
{{- end }}
8+
{{- if .args }}
9+
args:
10+
{{ toYaml .args | nindent 6 }}
11+
{{- end }}
12+
{{- if or (.volumeMounts) (.csi) }}
13+
volumeMounts:
14+
{{- if .volumeMounts }}
15+
{{- toYaml .volumeMounts | nindent 6 }}
16+
{{- end }}
17+
{{- if .csi }}
18+
- name: {{ .csi.name }}
19+
mountPath: {{ .csi.mountPath | quote }}
20+
readOnly: true
21+
{{- end }}
22+
{{- end }}
23+
ports:
24+
{{- if .deployKind }} {{/* a hack to check if we are in the root context or in a sidecar; sidecars are not using the port mapping from the service */}}
25+
{{- "- name: http" | nindent 4 }}
26+
{{- "containerPort: " | nindent 6 }}{{ .service.targetPort | default 8080 }}
27+
protocol: TCP
28+
{{- end }}
29+
{{- if .extraContainerPorts }}
30+
{{ toYaml .extraContainerPorts | nindent 6 }}
31+
{{- end }}
32+
{{- $liveness := default dict .liveness }}
33+
{{- $livenessEnabled := default false $liveness.enabled }}
34+
{{- if and $liveness $livenessEnabled }}
35+
livenessProbe:
36+
httpGet:
37+
path: {{ .liveness.path | default "/" }}
38+
port: {{ .liveness.port | default 8080 }}
39+
initialDelaySeconds: {{ .liveness.delay | default 15 }}
40+
timeoutSeconds: {{ .liveness.timeout | default 15 }}
41+
periodSeconds: {{ .liveness.periodSeconds | default 15 }}
42+
{{- end }}
43+
{{- $readiness := default dict .readiness }}
44+
{{- $readinessEnabled := default false $readiness.enabled }}
45+
{{- if and $readiness $readinessEnabled }}
46+
readinessProbe:
47+
httpGet:
48+
path: {{ .readiness.path | default "/" }}
49+
port: {{ .readiness.port | default 8080 }}
50+
initialDelaySeconds: {{ .readiness.delay | default 15 }}
51+
timeoutSeconds: {{ .readiness.timeout | default 15 }}
52+
periodSeconds: {{ .readiness.periodSeconds | default 15 }}
53+
{{- end }}
54+
env:
55+
{{- if .secrets }}
56+
{{ toYaml .secrets | nindent 6 }}
57+
{{- end }}
58+
{{- if .environment }}
59+
{{ toYaml .environment | nindent 6 }}
60+
{{- end }}
61+
resources:
62+
{{- toYaml .resources | nindent 6 }}
63+
securityContext:
64+
{{- toYaml .securityContext | nindent 6 }}
65+
{{- end }}

‎libchart/templates/_pod.tpl

+7-57
Original file line numberDiff line numberDiff line change
@@ -16,63 +16,13 @@ initContainers:
1616

1717
containers:
1818
- name: {{ .Chart.Name }}
19-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
20-
imagePullPolicy: Always
21-
{{- if .Values.command }}
22-
command:
23-
{{ toYaml .Values.command | nindent 6 }}
24-
{{- end }}
25-
{{- if .Values.args }}
26-
args:
27-
{{ toYaml .Values.args | nindent 6 }}
28-
{{- end }}
29-
{{- if or (.Values.volumeMounts) (.Values.csi) }}
30-
volumeMounts:
31-
{{- if .Values.volumeMounts }}
32-
{{ toYaml .Values.volumeMounts | nindent 6 }}
33-
{{- end }}
34-
{{- if .Values.csi }}
35-
- name: {{ .Values.csi.name }}
36-
mountPath: {{ .Values.csi.mountPath | quote }}
37-
readOnly: true
38-
{{- end }}
39-
{{- end }}
40-
ports:
41-
- name: http
42-
containerPort: {{ .Values.service.targetPort | default 8080 }}
43-
protocol: TCP
44-
{{ if .Values.extraContainerPorts }}
45-
{{ toYaml .Values.extraContainerPorts | nindent 6 }}
46-
{{- end }}
47-
{{- if and (.Values.liveness) (.Values.liveness.enabled) }}
48-
livenessProbe:
49-
httpGet:
50-
path: {{ .Values.liveness.path | default "/" }}
51-
port: {{ .Values.liveness.port | default 8080 }}
52-
initialDelaySeconds: {{ .Values.liveness.delay | default 15 }}
53-
timeoutSeconds: {{ .Values.liveness.timeout | default 15 }}
54-
periodSeconds: {{ .Values.liveness.periodSeconds | default 15 }}
55-
{{- end }}
56-
{{- if and (.Values.readiness) (.Values.readiness.enabled) }}
57-
readinessProbe:
58-
httpGet:
59-
path: {{ .Values.readiness.path | default "/" }}
60-
port: {{ .Values.readiness.port | default 8080 }}
61-
initialDelaySeconds: {{ .Values.readiness.delay | default 15 }}
62-
timeoutSeconds: {{ .Values.readiness.timeout | default 15 }}
63-
periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }}
64-
{{- end }}
65-
env:
66-
{{- if .Values.secrets }}
67-
{{ toYaml .Values.secrets | nindent 6 }}
68-
{{- end }}
69-
{{- if .Values.environment }}
70-
{{ toYaml .Values.environment | nindent 6 }}
71-
{{- end }}
72-
resources:
73-
{{ toYaml .Values.resources | nindent 6 }}
74-
securityContext:
75-
{{- toYaml .Values.securityContext | nindent 6 }}
19+
{{- include "libchart.container" .Values | indent 2 -}}
20+
{{- range $sc := .Values.sidecars -}}
21+
{{ "- name: " | nindent 2 }}{{ $sc.name }}
22+
{{- include "libchart.container" $sc | indent 2 }}
23+
{{- end }}
24+
{{- if .Values.initContainers }}
25+
{{- end }}
7626
{{- with .Values.nodeSelector }}
7727
nodeSelector:
7828
{{ toYaml . | nindent 4 }}

‎libchart/values.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,49 @@ image:
1414
# pullSecrets:
1515
# - secret1
1616
# - secret2
17+
sidecars: {}
18+
# - name: helper1
19+
# image:
20+
# repository: "repo"
21+
# tag: "123"
22+
# extraContainerPorts: [8088, 9099]
23+
# securityContext:
24+
# readOnlyRootFilesystem: true
25+
# allowPrivilegeEscalation: false
26+
# resources:
27+
# limits:
28+
# cpu: 100m
29+
# memory: 128Mi
30+
# requests:
31+
# cpu: 100m
32+
# memory: 128Mi
33+
# environment: { }
34+
# secrets: { }
35+
# volumeMounts: [ ]
36+
# # - name: secret-volume
37+
# # mountPath: /app/secrets
38+
# # readOnly: true
39+
# - name: helper2
40+
# image:
41+
# repository: "repo"
42+
# tag: "456"
43+
# extraContainerPorts: [8088, 9099]
44+
# securityContext:
45+
# readOnlyRootFilesystem: true
46+
# allowPrivilegeEscalation: false
47+
# resources:
48+
# limits:
49+
# cpu: 100m
50+
# memory: 128Mi
51+
# requests:
52+
# cpu: 100m
53+
# memory: 128Mi
54+
# environment: { }
55+
# secrets: { }
56+
# volumeMounts:
57+
# - name: secret-volume
58+
# mountPath: /app/secrets
59+
# readOnly: true
1760

1861
initContainers: {}
1962
# - name: network-proxy

‎nodejs/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v2
22
description: Node.js Helm Chart
33
name: nodejs
4-
version: 17.1.1
4+
version: 17.2.0
55
dependencies:
66
- name: libchart
7-
version: 4.1.1
7+
version: 4.2.0
88
repository: file://../libchart

‎web/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
appVersion: "1.0"
33
description: Helm chart for deployment of web servers
44
name: web
5-
version: 14.1.1
5+
version: 14.2.0
66
dependencies:
77
- name: libchart
8-
version: 4.1.1
8+
version: 4.2.0
99
repository: file://../libchart

0 commit comments

Comments
 (0)
Please sign in to comment.