Kamal secrets and github actions deployment #1034
Replies: 5 comments 1 reply
-
|
You can use GH Secrets as ENVs, which you can then refer to in .kamal/secrets. See https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions. |
Beta Was this translation helpful? Give feedback.
-
|
I am having the same issue, deploying an app using a CI/CD service fails unless the CI/CD executor has access to the project's secrets. The process breaks during the secrets upload step. Uploading my secrets to GH isn’t a viable solution for me, as :
I understand it is important to fail fast if some secret are missing, but maybe this check can happen on the host directly ? My best option is a dedicated secret manager, or a |
Beta Was this translation helpful? Give feedback.
-
|
Would it be possible to reopen this? Support for secrets provisioned out-of-band would be great. We can use IaC to provision secrets on the machine in a specific file, and then Kamal can be told to just use that file as its env. This means the CI infrastructure can deploy to that machine without explicitly having to manage those secrets itself. |
Beta Was this translation helpful? Give feedback.
-
|
I came up with a simple workaround. You deploy your secrets in env-file format out-of-band to the target machines using Ansible or whatever configuration management tool of choice, in some location like Then in your Kamal roles definition, you use a custom Docker option This will be merged with the clear env vars from Kamal's config (I believe the vars from the file will take precedence as it's the last env-related option in the Docker command line). This allows you to have no sensitive data in the Kamal config nor in the repo. |
Beta Was this translation helpful? Give feedback.
-
|
That looks like a good solution, just following up here with what I ended up doing to manage this. Since I have a fairly large app with a lot of secrets (30+) I didn't want to create/manage an individual secret in github for each one. So I ended up base64 encoding my entire secrets file and storing that as a single secret in github. Then using a step in github actions deploy to rewrite this file out to the target: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Now that I've upgraded to kamal 2, I see the secrets no longer have a separate lifecycle and they are pushed on every deployment. While this simplifies the whole process, it does remove some of the flexibility that kamal 1.x provided with the ability to manage secrets independently of the deployment. I would manage the uploading of secrets (env push) from my local machine, and then leave the grunt work of deployment to github actions. This meant that all my app secrets didn't have to be duplicated in github secrets as well, and github only needed the basics like the KAMAL_REGISTRY_PASSWORD and SSH_KEY to do a deploy.
Curious how others are managing their secrets with github actions and kamal, as maybe I'm missing some path that makes this easier with kamal 2. Kamal 2 has been much easier to get up and going, so maybe this is just a tradeoff of making the whole deployment process more simple and bulletproof.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions