Richard Rublev
Richard Rublev

Reputation: 8172

error: unable to upgrade connection: container not found ("wordpress")

My goal is to list environment variables in my wordpress pod

kubectl get pods

wordpress-77f45f895-lxh5t            1/1     Running            993        92d
wordpress-mysql-7d4fc77fdc-x4bfm     1/1     Running            87         92d

Although the pod is running

kubectl exec wordpress-77f45f895-lxh5t env
error: unable to upgrade connection: container not found ("wordpress")

If I try the other one

kubectl exec wordpress-mysql-7d4fc77fdc-x4bfm env
Unable to connect to the server: net/http: TLS handshake timeout

My services

wordpress                NodePort       10.102.29.45     <none>        80:31262/TCP     94d
wordpress-mysql          ClusterIP      None             <none>        3306/TCP         94d

Why is container not found?

Upvotes: 31

Views: 77701

Answers (2)

b. schroeder
b. schroeder

Reputation: 31

The problem may be that the container hasn't been started yet. Use

kubectl describe pod <podname>

to see if you can view a message such as:

Normal  Created                 19s   kubelet                  Created container container

Normal  Started                 17s   kubelet                  Started container container

The container will have been created and you should no longer see that error message.

Upvotes: 3

Guru
Guru

Reputation: 1410

by looking at your output, I think your containers are crashing. first pod crashed 993 times and the second one crashed 87 times. You can check logs of the containers/events of the pods

kubectl logs {{podname}}: for pod logs

kubectl describe pod {{podname}} for detailed description.

As suggested by @mdaniel in comment check for ports also.

Are you able to access application on nodePort?

Upvotes: 42

Related Questions