k8s Prometheus:pod has unbound PersistentVolumeClaims

7/17/2018

I install kube1.10.3 in two virtualbox(centos 7.4) in my win10 machine. I use git clone to get prometheus yaml files.

git clone https://github.com/kubernetes/kubernetes

Then I enter kubernetes/cluster/addons/prometheus annd follow this order to create pods:

alertmanager-configmap.yaml
alertmanager-pvc.yaml
alertmanager-deployment.yaml
alertmanager-service.yaml

kube-state-metrics-rbac.yaml
kube-state-metrics-deployment.yaml
kube-state-metrics-service.yaml

node-exporter-ds.yml
node-exporter-service.yaml

prometheus-configmap.yaml
prometheus-rbac.yaml
prometheus-statefulset.yaml
prometheus-service.yaml

But Prometheus and alertmanage are in pending state:

kube-system   alertmanager-6bd9584b85-j4h5m              0/2       Pending   0          9m
kube-system   calico-etcd-pnwtr                          1/1       Running   0          16m
kube-system   calico-kube-controllers-5d74847676-mjq4j   1/1       Running   0          16m
kube-system   calico-node-59xfk                          2/2       Running   1          16m
kube-system   calico-node-rqsh5                          2/2       Running   1          16m
kube-system   coredns-7997f8864c-ckhsq                   1/1       Running   0          16m
kube-system   coredns-7997f8864c-jjtvq                   1/1       Running   0          16m
kube-system   etcd-master16g                             1/1       Running   0          15m
kube-system   heapster-589b7db6c9-mpmks                  1/1       Running   0          16m
kube-system   kube-apiserver-master16g                   1/1       Running   0          15m
kube-system   kube-controller-manager-master16g          1/1       Running   0          15m
kube-system   kube-proxy-hqq49                           1/1       Running   0          16m
kube-system   kube-proxy-l8hmh                           1/1       Running   0          16m
kube-system   kube-scheduler-master16g                   1/1       Running   0          16m
kube-system   kube-state-metrics-8595f97c4-g6x5x         2/2       Running   0          8m
kube-system   kubernetes-dashboard-7d5dcdb6d9-944xl      1/1       Running   0          16m
kube-system   monitoring-grafana-7b767fb8dd-mg6dd        1/1       Running   0          16m
kube-system   monitoring-influxdb-54bd58b4c9-z9tgd       1/1       Running   0          16m
kube-system   node-exporter-f6pmw                        1/1       Running   0          8m
kube-system   node-exporter-zsd9b                        1/1       Running   0          8m
kube-system   prometheus-0                               0/2       Pending   0          7m

I checked prometheus pod by command shown below:

[root@master16g prometheus]# kubectl describe pod prometheus-0 -n kube-system
Name:           prometheus-0
Namespace:      kube-system
Node:           <none>
Labels:         controller-revision-hash=prometheus-8fc558cb5
                k8s-app=prometheus
                statefulset.kubernetes.io/pod-name=prometheus-0
Annotations:    scheduler.alpha.kubernetes.io/critical-pod=
Status:         Pending
IP:
Controlled By:  StatefulSet/prometheus
Init Containers:
  init-chown-data:
    Image:      busybox:latest
    Port:       <none>
    Host Port:  <none>
    Command:
      chown
      -R
      65534:65534
      /data
    Environment:  <none>
    Mounts:
      /data from prometheus-data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from prometheus-token-f6v42 (ro)
Containers:
  prometheus-server-configmap-reload:
    Image:      jimmidyson/configmap-reload:v0.1
    Port:       <none>
    Host Port:  <none>
    Args:
      --volume-dir=/etc/config
      --webhook-url=http://localhost:9090/-/reload
    Limits:
      cpu:     10m
      memory:  10Mi
    Requests:
      cpu:        10m
      memory:     10Mi
    Environment:  <none>
    Mounts:
      /etc/config from config-volume (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from prometheus-token-f6v42 (ro)
  prometheus-server:
    Image:      prom/prometheus:v2.2.1
    Port:       9090/TCP
    Host Port:  0/TCP
    Args:
      --config.file=/etc/config/prometheus.yml
      --storage.tsdb.path=/data
      --web.console.libraries=/etc/prometheus/console_libraries
      --web.console.templates=/etc/prometheus/consoles
      --web.enable-lifecycle
    Limits:
      cpu:     200m
      memory:  1000Mi
    Requests:
      cpu:        200m
      memory:     1000Mi
    Liveness:     http-get http://:9090/-/healthy delay=30s timeout=30s period=10s #success=1 #failure=3
    Readiness:    http-get http://:9090/-/ready delay=30s timeout=30s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /data from prometheus-data (rw)
      /etc/config from config-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from prometheus-token-f6v42 (ro)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  prometheus-data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  prometheus-data-prometheus-0
    ReadOnly:   false
  config-volume:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      prometheus-config
    Optional:  false
  prometheus-token-f6v42:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  prometheus-token-f6v42
    Optional:    false
QoS Class:       Guaranteed
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  42s (x22 over 5m)  default-scheduler  pod has unbound PersistentVolumeClaims (repeated 2 times)

In the last line, it shows warning message: pod has unbound PersistentVolumeClaims (repeated 2 times)

The Prometheus logs says:

[root@master16g prometheus]# kubectl logs prometheus-0 -n kube-system
Error from server (BadRequest): a container name must be specified for pod prometheus-0, choose one of: [prometheus-server-configmap-reload prometheus-server] or one of the init containers: [init-chown-data]

The I describe alertmanager pod and its logs:

[root@master16g prometheus]# kubectl describe pod alertmanager-6bd9584b85-j4h5m -n kube-system
Name:           alertmanager-6bd9584b85-j4h5m
Namespace:      kube-system
Node:           <none>
Labels:         k8s-app=alertmanager
                pod-template-hash=2685140641
                version=v0.14.0
Annotations:    scheduler.alpha.kubernetes.io/critical-pod=
Status:         Pending
IP:
Controlled By:  ReplicaSet/alertmanager-6bd9584b85
Containers:
  prometheus-alertmanager:
    Image:      prom/alertmanager:v0.14.0
    Port:       9093/TCP
    Host Port:  0/TCP
    Args:
      --config.file=/etc/config/alertmanager.yml
      --storage.path=/data
      --web.external-url=/
    Limits:
      cpu:     10m
      memory:  50Mi
    Requests:
      cpu:        10m
      memory:     50Mi
    Readiness:    http-get http://:9093/%23/status delay=30s timeout=30s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /data from storage-volume (rw)
      /etc/config from config-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-snfrt (ro)
  prometheus-alertmanager-configmap-reload:
    Image:      jimmidyson/configmap-reload:v0.1
    Port:       <none>
    Host Port:  <none>
    Args:
      --volume-dir=/etc/config
      --webhook-url=http://localhost:9093/-/reload
    Limits:
      cpu:     10m
      memory:  10Mi
    Requests:
      cpu:        10m
      memory:     10Mi
    Environment:  <none>
    Mounts:
      /etc/config from config-volume (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-snfrt (ro)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  config-volume:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      alertmanager-config
    Optional:  false
  storage-volume:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  alertmanager
    ReadOnly:   false
  default-token-snfrt:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-snfrt
    Optional:    false
QoS Class:       Guaranteed
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  3m (x26 over 9m)  default-scheduler  pod has unbound PersistentVolumeClaims (repeated 2 times)

And its log:

[root@master16g prometheus]# kubectl logs alertmanager-6bd9584b85-j4h5m -n kube-system
Error from server (BadRequest): a container name must be specified for pod alertmanager-6bd9584b85-j4h5m, choose one of: [prometheus-alertmanager prometheus-alertmanager-configmap-reload] 

It has same warning message as Prometheus:

pod has unbound PersistentVolumeClaims (repeated 2 times)

Then I get pvc by issuing command as follows:

[root@master16g prometheus]# kubectl get pvc --all-namespaces
NAMESPACE     NAME                           STATUS    VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   AGE
kube-system   alertmanager                   Pending                                       standard       20m
kube-system   prometheus-data-prometheus-0   Pending                                       standard       19m

My question is how to make bound persistentVolumnClaim? Why log says container name must be specified?

\===============================================================

Second edition

Since pvc file defined storage class, so I need to define a storage class yaml. How to do it if I want Nfs or GlusterFs? In this way, I could avoid cloud vendor, like Google or AWS.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: alertmanager
  namespace: kube-system
  labels:
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: EnsureExists
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: "2Gi"
-- user84592
kubernetes
prometheus

1 Answer

7/17/2018

This log entry:

Error from server (BadRequest): a container name must be specified for pod alertmanager-6bd9584b85-j4h5m, choose one of: [prometheus-alertmanager prometheus-alertmanager-configmap-reload] 

means Pod alertmanager-6bd9584b85-j4h5m consists of two containers:

  • prometheus-alertmanager
  • prometheus-alertmanager-configmap-reload

When you use kubectl logs for Pod which consists of more then one containers you must specify a name of the container to view its logs. Command template:

kubectl -n <namespace> logs <pod_name> <container_name>

For example, if you want to view logs of the container prometheus-alertmanager which is a part of Pod alertmanager-6bd9584b85-j4h5m in the namespace kube-system you should use this command:

kubectl -n kube-system logs alertmanager-6bd9584b85-j4h5m prometheus-alertmanager

Pending status of the PVCs could mean you have no corresponding PVs

-- Konstantin Vustin
Source: StackOverflow