Deploy an UpdateRequirementsPush New Image to ECRUpdate the Deployment Image ReferenceVerify the Update
So you've updated your code recently, and you need to rollout the change.
Each of your codebases is associated with a Deployment, which will spin up several instances based on whatever Docker Image you provide it. In order to rollout an update, you need to update the Docker Image in your Deployment.
There are three stages to this:
To do this, you'll need to know some pieces of information:
NAMESPACE
: The Kubernetes namespace the Deployment is inDEPLOYMENT_NAME
: The name of the Deployment you're updatingREPOSITORY_NAME
: The name of the ECR repository associated with your Deployment TAG
: The new Docker tag for the new imageCONTAINER_NAME
: The name given to the container within the Kubernetes Pod specificationIf you don't know these, instructions on finding them are here, depending. Remember to sub them in wherever you see orange text in the code blocks.
For the NAMESPACE
, you can either switch to the correct namespace at the beginning, or use -n NAMESPACE
throughout for all kubectl
commands. See the appropriate section for details.
First, make sure you're logged in to the ECR:
Go to your repository root folder and make sure you've built your docker image locally:
Tag your local docker image with the ECR repository location, name and tag. Make sure the tag is unique :
Push the image to the ECR:
This is where it all comes together. Run this command to update the image:
This will perform a rolling update. This means that it will spin up new Pods with the new image and ensure those are running properly before terminating the current pods, in order to ensure continuous availability.
The update is now being pushed out. You can check on its progression in a couple of ways.
To watch the progress:
If there seems to be an issue, you can see what's happening with the pods in more detail:
Name | Ready | Status | Restarts | Age |
hello-node-5776cf4bcf-4sjrt | 1/1 | Running | 0 | 3s |
hello-node-7694cbfdd4-zfrms | 1/1 | Terminating | 0 | 4d |
This will tell you the status of all your Pods. Some may take awhile to be scheduled (Pending
status) if a new node needs to be deployed. If any of the pods have failed or seem stuck, note down the POD_NAME
and check for the reasons by looking at the output of:
Type | Reason | Age | From | Message |
Normal | Scheduled | 2m | default-scheduler | Successfully assigned default/hello-node-5776cf4bcf-4sjrt to ip-172-31-41-3.ap-southeast-1.compute.internal |
The Deployment has successfully rolled out when you get: