Skip to content

Commit

Permalink
feat(atlantis): add containerPort custom
Browse files Browse the repository at this point in the history
Signed-off-by: Julliano Goncalves <[email protected]>
  • Loading branch information
jullianow committed Dec 20, 2024
1 parent 531b38f commit 2e4561c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
3 changes: 2 additions & 1 deletion charts/atlantis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand All @@ -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 | `{}` | |
Expand Down
7 changes: 7 additions & 0 deletions charts/atlantis/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
8 changes: 4 additions & 4 deletions charts/atlantis/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
17 changes: 13 additions & 4 deletions charts/atlantis/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion charts/atlantis/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2e4561c

Please sign in to comment.