1
resposta

Erro porta

Olá pessoal! Estou com esse problema aqui ao inserir a porta ao Pod.

pod-02.yaml

apiVersion: v1
kind: Pod
metadata:
  name: pod-2
  labels:
    app: segundo-pod
spec:
  containers:
    - name: container-pod-2
      image: nginx:latest
      ports:
        - containerPort: 80

Segue o erro:

The Pod "pod-2" is invalid: spec: Forbidden: pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)
  core.PodSpec{
      Volumes:        []core.Volume{{Name: "default-token-5hcr7", VolumeSource: core.VolumeSource{Secret: &core.SecretVolumeSource{SecretName: "default-token-5hcr7", DefaultMode: &420}}}},
      InitContainers: nil,
      Containers: []core.Container{
          {
-             Name:         "container-pod-2",
+             Name:         "pod-2",
              Image:        "nginx:latest",
              Command:      nil,
              Args:         nil,
              WorkingDir:   "",
-             Ports:        []core.ContainerPort{{ContainerPort: 80, Protocol: "TCP"}},
+             Ports:        nil,
              EnvFrom:      nil,
              Env:          nil,
              Resources:    core.ResourceRequirements{},
-             VolumeMounts: nil,
+             VolumeMounts: []core.VolumeMount{
+                 {
+                     Name:      "default-token-5hcr7",
+                     ReadOnly:  true,
+                     MountPath: "/var/run/secrets/kubernetes.io/serviceaccount",
+                 },
+             },
              VolumeDevices: nil,
              LivenessProbe: nil,
              ... // 10 identical fields
          },
      },
      EphemeralContainers: nil,
      RestartPolicy:       "Always",
      ... // 25 identical fields
  }
1 resposta

Olá Filipe, tudo bem?

Nesse caso, ele está indicando que essa mudança não pode ser feita com o Pod já criado.

Você deve excluí-lo e recriá-lo utilizando os comandos kubectl delete pod <nome_do_pod> e kubectl apply -f <arquivo_yaml>.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software