Custom image for atlantis was needed:
- to add missing components
- terragrunt
- Google Cloud SDK
- taking care of the SSH key for the user atlantis uses to clone GitHub repos (the key is NOT embedded into the image)
- GCP
- Atlantis is running in a GKE cluster
- Atlantis deployed using the stable Atlantis Helm chart
- The Helm chart is deployed by Terraform code (can be done differently)
-
The following values are passed to the atlantis Helm chart (through a values file)
environment: GOOGLE_APPLICATION_CREDENTIALS: "/etc/credentials/service-account.json" GITHUB_USER_SSH_KEY: "/etc/github-user-ssh-key/service-account.json"
service-account.json
is an unfortunate name for the file that contains a private SSH key, but we are "creatively using" the functionality that was originally designed for passing GCP service account credentials toatlantis
andservice-account.json
is expected by atlantis Kubernetes manifests created by the chart. -
The values bwlow are passed to the atlantis Helm chart as parameters on the command line. In our case, this has been done with Terraform, but it doesn't have to be.
set { # used for mounting credential files (when using google provider). name = "serviceAccountSecrets.credentials" value = "${base64encode(file(local.svc_acct_key_file_name))}" } set { # used for mounting github user ssh key # a bit of a hack because we are hijacking the functionality for # handling service account keys name = "serviceAccountSecrets.github-user-ssh-key" value = "${base64encode(file(local.github_user_ssh_key_file_name))}"
}
-
We are placing a custom
/usr/local/bin/docker-entrypoint.sh
on the custom Atlantis image. It copies the GitHub SSH key to the atlantis home directory and then calls the original entrypoint.
Thanks for the idea. helped me with another issue i had with extending the base atlantis functionality 😃
the shebang in docker-entrypoint.sh and create_github_user_ssh_key.sh changed in the more recent upstream images to
#!/usr/bin/dumb-init /bin/sh
(source: upstream) if somebody else stumbles upon this in the future