Finding Variables

Finding VariablesNamespaceDeployment NameRepository NameIn-Pod Container NameDocker Tag


Namespace

Unless you know otherwise, this is probably going to be staging.

 

Deployment Name

To get a list of the current deployments in this namespace, run:

$ kubectl get deployments -n NAMESPACE
NAME READY UP-TO-DATE AVAILABLE AGE
apigateway 1/1 1 1 32d
converter 2/2 2 2 34d
ui 1/1 1 1 32d
graphql 1/1 1 1 34d

You should be able to pick out the correct name from this list; most of them are pretty self explanatory.

 

Repository Name

You need to push to a specific ECR repository; there is one for each codebase. This repository name will correlate to the Docker image name. You can get this by going to the AWS ECR dashboard and looking through the options. Alternatively, you can list them in the command line.

On Mac/Linux:

$ aws ecr describe-repositories | grep repositoryName
"repositoryName": "apigateway",
"repositoryName": "converter",
"repositoryName": "UI",
"repositoryName": "graphql",
...

On Windows:

$ aws ecr describe-repositories | findstr repositoryName

Once again, it should be pretty easy to pick out the correct name. Do note that the repository name and the Deployment name will not always be the same.

 

In-Pod Container Name

This is the name given to the container within the Kubernetes Pod specification. To find it, you need to know the namespace and deployment_name.

Then run:

$ kubectl get deploy -n NAMESPACE DEPLOYMENT_NAME -o jsonpath="{.spec.template.spec.containers[*].name}"
CONTAINER_NAME

 

Docker Tag

Your image will need a new, unique tag for Kubernetes to identify it by. We're implementing this using the classic method of major/minor versions, so your new image tag should just increment the current one.

Since you already know the NAMESPACE and DEPLOYMENT_NAME, you can see the current image name and tag:

$ kubectl get deploy -n NAMESPACE DEPLOYMENT_NAME -o jsonpath="{.spec.template.spec.containers[*].image}"
012345678910.dkr.ecr.ap-southeast-3.amazonaws.com/REPOSITORY_NAME:v0.2

The part after the colon (in this case, v0.2) is the current image tag. If you're deploying a small change, increment the minor version (v0.3). For a new feature release or other big change, increment the major version (v1.0).

It's important that the tag be unique within the repository.1 If you want to list all previous image tags to verify, you can do this in command line:

$ aws ecr list-images --repository-name REPOSITORY_NAME | grep imageTag
"imageTag": "v0.2"
"imageTag": "v0.1"
"imageTag": "v0.0"

For Windows, replace grep with findstr.

Never use latest as a tag. It will cause issues. This is important. AWS tries to get you to use latest. Do not listen.

 

 



1 Kubernetes checks for locally-stored images before turning to the ECR. So if the tags already been used, Kubernetes might end up using the old version instead of the new version.