diff --git a/charts/atlantis/README.md b/charts/atlantis/README.md index 045e355a..33f5610f 100644 --- a/charts/atlantis/README.md +++ b/charts/atlantis/README.md @@ -88,6 +88,7 @@ extraManifests: | command | list | `[]` | Override the command field of the Atlantis container. | | commonLabels | object | `{}` | Common Labels for all resources created by this chart. | | config | string | `""` | Override atlantis main configuration by config map, ref: https://www.runatlantis.io/docs/using-slack-hooks.html#configuring-atlantis. Check values.yaml for examples. | +| containerPort | string | `nil` | When set, ignores the port specified by the Service's targetPort attribute. This is relevant when another container is injected into the same Pod. | | containerSecurityContext | object | `{}` | Check values.yaml for examples. | | customPem | string | `""` | Allows to override the /etc/ssl/certs/ca-certificates.cer with your custom one. You have to create a secret with the specified name. | | dataStorage | string | `""` | DEPRECATED - Disk space available to check out repositories. Example: 5Gi. | @@ -100,7 +101,7 @@ extraManifests: | dnsPolicy | string | `"ClusterFirst"` | Optionally specify dnsPolicy parameter to specify a DNS policy for a pod Check https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy | | enableDiffMarkdownFormat | bool | `false` | Use Diff Markdown Format for color coding diffs. | | enableKubernetesBackend | bool | `false` | Optionally deploy rbac to allow for the serviceAccount to manage terraform state via the kubernetes backend. | -| environment | object | `{}` | Environtment values to add to the Atlantis pod. Check values.yaml for examples. | +| environment | object | `{}` | Environment values to add to the Atlantis pod. Check values.yaml for examples. | | environmentRaw | list | `[]` | Optionally specify additional environment variables in raw yaml format. Useful to specify variables refering to k8s objects. Check values.yaml for examples. | | environmentSecrets | list | `[]` | Optionally specify additional environment variables to be populated from Kubernetes secrets. Useful for passing in TF_VAR_foo or other secret environment variables from Kubernetes secrets. Check values.yaml for examples. | | extraAnnotations | object | `{}` | | diff --git a/charts/atlantis/templates/_helpers.tpl b/charts/atlantis/templates/_helpers.tpl index 1369ab3a..af1d295a 100644 --- a/charts/atlantis/templates/_helpers.tpl +++ b/charts/atlantis/templates/_helpers.tpl @@ -141,3 +141,10 @@ Define PATH environment variable that will be used system-wide. {{- end -}} {{- printf "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" }} {{- end -}} + +{{/* +Sets the container port based on the defined values. +*/}} +{{- define "atlantis.containerPort" -}} +{{- default .Values.service.targetPort .Values.containerPort }} +{{- end -}} diff --git a/charts/atlantis/templates/statefulset.yaml b/charts/atlantis/templates/statefulset.yaml index 30fe0601..35575ee0 100644 --- a/charts/atlantis/templates/statefulset.yaml +++ b/charts/atlantis/templates/statefulset.yaml @@ -238,7 +238,7 @@ spec: {{- end }} ports: - name: atlantis - containerPort: {{ .Values.service.targetPort }} + containerPort: {{ include "atlantis.containerPort" . }} {{- with .Values.lifecycle }} lifecycle: {{ toYaml . | nindent 12 }} {{- end }} @@ -331,7 +331,7 @@ spec: value: {{ .Values.orgWhitelist | quote }} {{- end }} - name: ATLANTIS_PORT - value: {{ .Values.service.targetPort | quote }} + value: {{ include "atlantis.containerPort" . | quote }} {{- if .Values.repoConfig }} - name: ATLANTIS_REPO_CONFIG value: /etc/atlantis/repos.yaml @@ -528,7 +528,7 @@ spec: livenessProbe: httpGet: path: /healthz - port: {{ .Values.service.targetPort }} + port: {{ include "atlantis.containerPort" . }} scheme: {{ .Values.livenessProbe.scheme }} initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.livenessProbe.periodSeconds }} @@ -540,7 +540,7 @@ spec: readinessProbe: httpGet: path: /healthz - port: {{ .Values.service.targetPort }} + port: {{ include "atlantis.containerPort" . }} scheme: {{ .Values.readinessProbe.scheme }} initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.readinessProbe.periodSeconds }} diff --git a/charts/atlantis/values.schema.json b/charts/atlantis/values.schema.json index ed9b3f5a..d1f2eafa 100644 --- a/charts/atlantis/values.schema.json +++ b/charts/atlantis/values.schema.json @@ -267,6 +267,15 @@ } } }, + "containerPort": { + "description": "Port for the Atlantis container, when necessary specify a value different from the Service's targetPort", + "type": [ + "string", + "integer", + "null" + ], + "default": null + }, "image": { "type": "object", "description": "Atlantis image configuration.", @@ -336,10 +345,10 @@ "type": "string", "description": "Default Atlantis distribution to be used by atlantis server. Either opentofu or terraform", "default": "terraform", - "enum": [ - "terraform", - "opentofu" - ] + "enum": [ + "terraform", + "opentofu" + ] }, "defaultTFVersion": { "type": "string", diff --git a/charts/atlantis/values.yaml b/charts/atlantis/values.yaml index 3869fc19..b539359d 100644 --- a/charts/atlantis/values.yaml +++ b/charts/atlantis/values.yaml @@ -172,6 +172,10 @@ serviceAccountSecrets: {} # Default values for atlantis (override as needed). ## -------------------------- ## +# -- When set, ignores the port specified by the Service's targetPort attribute. +# This is relevant when another container is injected into the same Pod. +containerPort: + image: repository: ghcr.io/runatlantis/atlantis # -- If not set appVersion field from Chart.yaml is used @@ -497,7 +501,7 @@ tlsSecretName: "" # -- Additional path (`:` separated) that will be appended to the system `PATH` environment variable. extraPath: "" -# -- Environtment values to add to the Atlantis pod. +# -- Environment values to add to the Atlantis pod. # Check values.yaml for examples. environment: {} # environment: