Alex Tbk
Alex Tbk

Reputation: 2104

Pod naming in google cluster

I created a deployment like this:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: scs-db-sink
spec:
  selector:
    matchLabels:
      app: scs-db-sink
  replicas: 1 
  template: 
    metadata:
      labels:
        app: scs-db-sink
    spec:
      nodeSelector:
        cloud.google.com/gke-nodepool: service-pool
      containers:
      - name: scs-db-sink
        image: 'IMAGE_NAME'
        imagePullPolicy: Always
        ports:
        - containerPort: 1068

kubectl get pods shows me that the pod is running:

scs-db-sink-74c4b6cd6b-tchm9   1/1     Running   0          16m

Question: How can I setup the pod name to be scs-db-sink-0 and increase to scs-db-sink-1 when I scale up?

Thanks

Upvotes: 0

Views: 62

Answers (1)

Emruz Hossain
Emruz Hossain

Reputation: 5528

Deployments pods are named as <replicaset-name>-<random-suffix> where replicaset name is <deployment-name>-<random-suffix>. Here, replicaset is created automatically by deployment. So, you can't achieve your expected name with deployment.

However, you can use Statefulset in this case. Statefulset's pods are named as you specified. Check about Statefulset here.

Upvotes: 2

Related Questions