feat(grafana): Add basic configuration and provisioning

This commit is contained in:
Tanguy Herbron 2023-07-05 14:21:39 +02:00
commit 7fdd4bb7cb
9 changed files with 166 additions and 0 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# Monitoring stack
## Grafana
## Loki
## Prometheus Operator

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- pvc.yaml
- service.yaml
- ingress.yaml
- datasources.yaml
- deployment.yaml

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- grafana

4
manifests/namespace.yaml Normal file
View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: monitoring