pod has unbound immediate PersistentVolumeClaims (repeated 3 times)
Asked Answered
K

3

16

What is wrong with below.

# config for es data node
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: infra
  name: elasticsearch-data-config
  labels:
    app: elasticsearch
    role: data
data:
  elasticsearch.yml: |-
    cluster.name: ${CLUSTER_NAME}
    node.name: ${NODE_NAME}
    discovery.seed_hosts: ${NODE_LIST}
    cluster.initial_master_nodes: ${MASTER_NODES}

    network.host: 0.0.0.0

    node:
      master: false
      data: true
      ingest: false

    xpack.security.enabled: true
    xpack.monitoring.collection.enabled: true
---
# service for es data node
apiVersion: v1
kind: Service
metadata:
  namespace: infra
  name: elasticsearch-data
  labels:
    app: elasticsearch
    role: data
spec:
  ports:
  - port: 9300
    name: transport
  selector:
    app: elasticsearch
    role: data
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  namespace: infra
  name: elasticsearch-data
  labels:
    app: elasticsearch
    role: data
spec:
  serviceName: "elasticsearch-data"
  replicas: 1
  template:
    metadata:
      labels:
        app: elasticsearch-data
        role: data
    spec:
      containers:
      - name: elasticsearch-data
        image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
        env:
        - name: CLUSTER_NAME
          value: elasticsearch
        - name: NODE_NAME
          value: elasticsearch-data
        - name: NODE_LIST
          value: elasticsearch-master,elasticsearch-data,elasticsearch-client
        - name: MASTER_NODES
          value: elasticsearch-master
        - name: "ES_JAVA_OPTS"
          value: "-Xms300m -Xmx300m"
        ports:
        - containerPort: 9300
          name: transport
        volumeMounts:
        - name: config
          mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
          readOnly: true
          subPath: elasticsearch.yml
        - name: elasticsearch-data-persistent-storage
          mountPath: /data/db
      volumes:
      - name: config
        configMap:
          name: elasticsearch-data-config
      initContainers:
      - name: increase-vm-max-map
        image: busybox
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
  volumeClaimTemplates:
  - metadata:
      name: elasticsearch-data-persistent-storage
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Gi

statefull output:

Name:           elasticsearch-data-0
Namespace:      infra
Priority:       0
Node:           <none>
Labels:         app=elasticsearch-data
                controller-revision-hash=elasticsearch-data-76bdf989b6
                role=data
                statefulset.kubernetes.io/pod-name=elasticsearch-data-0
Annotations:    <none>
Status:         Pending
IP:             
IPs:            <none>
Controlled By:  StatefulSet/elasticsearch-data
Init Containers:
  increase-vm-max-map:
    Image:      busybox
    Port:       <none>
    Host Port:  <none>
    Command:
      sysctl
      -w
      vm.max_map_count=262144
    Environment:  <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-9nhmg (ro)
Containers:
  elasticsearch-data:
    Image:      docker.elastic.co/elasticsearch/elasticsearch:7.3.0
    Port:       9300/TCP
    Host Port:  0/TCP
    Environment:
      CLUSTER_NAME:  elasticsearch
      NODE_NAME:     elasticsearch-data
      NODE_LIST:     elasticsearch-master,elasticsearch-data,elasticsearch-client
      MASTER_NODES:  elasticsearch-master
      ES_JAVA_OPTS:  -Xms300m -Xmx300m
    Mounts:
      /data/db from elasticsearch-data-persistent-storage (rw)
      /usr/share/elasticsearch/config/elasticsearch.yml from config (ro,path="elasticsearch.yml")
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-9nhmg (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  elasticsearch-data-persistent-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  elasticsearch-data-persistent-storage-elasticsearch-data-0
    ReadOnly:   false
  config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      elasticsearch-data-config
    Optional:  false
  default-token-9nhmg:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-9nhmg
    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  46s (x4 over 3m31s)  default-scheduler  pod has unbound immediate PersistentVolumeClaims (repeated 3 times)

kubectl get sc

NAME                 PROVISIONER            AGE
standard (default)   kubernetes.io/gce-pd   5d19h

kubectl get pv
No resources found in infra namespace.
kubectl get pvc
NAME                                                         STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
elasticsearch-data-persistent-storage-elasticsearch-data-0   Pending                                      gp2            8h
Katlynkatmai answered 5/6, 2020 at 12:52 Comment(7)
share output of kubectl get pv,pvc,scIdeate
Added statefulset output.PVC is not createdKatlynkatmai
Share the output of kubectl get scIdeate
@ArghyaSadhu addedKatlynkatmai
Share output of Kubectl get pv,pvcIdeate
@ArghyaSadhu AddedKatlynkatmai
Can you specify storageClassName: "standard" in the volumeClaimTemplatesIdeate
M
11

It looks like there is some issue with your PVC.

NAME                                                         STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
elasticsearch-data-persistent-storage-elasticsearch-data-0   Pending                                      gp2            8h

As you can see your PV is also not created.I think there is an issue with your storage class.Looks like gp2 storage class is not available in your cluster.

Either run this yaml file if you are in AWS EKS

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: gp2
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  fsType: ext4

or simply change the storage class to standard in GCP GKE

Metropolis answered 5/6, 2020 at 14:21 Comment(0)
I
6

From the docs here

The storage for a given Pod must either be provisioned by a PersistentVolume Provisioner based on the requested storage class, or pre-provisioned by an admin.

There should be a StorageClass which can dynamically provision the PV and mention that storageClassName in the volumeClaimTemplates or there needs to be a PV which can satisfy the PVC.

volumeClaimTemplates:
  - metadata:
      name: elasticsearch-data-persistent-storage
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "standard"
      resources:
        requests:
          storage: 10Gi
Ideate answered 5/6, 2020 at 12:57 Comment(3)
with StatefulSet do,we need a PVC? @ArghyaKatlynkatmai
There should be a PV or a storage classIdeate
I had the issue with value premium-rwo trying to deploy to Minicube. After the change to standard it worksPennate
A
1
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  namespace: default
  name: elasticsearch-data
  labels:
    app: elasticsearch
    role: data
spec:
  serviceName: "elasticsearch-data"
  replicas: 1
  template:
    metadata:
      labels:
        app: elasticsearch-data
        role: data
    spec:
      containers:
        - name: elasticsearch-data
          image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
          env:
            - name: CLUSTER_NAME
              value: elasticsearch
            - name: NODE_NAME
              value: elasticsearch-data
            - name: NODE_LIST
              value: elasticsearch-master,elasticsearch-data,elasticsearch-client
            - name: MASTER_NODES
              value: elasticsearch-master
            - name: "ES_JAVA_OPTS"
              value: "-Xms300m -Xmx300m"
          ports:
            - containerPort: 9300
              name: transport
          volumeMounts:
            - name: config
              mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
              readOnly: true
              subPath: elasticsearch.yml
            - name: elasticsearch-data-persistent-storage
              mountPath: /data/db
      volumes:
        - name: config
          configMap:
            name: elasticsearch-data-config
      initContainers:
        - name: increase-vm-max-map
          image: busybox
          command: ["sysctl", "-w", "vm.max_map_count=262144"]
          securityContext:
            privileged: true
  volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data-persistent-storage
        annotations:
          volume.beta.kubernetes.io/storage-class: "standard"
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 10Gi
---

This worked for me. Like Avinash said I simply changed the storage class to standard in GCP GKE

Aeneas answered 5/11, 2020 at 22:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.