Several questions in this post. I’m using Azure Kubernetes service, and I have images in ACR.
When I use kubectl run my-pod --image my-acr/my-image, does it use the image with latest tag, eg, my-acr/my-image:latest.
When I push the image built locally, I do things like
- Build
my-image:v1 - Tag
my-image:v1withmy-acr/my-image:latest - Now, should I delete
my-acr/my-image:latestfrom ACR first, then push it. Or I can directly do the push?
>Solution :
- Using the kubectl run command:
–When you use the kubectl run command with the –image flag, it will use the image specified, including the tag. If you don’t specify a tag , it will default to using the latest tag.
–For example, if you run kubectl run my-pod –image my-acr/my-image, it will use the image my-acr/my-image:latest. If you want to use a specific version/tag , you should specify it explicitly. - Updating the image in ACR:
–To update the image in ACR , you don’t necessarily need to delete the existing latest tag before pushing the updated image.
–After building your image locally and tagging it with a specific version/tag (e.g., my-image:v1), you can directly push it to ACR with the desired tag (e.g. , my-acr/my-image:v1).
–The latest tag in ACR will still point to the previous image unless you explicitly update it. You can choose to update the latest tag to point to the newly pushed image by using the az acr repository update command or by re-tagging the new image as my-acr/my-image:latest and pushing it again.
Here’s an example workflow to update the image in ACR:
- Build your image locally: docker build -t my-image:v1 .
- Tag the image with the ACR repository name and version: docker tag my-image:v1 my-acr/my-image:v1
- Push the image to ACR: docker push my-acr/my-image:v1
- If you want the latest tag to point to the newly pushed image , you can update it using the az acr repository update command or by re-tagging the image as my-acr/my-image:latest and pushing it again.