I followed this tutorial: https://cloud.google.com/python/django/kubernetes-engine on how to deploy a Django application to GKE.
Unfortunately, I made a mistake while deploying the application, and one of my 3 pods in the cluster failed to come up. I believe I've fixed the failure, and now want to redeploy the application.
I can't figure out how to do that, or if I didn't fix the error and that's why it is still in error. I don't know how to diagnose if that's the case either...
After fixing my Dockerfile, I re-built and re-pushed to the Google Container Registry. It seemed to update, but I have no idea how to track this sort of deployment.
How does the traditional model of pushing a new version of an application and rolling back work in GKE?
Edit: The issue I'm specifically having is I updated settings.py
in my Django application but this is not being propagated to my cluster
You can delete pods to update app, but doing that just to update application is not good in production because it causes downtime while new pods are starting up.
In production you have to trigger rolling update of deployment which leaves old version in place until new version is ready and then makes a switch to new version. To start rolling update of deployment you can you this command:
kubectl -n NS patch deploy DEPLOYMENT_NAME -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"`date +'%s'`\"}}}}}"
I know it looks awful but so far with so many Kubernetes clusters and applications I did not yet found anything better.
The normal way would be to push a new image with a new tag and then edit the container image tag in the Deployment (https://github.com/GoogleCloudPlatform/python-docs-samples/blob/78d8a59d59c5eca788495666b43283534a50b7ee/container_engine/django_tutorial/polls.yaml#L42), and then re-apply the file (kubectl apply -f polls.yml
). However because their example is not using image tags (read: is implicitly using the tag latest
) then you just need to delete the existing pods and force all three to restart. A fast way to do this is kubectl delete pod -n app=polls
.