apiVersion: apps/v1 kind: Deployment metadata: name: grafana labels: app.kubernetes.io/name: grafana spec: replicas: 1 # we can only have 1 replica for as long as the database is sqlite strategy: type: Recreate selector: matchLabels: app.kubernetes.io/name: grafana template: metadata: labels: app.kubernetes.io/name: grafana spec: containers: - name: grafana image: grafana/grafana env: - name: GF_AUTH_ANONYMOUS_ENABLED value: "true" - name: GF_AUTH_ANONYMOUS_ORG_ROLE value: Viewer # - name: GF_DATABASE_TYPE # value: postgres # - name: GF_DATABASE_HOST # valueFrom: # secretKeyRef: # name: postgres-credentials # key: host # - name: GF_DATABASE_NAME # valueFrom: # secretKeyRef: # name: postgres-credentials # key: database # - name: GF_DATABASE_USER # valueFrom: # secretKeyRef: # name: postgres-credentials # key: username # - name: GF_DATABASE_PASSWORD # valueFrom: # secretKeyRef: # name: postgres-credentials # key: password 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 ports: - name: http containerPort: 3000 resources: requests: cpu: 250m memory: 500Mi limits: cpu: 500m memory: 750Mi volumeMounts: - name: grafana-datasources mountPath: /etc/grafana/provisioning/datasources - mountPath: /var/lib/grafana name: grafana-pv volumes: - name: grafana-datasources configMap: name: grafana-datasources - name: grafana-pv persistentVolumeClaim: claimName: grafana-pvc --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: grafana-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi --- apiVersion: v1 kind: Service metadata: name: grafana labels: app.kubernetes.io/name: grafana monitor: prometheus spec: selector: app.kubernetes.io/name: grafana ports: - name: http port: 3000 targetPort: http