apiVersion: v1 kind: Service metadata: name: grafana labels: k8s-app: grafana spec: type: NodePort ports: - name: http port: 3000 targetPort: 3000 nodePort: 30300 selector: k8s-app: grafana --- apiVersion: apps/v1 kind: Deployment metadata: name: grafana labels: k8s-app: grafana spec: selector: matchLabels: k8s-app: grafana template: metadata: labels: k8s-app: grafana spec: initContainers: - name: init-file image: busybox:1.28 imagePullPolicy: IfNotPresent securityContext: runAsUser: 0 command: ['chown', '-R', "472:0", "/var/lib/grafana"] volumeMounts: - name: data mountPath: /var/lib/grafana subPath: grafana containers: - name: grafana image: grafana/grafana:7.4.3 securityContext: fsGroup: 0 runAsUser: 472 ports: - name: http containerPort: 3000 env: - name: GF_SECURITY_ADMIN_USER value: "admin" - name: GF_SECURITY_ADMIN_PASSWORD value: "admin" resources: limits: cpu: '2' memory: 1Gi requests: cpu: 1 memory: 512Mi readinessProbe: failureThreshold: 10 httpGet: path: /api/health port: 3000 scheme: HTTP initialDelaySeconds: 10 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 30 livenessProbe: failureThreshold: 10 httpGet: path: /api/health port: 3000 scheme: HTTP initialDelaySeconds: 10 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 1 volumeMounts: - name: data mountPath: /var/lib/grafana subPath: grafana volumes: - name: data persistentVolumeClaim: claimName: grafana