Skip to content

Commit

Permalink
feat(helm-chart): support adding providers/plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
GMartinez-Sisti committed Jul 8, 2023
1 parent 710bba1 commit 2497204
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ The following options are supported. See [values.yaml](/charts/atlantis/values.y
| `ingress.path` | Path to use in the `Ingress`. Should be set to `/*` if using gce-ingress in Google Cloud. | `/` |
| `ingress.tls` | Kubernetes tls block. See [Kubernetes docs](https://kubernetes.io/docs/concepts/services-networking/ingress/#tls) for details. | `[]` |
| `initContainers` | Containers used to initialize context for Atlantis pods | `[]` |
| `initConfig` | Init container used to install plugins/providers shared with Atlantis pods | n/a |
| `lifecycle` | Configure pod container lifecycle hooks. See [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/) for details. | `{}` |
| `loadEnvFromConfigMaps` | Array of Kubernetes `ConfigMap`s to set all key-value pairs as environment variables. See `values.yaml` for example. | `[]` |
| `loadEnvFromSecrets` | Array of Kubernetes secrets to set all key-value pairs as environment variables. See `values.yaml` for example. | `[]` |
Expand Down
2 changes: 1 addition & 1 deletion charts/atlantis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
appVersion: v0.24.3
description: A Helm chart for Atlantis https://www.runatlantis.io
name: atlantis
version: 4.13.3
version: 4.14.0
keywords:
- terraform
home: https://www.runatlantis.io
Expand Down
38 changes: 38 additions & 0 deletions charts/atlantis/ci/ci-values-init-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
github:
user: foo
token: bar
secret: baz

service:
type: ClusterIP

ingress:
enabled: true
ingressClassName: nginx
host: atlantis.localdev.me
path: /
secondary_ingress:
enabled: true
ingressClassName: nginx
host: atlantis-webook.localdev.me
path: /events

resources:
requests:
memory: 64Mi
cpu: 10m
limits:
memory: 128Mi
cpu: 100m

initConfig:
enabled: true
script: |
#!/bin/sh
set -eoux pipefail
TG_VERSION="v0.47.0"
wget https://github.com/gruntwork-io/terragrunt/releases/download/${TG_VERSION}/terragrunt_linux_amd64 -O "terragrunt_linux_amd64_${TG_VERSION}"
mv "terragrunt_linux_amd64_${TG_VERSION}" "${INIT_SHARED_DIR}"/terragrunt
chmod 755 "${INIT_SHARED_DIR}"/terragrunt
terragrunt -v
11 changes: 11 additions & 0 deletions charts/atlantis/templates/configmap-init-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.initConfig.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}-init-config
labels:
{{- include "atlantis.labels" . | nindent 4 }}
data:
init-config.sh: |
{{- .Values.initConfig.script | nindent 4 }}
{{- end -}}
73 changes: 60 additions & 13 deletions charts/atlantis/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ spec:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap-config.yaml") . | sha256sum }}
checksum/repo-config: {{ include (print $.Template.BasePath "/configmap-repo-config.yaml") . | sha256sum }}
{{- if .Values.podTemplate.annotations }}
{{ toYaml .Values.podTemplate.annotations | indent 8 }}
{{- end }}
{{- if .Values.initConfig.enabled }}
checksum/init-config: {{ include (print $.Template.BasePath "/configmap-init-config.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.podTemplate.annotations }}
{{- toYaml .Values.podTemplate.annotations | nindent 8 }}
{{- end }}
spec:
{{- if .Values.hostAliases }}
hostAliases:
Expand Down Expand Up @@ -122,17 +125,50 @@ spec:
secretName: {{ .Values.customPem }}
{{- end }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{- toYaml .Values.extraVolumes | nindent 6 }}
{{- end }}
{{- if .Values.initConfig.enabled }}
- name: init-config
configMap:
name: {{ template "atlantis.fullname" . }}-init-config
items:
- key: init-config.sh
path: init-config.sh
mode: 0555
- name: init-shared-path
emptyDir:
sizeLimit: {{ .Values.initConfig.sizeLimit }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.initContainers }}
{{- if or .Values.initContainers .Values.initConfig.enabled }}
initContainers:
{{ toYaml .Values.initContainers | indent 8 }}
{{- with .Values.initContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.initConfig.enabled }}
- name: init-config
image: {{ .Values.initConfig.image }}
imagePullPolicy: {{ .Values.initConfig.pullPolicy }}
command:
- /init-config.sh
workingDir: {{ .Values.initConfig.workDir }}
env:
- name: PATH
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ .Values.initConfig.sharedDir }}
- name: INIT_SHARED_DIR
value: {{ .Values.initConfig.sharedDir }}
volumeMounts:
- name: init-config
mountPath: /init-config.sh
subPath: init-config.sh
- name: init-shared-path
mountPath: {{ .Values.initConfig.sharedDir }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
Expand Down Expand Up @@ -403,6 +439,12 @@ spec:
- name: AWS_CONFIG_FILE
value: {{ .Values.aws.directory }}/config
{{- end }}
{{- if .Values.initConfig.enabled }}
- name: PATH
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ .Values.initConfig.sharedDir }}
- name: INIT_SHARED_DIR
value: {{ .Values.initConfig.sharedDir }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
Expand Down Expand Up @@ -494,32 +536,37 @@ spec:
subPath: ca-certificates.crt
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 10 }}
{{- toYaml .Values.extraVolumeMounts | nindent 10 }}
{{- end }}
{{- if .Values.initConfig.enabled }}
- name: init-shared-path
mountPath: {{ .Values.initConfig.sharedDir }}
readOnly: true
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{ toYaml . | indent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.statefulSet.updateStrategy }}
updateStrategy:
{{ toYaml . | indent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.dataStorage }}
volumeClaimTemplates:
Expand Down
20 changes: 20 additions & 0 deletions charts/atlantis/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,26 @@ initContainers: []
# image: alpine:latest
# command: ['sh', '-c', 'echo The init container is running! && sleep 10']

# Install providers/plugins into a path shared with the Atlantis pod
initConfig:
enabled: false
image: alpine:latest
imagePullPolicy: IfNotPresent
# sharedDir is set as env var INIT_SHARED_DIR
sharedDir: /plugins
workDir: /tmp
sizeLimit: 100Mi
script: ""
# example that installs terragrunt
# script: |
# #!/bin/sh
# set -eoux pipefail
# TG_VERSION="v0.47.0"
# wget https://github.com/gruntwork-io/terragrunt/releases/download/${TG_VERSION}/terragrunt_linux_amd64 -O "terragrunt_linux_amd64_${TG_VERSION}"
# mv "terragrunt_linux_amd64_${TG_VERSION}" "${INIT_SHARED_DIR}"/terragrunt
# chmod 755 "${INIT_SHARED_DIR}"/terragrunt
# terragrunt -v

# hostAliases:
# - hostnames:
# - aaa.com
Expand Down

0 comments on commit 2497204

Please sign in to comment.