Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions grafana/READEME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Grafana

## Installation

### Grafana Minikube cluster setup

```bash
minikube start --memory=4096 --cpus=2 --disk-size=30g --kubernetes-version=v1.25.14 --nodes 3 --profile grafana
minikube addons enable -p grafana metrics-server
minikube addons disable -p grafana storage-provisioner
minikube addons disable -p grafana default-storageclass
# minikube addons disalbe -p grafana volumesnapshots
# minikube addons disalbe -p grafana csi-hostpath-driver
# kubectl patch storageclass csi-hostpath-sc -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
minikube dashboard
```

```bash
cat <<EOF | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: standard
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubevirt.io/hostpath-provisioner
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubevirt-hostpath-provisioner
subjects:
- kind: ServiceAccount
name: kubevirt-hostpath-provisioner-admin
namespace: kube-system
roleRef:
kind: ClusterRole
name: kubevirt-hostpath-provisioner
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: kubevirt-hostpath-provisioner
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]

- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]

- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubevirt-hostpath-provisioner-admin
namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kubevirt-hostpath-provisioner
labels:
k8s-app: kubevirt-hostpath-provisioner
namespace: kube-system
spec:
selector:
matchLabels:
k8s-app: kubevirt-hostpath-provisioner
template:
metadata:
labels:
k8s-app: kubevirt-hostpath-provisioner
spec:
serviceAccountName: kubevirt-hostpath-provisioner-admin
containers:
- name: kubevirt-hostpath-provisioner
image: quay.io/kubevirt/hostpath-provisioner
imagePullPolicy: Always
env:
- name: USE_NAMING_PREFIX
value: "false" # change to true, to have the name of the pvc be part of the directory
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: PV_DIR
value: /tmp/hostpath-provisioner
volumeMounts:
- name: pv-volume # root dir where your bind mounts will be on the node
mountPath: /tmp/hostpath-provisioner/
#nodeSelector:
#- name: xxxxxx
volumes:
- name: pv-volume
hostPath:
path: /tmp/hostpath-provisioner/
EOF
```

## Prerequsites

### minio

```bash
helm repo add minio-operator https://operator.min.io

helm install \
--namespace minio-operator-system \
--create-namespace \
minio-operator minio-operator/operator
```

minio console

```bash
kubectl port-forward svc/console -n minio-operator-system 9090:9090
kubectl get secret/console-sa-secret -n minio-operator-system -o json | jq -r ".data.token" | base64 -d
# access to localhost:9090 and then create TEANT, name is grafana

kubectl port-forward svc/grafana-console -n grafana 9443:9443 # you can access TENANT console
# you can access key from get minio console TENANT>grafana>Configration Tab> ENV variables
# access to localhost:9443 and then create grafana-loki.local bucket
# create Access Keys grafana-loki
# Set up region name Administrator>Settings>>Region>local save and restart
```

## Grafana Helms

### Loki

```bash
helm repo add grafana https://grafana.github.io/helm-charts
helm install -n grafana --values loki/values.yaml loki grafana/loki
```

### Promtail

```bash
helm upgrade --install --values promtail/values.yaml -n grafana promtail grafana/promtail
```

### grafana

```bash
helm upgrade --install --values values.yaml -n grafana grafana grafana/grafana
```
19 changes: 19 additions & 0 deletions grafana/loki/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
loki:
auth_enabled: false
storage:
bucketNames:
chunks: chunks.loki.local
ruler: ruler.loki.local
admin: admin.loki.local
type: s3
s3:
endpoint: https://minio.grafana.svc.cluster.local
region: local
secretAccessKey: iUerATCmkmu4bhtmpttrXCJb7rvxEiZdAt9cFyeI
accessKeyId: jHtX1ehHN6bCgcfBOREH
s3ForcePathStyle: true
insecure: true
http_config:
insecure_skip_verify: true
minio:
enabled: false
4 changes: 4 additions & 0 deletions grafana/promtail/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config:
# publish data to loki
clients:
- url: http://loki-gateway.grafana.svc.cluster.local/loki/api/v1/push
Empty file added grafana/values.yaml
Empty file.