Welcome to the Linux Foundation Forum!

Error in the Lab 10.1: "error: unable to upgrade connection: container not found ("ngix")"

When I did the step 11, I found the pod "thirdpage-77c4bc9757-bwbpx" not running. And then I finished step 12 and 13. When I tried to do step 14 , I got an error "error: unable to upgrade connection: container not found ("ngix")". Could you please help me to figure out this?

Thanks,

Wei

student@master:~$ kubectl create deployment thirdpage --image=ngix
deployment.apps/thirdpage created
student@master:~$ kubectl get po
NAME READY STATUS RESTARTS AGE
secondapp-5cf87c9f48-cxtj2 1/1 Running 0 20h
thirdpage-77c4bc9757-bwbpx 0/1 ImagePullBackOff 0 14s

student@master:~$ kubectl expose deployment thirdpage --type=NodePort --port=80
service/thirdpage exposed
student@master:~$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 443/TCP 5d4h
secondapp NodePort 10.98.205.187 80:32497/TCP 20h
thirdpage NodePort 10.102.251.101 80:32023/TCP 4s

student@master:~$ kubectl exec -it thirdpage-77c4bc9757-bwbpx -- /bin/bash
error: unable to upgrade connection: container not found ("ngix")

Best Answer

Answers

  • zhangwe
    zhangwe Posts: 45

    Yes, my image name is not right. Thank you very much for your help.

  • The error message "error: unable to upgrade connection: container not found ("ngix")" that you are encountering in Kubernetes typically indicates that there's an issue with the container name specified in your command. It seems like there might be a typo in the container name.

    In Kubernetes, when you execute a command like kubectl exec to enter a container, you need to specify the exact name of the container if the pod has multiple containers. The error suggests that Kubernetes cannot find a container named "ngix" in the specified pod. This name seems like it's intended to be "nginx", the name of a popular web server.

    Here’s how you can troubleshoot and potentially resolve this issue:

    1. Check the Pod's Container Names
      First, verify the name of the container inside the pod. You can list all containers in a pod using the following command:

    kubectl get pod thirdpage-77c4bc9757-bwbpx -o jsonpath='{.spec.containers[*].name}'

    1. Correct the Container Name
      Use the correct container name in your kubectl exec command. If the container is indeed named "nginx", the command should look something like this:

    kubectl exec -it thirdpage-77c4bc9757-bwbpx -c nginx -- /bin/bash

    1. Check the Pod Status

    Since you mentioned the pod "thirdpage-77c4bc9757-bwbpx" was not running, ensure that the pod is in a running state. You can check the status of the pod with:

    kubectl get pod thirdpage-77c4bc9757-bwbpx

Categories

Upcoming Training