Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pod has unbound immediate PersistentVolumeClaims (repeated 3 times)

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
like image 960
RIYAJ KHAN Avatar asked Jun 05 '20 12:06

RIYAJ KHAN


2 Answers

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

like image 177
Avinash Jha Avatar answered Oct 03 '22 19:10

Avinash Jha


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
like image 21
Arghya Sadhu Avatar answered Oct 03 '22 19:10

Arghya Sadhu