Kubectl pull new version of image without changes to manifest

Kubectl pull new version of image without changes to manifest

When using kubectl apply using an already applied and unchanged manifest file, nothing happens on the Kubernetes cluster. However, deployments can be configured so as to always pull a new version image upon restart. This is achieved using the, imagePullPolicy: Always parameter:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example
spec:
  replicas: 3
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - name: example
        image: 192.168.1.2:5000/kubernetes-example:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 12345
---
apiVersion: v1
kind: Service
metadata:
  labels:
    run: example
  name: example
spec:
  ports:
  - port: 12345
    nodePort: 30112
  selector:
    app: example
  type: LoadBalancer

Thus, a new image can be pulled when using the rollout restart command:

kubectl rollout restart deployment/${DEPLOYENT}