0

When it comes to PODS with:

kind: Deployment

the command has a following format:

kubectl exec -it [# POD_NAME #] -- sh

I am not sure how to accomplish the same, when I do have PODs defined using:

apiVersion: apps/v1
kind: StatefulSet
Artur Drożdżyk
  • 605
  • 1
  • 6
  • 18

2 Answers2

4

In 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>** -- sh

You can see the created pod by your satefulset using

kubectl get pods -l <label in spec.template.metadata.labels>

More details click

hoque
  • 5,735
  • 1
  • 19
  • 29
1

It should be same because both StatefulSet and Deployment creates pod at the end.

kubectl exec -it podname -n namespacename -- sh
Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107