-
Notifications
You must be signed in to change notification settings - Fork 982
Open
kubernetes/kubernetes
#133444Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.sig/cliCategorizes an issue or PR as relevant to SIG CLI.Categorizes an issue or PR as relevant to SIG CLI.triage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.
Description
What would you like to be added?
Add container name info in kubectl logs xxx and kubectl exec xxx output, when there are multiple containers in a pod. Currently, there is no valid container name info in the output.
Current:
kubectl logs test-pod -c abc
error: container abc is not valid for pod test-pod
kubectl exec -it test-pod -c abc -- sh
Error from server (BadRequest): container abc is not valid for pod test-pod
Expected:
kubectl logs test-pod -c abc
error: container abc is not valid for pod test-pod out of: main-0, main-1, main-2, init-0 (init), init-1 (init)
kubectl exec -it test-pod -c abc -- sh
Error from server (BadRequest): container abc is not valid for pod test-pod out of: main-0, main-1, main-2, init-0 (init), init-1 (init)
Why is this needed?
When a pod with multiple containers, there is no valid container name info in the kubectl logs xxx and kubectl exec xxx output, need to add containers name info to choose easily.
Test yaml:
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
initContainers:
- name: init-0
image: busybox
command:
- echo
- msg from init-0
- name: init-1
image: busybox
command:
- echo
- msg from init-1
containers:
- name: main-0
image: busybox
command:
- /bin/sh
- -c
- sleep 3600
- name: main-1
image: busybox
command:
- /bin/sh
- -c
- sleep 3600
- name: main-2
image: busybox
command:
- /bin/sh
- -c
- sleep 3600
kubectl apply -f test-pod.yaml, then:
kubectl logs test-pod -c abckubectl exec -it test-pod -c abc -- sh
will reproduce this issue.
Metadata
Metadata
Assignees
Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.sig/cliCategorizes an issue or PR as relevant to SIG CLI.Categorizes an issue or PR as relevant to SIG CLI.triage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.
Type
Projects
Status
Needs Triage