Python Django project handling .env and SECRET_KEY on GitHub Actions + Kubernetes Deployment

10/26/2020

We have a web service written in Django that is stored on GitHub. We used GitHub Actions to create a workflow that builds a Docker image and pushes it to Azure Container Registry. Then the workflow triggers a Terraform file that in turn provisions a Kubernetes Cluster and using a deployment.yaml it deploys the web service app on Kubernetes cluster.

This whole process works fine but when pods are up they get terminated CrashLoopBackOff

The terminated pod's log can be found in the ix output below http://ix.io/2BCx

I know the log clearly shows that its missing some .env file and environment variables such as SECRET_KEY that seems to require these BEFORE the image build, we are unaware where and at what stage to provide these information to the image? Whether in the GH Actions workflow itself, in Dockerfile, a bash script to inject somewhere.

Any guidance is highly appreciated. Thanks.

-- Mert Alnuaimi
deployment
docker
github-actions
infrastructure
kubernetes

0 Answers