Solucionado (ver solução)
Solucionado
(ver solução)
6
respostas

Error from server (NotFound)

Boa tarde Daniel, eu estou usando o Windows 10, a página do sistema de login estava funcionando até o momento que eu excluir o sistema-noticias-deployment.yaml. Eu não consigo observer o pod sisttema-noticias-statefulset ao executar o comando kubectl get pods, ele só aparece no kubectl get statefulset, outra dúvida porque você acrescentou o Zero no statefulset?

PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl exec -it sistema-noticas-statefulset-0 -- bash
Error from server (NotFound): pods "sistema-noticas-statefulset-0" not found
PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl exec -it sistema-noticas-statefulset -- bash
Error from server (NotFound): pods "sistema-noticas-statefulset" not found
PS C:\Users\Michael\Desktop\kubernetes-alura>

Pods

PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl get pods
NAME                                          READY   STATUS    RESTARTS   AGE
db-noticias-deployment-bd5476446-g57lb        1/1     Running   3          3d16h
portal-noticias-deployment-69b54d9646-d9w7t   1/1     Running   3          3d18h
portal-noticias-deployment-69b54d9646-m5jk2   1/1     Running   3          3d18h
portal-noticias-deployment-69b54d9646-x5bzt   1/1     Running   3          3d18h
PS C:\Users\Michael\Desktop\kubernetes-alura>

Services

Meus services estão funcionando: Kubernetes, svc-db-noticias, svc-portal-noticias e svc-sistema-noticias. 

StatefulSet

PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl get statefulset
NAME                           READY   AGE
sistema-noticias-statefulset   0/1     18m

PV


PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                STORAGECLASS   REASON   AGE
pvc-7de25590-f356-4da0-bbe1-3481bb57a811   1Gi        RWO            Delete           Bound    default/imaens-pvc   hostpath                35m
pvc-ee74a09f-ad64-4718-87ff-cd4162672f9d   1Gi        RWO            Delete           Bound    default/sessao-pvc   hostpath                35m
PS C:\Users\Jackson\Desktop\kubernetes-alura>

PVC

PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl get pvc
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
imaens-pvc   Bound    pvc-7de25590-f356-4da0-bbe1-3481bb57a811   1Gi        RWO            hostpath       19m
sessao-pvc   Bound    pvc-ee74a09f-ad64-4718-87ff-cd4162672f9d   1Gi        RWO            hostpath       19m
6 respostas

Oi Jackson, boa tarde. Tudo bem?

Qual a saída do seu comando kubectl describe sts sistema-noticias-statefulset?

Respondendo a segunda pergunta: não fui eu que adicionei. Esse 0 foi adicionado pelo próprio Kubernetes como um índice para indicar que esse é o primeiro Pod desse conjunto.


PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl describe sts sistema-noticias-statefulset
Name:               sistema-noticias-statefulset
Namespace:          default
CreationTimestamp:  Wed, 02 Sep 2020 15:53:36 -0300
Selector:           app=sistema-noticias
Labels:             <none>
Annotations:        Replicas:  1 desired | 0 total
Update Strategy:    RollingUpdate
  Partition:        0
Pods Status:        0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=sistema-noticias
  Containers:
   sistema-noticias-container:
    Image:      aluracursos/sistema-noticias:1
    Port:       80/TCP
    Host Port:  0/TCP
    Environment Variables from:
      sistema-configmap  ConfigMap  Optional: false
    Environment:         <none>
    Mounts:
      /tmp from sessao (rw)
      /var/www/html/uploads from images (rw)
  Volumes:
   imagens:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  imagens-pvc
    ReadOnly:   false
   sessao:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  sessao-pvc
    ReadOnly:   false
Volume Claims:  <none>
Events:
  Type     Reason        Age                From                    Message
  ----     ------        ----               ----                    -------
  Warning  FailedCreate  7s (x13 over 28s)  statefulset-controller  create Pod sistema-noticias-statefulset-0 in StatefulSet sistema-noticias-statefulset failed error: Pod "sistema-noticias-statefulset-0" is invalid: spec.containers[0].volumeMounts[0].name: Not found: "images"

Pelo que vi ficou faltando uma letra n na palavra imagens durante a declaração do seu statefulset.

Como está o seu arquivo de definição do statefulset e dos volumes de imagens?

Obrigado Daniel, faltava a letra n, você está certo, por esse motivo que o Kubernetes não estava criando o índice pod como você me explicou, porém agora o status esta peding

PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl get pods
NAME                                          READY   STATUS    RESTARTS   AGE
db-noticias-deployment-bd5476446-g57lb        1/1     Running   3          3d17h
portal-noticias-deployment-69b54d9646-d9w7t   1/1     Running   3          3d19h
portal-noticias-deployment-69b54d9646-m5jk2   1/1     Running   3          3d19h
portal-noticias-deployment-69b54d9646-x5bzt   1/1     Running   3          3d19h
sistema-noticias-statefulset-0                0/1     Pending   0          4m14s

Statefulset

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: sistema-noticias-statefulset
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app:  sistema-noticias
      name: sistema-noticias
    spec:
      containers:
        - name: sistema-noticias-container
          image:  aluracursos/sistema-noticias:1
          ports:
            - containerPort:  80
          envFrom:
            - configMapRef:
                name: sistema-configmap
          volumeMounts:
            - name:  imagens
              mountPath:  /var/www/html/uploads
            - name:  sessao
              mountPath:  /tmp
      volumes:
        - name: imagens
          persistentVolumeClaim:
            claimName:  imagens-pvc
        - name: sessao
          persistentVolumeClaim:
            claimName:  sessao-pvc
  selector:
    matchLabels:
      app: sistema-noticias
  serviceName:  svc-sistem-noticias

Imagens-pvc

apiVersion: v1
kind: PersistentVolumeClaim 
metadata:
  name: imaens-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

sessao-pv

apiVersion: v1
kind: PersistentVolumeClaim 
metadata:
  name: sessao-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

Describe pod

PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl describe pod sistema-noticias-statefulset
Name:           sistema-noticias-statefulset-0
Namespace:      default
Priority:       0
Node:           <none>
Labels:         app=sistema-noticias
                controller-revision-hash=sistema-noticias-statefulset-759c55dfd7
                statefulset.kubernetes.io/pod-name=sistema-noticias-statefulset-0
Annotations:    <none>
Status:         Pending
IP:
IPs:            <none>
Controlled By:  StatefulSet/sistema-noticias-statefulset
Containers:
  sistema-noticias-container:
    Image:      aluracursos/sistema-noticias:1
    Port:       80/TCP
    Host Port:  0/TCP
    Environment Variables from:
      sistema-configmap  ConfigMap  Optional: false
    Environment:         <none>
    Mounts:
      /tmp from sessao (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-dsgcg (ro)
      /var/www/html/uploads from imagens (rw)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  imagens:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  imagens-pvc
    ReadOnly:   false
  sessao:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  sessao-pvc
    ReadOnly:   false
  default-token-dsgcg:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-dsgcg
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age                   From               Message
  ----     ------            ----                  ----               -------
  Warning  FailedScheduling  29s (x11 over 9m28s)  default-scheduler  persistentvolumeclaim "imagens-pvc" not found
solução!

Eu já conseguir identificar um erro de digitação no arquivo imagens-pvc.yaml, eu corrigir o erro, deletei o arquivo e criei novamente e funcionou!! Obrigado Daniel pela ajuda!!!

Disponha Jackson. Bons estudos :)