From 7fdd4bb7cbfb7f2c50865a6ddafe7f2ee7495b8c Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 5 Jul 2023 14:21:39 +0200 Subject: [PATCH] feat(grafana): Add basic configuration and provisioning --- README.md | 7 +++ manifests/grafana/datasources.yaml | 21 +++++++++ manifests/grafana/deployment.yaml | 70 ++++++++++++++++++++++++++++ manifests/grafana/ingress.yaml | 23 +++++++++ manifests/grafana/kustomization.yaml | 9 ++++ manifests/grafana/pvc.yaml | 13 ++++++ manifests/grafana/service.yaml | 13 ++++++ manifests/kustomization.yaml | 6 +++ manifests/namespace.yaml | 4 ++ 9 files changed, 166 insertions(+) create mode 100644 README.md create mode 100644 manifests/grafana/datasources.yaml create mode 100644 manifests/grafana/deployment.yaml create mode 100644 manifests/grafana/ingress.yaml create mode 100644 manifests/grafana/kustomization.yaml create mode 100644 manifests/grafana/pvc.yaml create mode 100644 manifests/grafana/service.yaml create mode 100644 manifests/kustomization.yaml create mode 100644 manifests/namespace.yaml diff --git a/README.md b/README.md new file mode 100644 index 0000000..a0f90fa --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Monitoring stack + +## Grafana + +## Loki + +## Prometheus Operator diff --git a/manifests/grafana/datasources.yaml b/manifests/grafana/datasources.yaml new file mode 100644 index 0000000..7db5886 --- /dev/null +++ b/manifests/grafana/datasources.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: grafana-datasources + namespace: monitoring +data: + default.yaml: |- + apiVersion: 1 + datasources: + - name: Loki + type: loki + access: proxy + url: "http://loki:3100" + version: 1 + isDefault: true + - name: Prometheus + type: prometheus + access: proxy + url: "http://prometheus-operator:9090" + version: 1 + isDefault: false diff --git a/manifests/grafana/deployment.yaml b/manifests/grafana/deployment.yaml new file mode 100644 index 0000000..3e809db --- /dev/null +++ b/manifests/grafana/deployment.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: grafana + namespace: monitoring +spec: + selector: + matchLabels: + app: grafana + template: + metadata: + labels: + app: grafana + spec: + securityContext: + fsGroup: 472 + supplementalGroups: + - 0 + containers: + - name: grafana + image: grafana/grafana:10.0.1 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 3000 + 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: + - name: grafana-pv + mountPath: /var/lib/grafana + - name: grafana-datasources-volume + mountPath: /etc/grafana/provisioning/datasources/default.yaml + subPath: default.yaml + env: + - name: GF_SECURITY_ADMIN_USER + valueFrom: + secretKeyRef: + name: grafana-secrets + key: admin-user + - name: GF_SECURITY_ADMIN_PASSWORD + valueFrom: + secretKeyRef: + name: grafana-secrets + key: admin-password + volumes: + - name: grafana-pv + persistentVolumeClaim: + claimName: grafana-pvc + - name: grafana-datasources-volume + configMap: + name: grafana-datasources diff --git a/manifests/grafana/ingress.yaml b/manifests/grafana/ingress.yaml new file mode 100644 index 0000000..75850f9 --- /dev/null +++ b/manifests/grafana/ingress.yaml @@ -0,0 +1,23 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: grafana-ingress + namespace: monitoring + annotations: + kubernetes.io/ingress.class: "traefik-inter" +spec: + tls: + - secretName: grafana-beta-tls + hosts: + - grafana.beta.entos + rules: + - host: grafana.beta.entos + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: grafana-svc + port: + number: 80 diff --git a/manifests/grafana/kustomization.yaml b/manifests/grafana/kustomization.yaml new file mode 100644 index 0000000..4dec0c4 --- /dev/null +++ b/manifests/grafana/kustomization.yaml @@ -0,0 +1,9 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - pvc.yaml + - service.yaml + - ingress.yaml + - datasources.yaml + - deployment.yaml diff --git a/manifests/grafana/pvc.yaml b/manifests/grafana/pvc.yaml new file mode 100644 index 0000000..d8fd319 --- /dev/null +++ b/manifests/grafana/pvc.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: grafana-pvc + namespace: monitoring +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + storageClassName: flat-storage-class diff --git a/manifests/grafana/service.yaml b/manifests/grafana/service.yaml new file mode 100644 index 0000000..029e9a5 --- /dev/null +++ b/manifests/grafana/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: grafana-svc + namespace: monitoring +spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: 3000 + selector: + app: grafana diff --git a/manifests/kustomization.yaml b/manifests/kustomization.yaml new file mode 100644 index 0000000..78b4da9 --- /dev/null +++ b/manifests/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - namespace.yaml + - grafana diff --git a/manifests/namespace.yaml b/manifests/namespace.yaml new file mode 100644 index 0000000..d325236 --- /dev/null +++ b/manifests/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring