When it comes to PODS with:
kind: Deploymentthe command has a following format:
kubectl exec -it [# POD_NAME #] -- shI am not sure how to accomplish the same, when I do have PODs defined using:
apiVersion: apps/v1
kind: StatefulSetIn Statefulset number of pods will be created defined in spec.replicas. The Pods' names take the form <statefulset name>-<ordinal index>. If your StatefulSet has two replicas, it creates two Pods, <statefulset-name>-0 and <statefulset-name>-1
You can exec
$ kubectl exec -it **<statefulset name>-<ordinal index>** -- shYou can see the created pod by your satefulset using
kubectl get pods -l <label in spec.template.metadata.labels>More details click
It should be same because both StatefulSet and Deployment creates pod at the end.
kubectl exec -it podname -n namespacename -- sh