Using kubectl set to update the container image

Use the kubectl set command allows us to overwrite the spec.template.spec.containers[].image property that is similar to using the kubectl run command to specify the image file. The following example specifies my-nginx deployment to set the container my-nginx to change the image to nginx version 1.12.0:

$ kubectl set image deployment my-nginx my-nginx=nginx:1.12.0 --recorddeployment.apps "my-nginx" image updated$ kubectl describe deploy my-nginxName:                   my-nginx……Conditions:  Type           Status  Reason  ----           ------  ------  Available      True    MinimumReplicasAvailable  Progressing    True    ReplicaSetUpdatedOldReplicaSets:  my-nginx-54bb7bbcf9 (3/3 replicas created)NewReplicaSet:   my-nginx-77769b7666 (1/1 replicas created) ...

Get Kubernetes Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.