Image tag in Replication Controller file

7/1/2018

I have an image pushed to Google Container Registry, named gcr.io/$(PROJECT_ID)/img-name:46d49ab.

In my replication controller I have:

apiVersion: v1
kind: ReplicationController
metadata:
  name: go-server-rc
spec:
  replicas: 3
  selector:
    name: go-server
    version: v8
  template:
    metadata:
      labels:
        name: go-server
        version: v8
    spec:
      containers:
      - name: go-server
        image: gcr.io/$(PROJECT_ID)/img-name:46d49ab
        ports:
        - containerPort: 5000

This works, but it doesn't when I remove the commit hash tag 46d49ab. I don't want to have to change the tag every single time I commit.

I have also set up a trigger on Google Container Builder to pull the master branch of my repository after every commit, and create an image gcr.io/$(PROJECT_ID)/img-name:$(COMMIT_HASH).

How can I edit my replication controller file to just get the most recent? What workflows do people use?

-- farah
google-container-builder
google-container-registry
google-kubernetes-engine
kubernetes

1 Answer

7/1/2018

It's possible to use the latest tag to ensure Kubernetes pulls the image each time it runs. Every time you create a new image tag it with latest and push it to the container registry. However, I would not recommend this.

You won't know which pods are running which version of your code. I do exactly as you mention in your question. I find it's better to update your deployment object each time your image updates. This will ensure the deployment is in the state you expect and troubleshooting will be clearer when looking at images.

-- Zach
Source: StackOverflow