Skip to content

Commit

Permalink
Added support for initContainers
Browse files Browse the repository at this point in the history
  • Loading branch information
hfjn committed Feb 2, 2024
1 parent 6dfbec2 commit 812bf0c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions charts/generic-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ app:
| `alerting.custom.*.description` | __required if used__ | A longer description of the alert; can include metric labels via templating |
| `sidecars` | `[]` | Additional sidecar containers to be added to the `Pod` |
| `sidecarTemplates` | `[]` | Strings to be templated providing additional sidecar containers to be added to the Pod |
| `initContainers` | `[]` | Additional init containers to be added to the `Pod` |
| `initContainerTemplates` | `[]` | Strings to be templated providing additional init containers to be added to the Pod
| `rbac.roles` | `[]` | Namespace-specific Kubernetes RBAC Roles to assign to the service (supports templating) |
| `rbac.clusterRoles` | `[]` | Cluster-wide Kubernetes RBAC Roles to assign to the service (supports templating) |
| `rbac.existingServiceAccount` | | The name of an existing service account to use (instead of automatically creating one for the service) |
Expand Down
21 changes: 21 additions & 0 deletions charts/generic-service/ci/initContainer-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# InitContainer test

name: test
fullname: my-test

image:
repository: jwilder/whoami
tag: latest

initContainers:
- name: init1
image: docker/whalesay
command: ["cowsay"]
args: ["hi"]

initContainerTemplates:
- |
name: init2
image: docker/whalesay:{{ .Values.image.tag }}
command: ["cowsay"]
args: ["hi"]
16 changes: 16 additions & 0 deletions charts/generic-service/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,19 @@ spec:
{{- $spec | nindent 10 }}
{{- end }}
{{- end }}

{{ if .Values.initContainers }}
initContainers:
{{- range .Values.initContainers }}
- securityContext: {{- $.Values.securityContext.container | toYaml | nindent 12 }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- range .Values.initContainerTemplates }}
{{- $spec := tpl . $ }}
{{- if $spec }}
- securityContext: {{- $.Values.securityContext.container | toYaml | nindent 12 }}
{{- $spec | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}

10 changes: 10 additions & 0 deletions charts/generic-service/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,16 @@
"items": {"type": "string"},
"description": "Strings to be templated providing additional sidecar containers to be added to the Pod"
},
"initContainers": {
"type": "array",
"items": {"type": "object"},
"description": "Additional init containers to be added to the Pod"
},
"initContainerTemplates": {
"type": "array",
"items": {"type": "string"},
"description": "Strings to be templated providing additional init containers to be added to the Pod"
},
"rbac": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions charts/generic-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ alerting:
labelValue: ""
custom: {}

initContainers: []
initContainerTemplates: []

sidecars: []
sidecarTemplates: []

Expand Down

0 comments on commit 812bf0c

Please sign in to comment.