apiVersion: apps/v1 kind: Deployment metadata: name: monitoring-grafana namespace: monitoring spec: replicas: 1 selector: matchLabels: k8s-app: grafana template: metadata: labels: task: monitoring k8s-app: grafana spec: containers: - name: grafana image: grafana/grafana:6.4.3 env: - name: GF_PATHS_PROVISIONING value: /var/lib/grafana/provisioning volumeMounts: - name: grafana-storage mountPath: /var/lib/grafana/ ports: - containerPort: 3000 protocol: TCP initContainers: - name: "init-chown-data" image: "busybox:latest" imagePullPolicy: "IfNotPresent" command: ["chown", "-R", "472:472", "/var/lib/grafana/"] volumeMounts: - name: grafana-storage mountPath: /var/lib/grafana/ subPath: "" volumes: - name: grafana-storage persistentVolumeClaim: claimName: monitoring-grafana-claim --- apiVersion: v1 kind: Service metadata: labels: kubernetes.io/cluster-service: 'true' kubernetes.io/name: monitoring-grafana name: monitoring-grafana namespace: monitoring spec: type: NodePort ports: - port: 80 targetPort: 3000 nodePort: 32333 selector: k8s-app: grafana