Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
kubernetes Deployment PodName setting
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      name: test
      labels:
        app: test
    spec:
      containers:
        - name: server
          image: test_ml_server:2.3
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: hostpath-vol-testserver
              mountPath: /app/test/api
#          env:
#            - name: POD_NAME
#              valueFrom:
#                fieldRef:
#                  fieldPath: template.metadata.name
        - name: testdb
          image: test_db:1.4
          ports:
            - name: testdb
              containerPort: 1433
          volumeMounts:
            - name: hostpath-vol-testdb
              mountPath: /var/opt/mssql/data
#          env:
#            - name: POD_NAME
#              valueFrom:
#                fieldRef:
#                  fieldPath: template.metadata.name
      volumes:
        - name: hostpath-vol-testserver
          hostPath:
            path: /usr/testhostpath/testserver
        - name: hostpath-vol-testdb
          hostPath:
            path: /usr/testhostpath/testdb

I want to set the name of the pod Because it communicates internally based on the name of the pod but when a pod is created, it cannot be used because the variable name is appended to the end. How can I set the pod name?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

It's better if you use, statefulset instead of deployment. Statefulset's pod name will be like <statefulsetName-0>,<statefulsetName-1>... And you will need a clusterIP service. with which you can bound your pods. see the doc for more details. Ref

apiVersion: v1
kind: Service
metadata:
  name: test-svc
  labels:
    app: test
spec:
  ports:
  - port: 8080
    name: web
  clusterIP: None
  selector:
    app: test
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: test-StatefulSet
  labels:
    app: test
spec:
  replicas: 1
  serviceName: test-svc
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      name: test
      labels:
        app: test
    spec:
      containers:
        - name: server
          image: test_ml_server:2.3
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: hostpath-vol-testserver
              mountPath: /app/test/api
        - name: testdb
          image: test_db:1.4
          ports:
            - name: testdb
              containerPort: 1433
          volumeMounts:
            - name: hostpath-vol-testdb
              mountPath: /var/opt/mssql/data
      volumes:
        - name: hostpath-vol-testserver
          hostPath:
            path: /usr/testhostpath/testserver
        - name: hostpath-vol-testdb
          hostPath:
            path: /usr/testhostpath/testdb

Here, The pod name will be like this test-StatefulSet-0.

over 4 years ago · Santiago Trujillo Relatório

0

if you are using the kind: Deployment it won't be possible ideally in this scenario you can use kind: Statefulset.

Instead of POD to POD communication, you can use the Kubernetes service for communication.

Still, statefulset manage the pod name in the sequence

statefulsetname - 0
statefulsetname - 1
statefulsetname - 2
over 4 years ago · Santiago Trujillo Relatório

0

You can't.

It is the property of the pods of a Deployment that they do not have an identity associated with them.

You could have a look at Statefulset instead of a Deployment if you want the pods to have a state.

From the docs:

Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling.

So, if you have a Statefulset object named myapp with two replicas, the pods will be named as myapp-0 and myapp-1.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda