Problem deploy grafana to K8s

I currently have a server. Kubernetes server running locally on Linux and not in the cloud.

I have just installed Grafana following the documentation but I realize that my pods remain in status pending.

If you run this command on the PVC
kubectl describe pvc grafana-pvc -n my-grafana

I get this:

[root@k8s-master ~]# kubectl describe pvc grafana-pvc -n my-grafana
Name: grafana-pvc
Namespace: my-grafana
StorageClass:  
Status: Pending
Volume:        
Labels: <none>
Annotations: <none>
Finalizers: [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
VolumeMode: Filesystem
Used By: grafana-6756f6587b-m5w88
Events:
  Type Reason Age From Message
  ---- ------ ---- ---- -------
  Normal FailedBinding 100s (x242 over 61m) persistentvolume-controller no persistent volumes available for this claim and no storage class is set

I’ve got the impression that it doesn’t create any volumes, but I’ve used the yaml provided in the Grafana documentation and put in exactly the same yaml file.

The doc:https://grafana.com/docs/grafana/latest/setup-grafana/installation/kubernetes/

The yaml file:

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: grafana
  name: grafana
spec:
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      securityContext:
        fsGroup: 472
        supplementalGroups:
          - 0
      containers:
        - name: grafana
          image: grafana/grafana:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
              name: http-grafana
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /robots.txt
              port: 3000
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 2
          livenessProbe:
            failureThreshold: 3
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 3000
            timeoutSeconds: 1
          resources:
            requests:
              cpu: 250m
              memory: 750Mi
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: grafana-pv
      volumes:
        - name: grafana-pv
          persistentVolumeClaim:
            claimName: grafana-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: grafana
spec:
  ports:
    - port: 3000
      protocol: TCP
      targetPort: http-grafana
  selector:
    app: grafana
  sessionAffinity: None
  type: LoadBalancer

Could you help me with this?

Thank you in advance.

Do you have a storage class created in your k8s cluster, if yes, is it marked as default ?

You can check that by running kubectl get storageclass

Because the error message says : no storage class is set

1 Like