How to update containers if the images are updated in image registry (gcr)?

Cluster information:

Kubernetes version:
Cloud being used: GKE
Installation method: NA
Host OS: NA
CNI and version: NA
CRI and version: NA

YAML

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "2"
  creationTimestamp: 2019-04-28T23:22:57Z
  generation: 9
  labels:
    app: graphql
    entity: esque
  name: graphql
  namespace: esque-entity
  resourceVersion: "16032106"
  selfLink: /apis/extensions/v1beta1/namespaces/esque-entity/deployments/graphql
  uid: <uid>
spec:
  progressDeadlineSeconds: 2147483647
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: graphql
      entity: esque
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: graphql
        entity: esque
    spec:
      containers:
      - env:
        - name: MONGODB_URL
          valueFrom:
            configMapKeyRef:
              key: MONGODB_URL
              name: graphql-config
        - name: entity_db
          valueFrom:
            configMapKeyRef:
              key: entity_db
              name: graphql-config
        - name: mxr_db
          valueFrom:
            configMapKeyRef:
              key: mxr_db
              name: graphql-config
        image: gcr.io/k8s-project/mxr-graphql@sha256:62ced28a6f29cfcdd66c44c747c9e8fe1f1c72ca104a043fd9b80f10521d2ae5
        imagePullPolicy: IfNotPresent
        name: mxr-graphql-sha256
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: 2019-04-28T23:22:59Z
    lastUpdateTime: 2019-04-28T23:22:59Z
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  observedGeneration: 9
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1

Assuming your image is tagged right in GCR and YAML, you can simple delete the pod. Then, k8s will revive the pod with correct image.

@icanhasr00t and how can that be done automatically. I don’t want to manually do it.
I have a image which is running in 50 different workload with different env variables. Therefore, it would be easy if this can be done just when the master branch in git is updated or when the new image becomes available in gcr

Hook up the (killing / patching) action/step into your CI/CD pipeline / deployment script
/ whatever you are using to push out the new image.

I am using google cloud build trigger for that, it watches master branch of my git repos. Not using any CI/CD tool as such at this point. I didn’t wanted to do all that but then I guess that’s the only way left :frowning:
Probably I will try jenkins or spinnaker…