Skip to content

Commit 4afb61d

Browse files
authored
feat(atlantis): allow restartPolicy on containers for native sidecars (#563)
The bundled values.schema.json carries an older k8s Container definition (additionalProperties: false) that predates the restartPolicy field added to Container in k8s 1.28. This rejected init containers declared as native sidecars (an initContainers entry with restartPolicy: Always): at '/initContainers/0': additional properties 'restartPolicy' not allowed Add restartPolicy to the Container definition so initContainers and extraContainers can declare native sidecars. Additive and renders nothing differently by default. Adds a statefulset unittest covering the case. Signed-off-by: DrFaust92 <ilia.lazebnik@placer.ai>
1 parent f543305 commit 4afb61d

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

charts/atlantis/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: v1
33
appVersion: v0.45.0
44
description: A Helm chart for Atlantis https://www.runatlantis.io
55
name: atlantis
6-
version: 6.9.0
6+
version: 6.9.1
77
keywords:
88
- terraform
99
home: https://www.runatlantis.io

charts/atlantis/tests/statefulset_test.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ tests:
258258
- equal:
259259
path: spec.template.spec.hostNetwork
260260
value: true
261+
- it: native sidecar via initContainers restartPolicy
262+
template: statefulset.yaml
263+
set:
264+
initContainers:
265+
- name: sidecar
266+
image: busybox:latest
267+
restartPolicy: Always
268+
asserts:
269+
- equal:
270+
path: spec.template.spec.initContainers[0].name
271+
value: sidecar
272+
- equal:
273+
path: spec.template.spec.initContainers[0].restartPolicy
274+
value: Always
261275
- it: serviceAccountName
262276
template: statefulset.yaml
263277
set:

charts/atlantis/values.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,10 @@
16201620
"$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements",
16211621
"description": "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
16221622
},
1623+
"restartPolicy": {
1624+
"description": "RestartPolicy defines the restart behavior of individual containers in a pod. This field may only be set for init containers, and the only allowed value is \"Always\". For non-init containers or when this field is not specified, the restart behavior is defined by the Pod's restart policy and the container type. Setting the RestartPolicy as \"Always\" for the init container will have the following effect: this init container will be continually restarted on exit until all regular containers have terminated. Once all regular containers have completed, all init containers with restartPolicy \"Always\" will be shut down. This lifecycle differs from normal init containers and is often referred to as a \"sidecar\" container.",
1625+
"type": "string"
1626+
},
16231627
"securityContext": {
16241628
"$ref": "#/definitions/io.k8s.api.core.v1.SecurityContext",
16251629
"description": "SecurityContext defines the security options the container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/"

0 commit comments

Comments
 (0)