使用三个Pod运行部署。

NAME                        READY   STATUS    RESTARTS   AGE
my-api-XXX                  3/3     Running   0          4h

Containers:
  zipkin:
    Container ID:   docker://XXX
    Image:          openzipkin/zipkin:2.11
    Image ID:       docker-pullable://openzipkin/zipkin@sha256:XXX
    Port:           8611/TCP
    Host Port:      8611/TCP
    State:          Running
      Started:      Mon, 17 Feb 2020 12:13:03 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      XXX
  my-api:
    Container ID:   docker://XXX
    Image:          XXX
    Image ID:       XXX
    Ports:          5000/TCP, 6000/TCP
    Host Ports:     5000/TCP, 6000/TCP
    State:          Running
      Started:      Mon, 17 Feb 2020 12:13:04 +0800
    Ready:          True
    Restart Count:  0
    Mounts:
      XXX
  my-metrics:
    Container ID:   docker://XXX
    Image:          XXX
    Image ID:       XXX
    Ports:          5001/TCP, 6001/TCP
    Host Ports:     5001/TCP, 6001/TCP
    State:          Running
      Started:      Mon, 17 Feb 2020 12:13:04 +0800
    Ready:          True
    Restart Count:  0
    Environment:
      XXX
    Mounts:
      XXX

我可以连接的唯一一个pod容器是zipkin和kubectl exec -it my-api-XXX -- /bin/bash

如果我想使用kubectl exec -it my-api-XXX -c <my-api container ID> -- /bin/bash访问my-api容器。

它报告一个错误,表明该容器不在该容器中。

最佳答案



这里只需要容器名称。在您的情况下,它将是:



您可以执行Zipkin,因为exec将zipkin作为默认容器。

08-18 11:38
查看更多