error: unable to find container in kubectl set image

9/19/2019

I am trying to push an update to my codebase for my docker image. I have the docker image on kubernetes on GCP and I followed the way it was mentioned in the document here. I even pushed the image with :v2 tag to the container registry and that image is visible in the console as well. But now when I am trying to run:

kubectl set image deployment/clustername myImageName=gcr.io/${PROJECT_ID}/myImageName:v2

it gives me the following error:

error: unable to find container myImageName

I know that the image is there because I build it with

docker build -t gcr.io/${PROJECT_ID}/myImageName:v2 .

I have also fixed the issue of: Error from server (NotFound): deployments.extensions I am stuck at this very moment. Can anyone throw some light on it?

-- Siddharth Choudhary
docker
google-cloud-platform
kubectl
kubernetes

4 Answers

9/20/2019

Your command is wrong you have to remove the myImageName before the image url and pass the command

kubectl set image <deployment name> gcr.io/${PROJECT_ID}/myImageName:v2
-- Harsh Manvar
Source: StackOverflow

3/21/2020

The documentation on the GCP hello-app tutorial has the syntax wrong. It should be:

kubectl set image deployment/clustername 
clustername=gcr.io/${PROJECT_ID}/myImageName:v2

rather than:

kubectl set image deployment/clustername 
myImageName=gcr.io/${PROJECT_ID}/myImageName:v2
-- user13100595
Source: StackOverflow

9/19/2019

The error message specifies that your deployment doesn't have a container named myImageName.

The syntax for kubectl set image is:

kubectl set image deployment-name container-name=image-name

container-name must be the name of a container you specified inside your deployment under spec.template.spec.containers.name.

-- Alassane Ndiaye
Source: StackOverflow

5/9/2020

check 'myImageName' container name is matching in the pod description.

Try command : kubectl describe pods

In pod description check the following under 'Containers' section: In the below example 'avroconsumerclient' is the name of the container.

Containers:
  avroconsumerclient:
    Container ID:   docker://ab5890be34dfk5678dfdf5670ac19583d8859427695a258d4fdfd
    Image:          ************/democlient:v2
    Image ID:       docker-pullable://********/democlient@sha256:71e97df533915d62c433c2c04168bb7b1dd545c7ef423169a1452ac5abd4302e
    Port:           <none>
    Host Port:      <none>
    State:          Running
-- svps
Source: StackOverflow