Helm/Grafana

From Chorke Wiki
Revision as of 12:15, 22 August 2024 by Shahed (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update && helm repo list
kubectl config get-contexts

Config

export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"

Install

kubectl create namespace grafana
helm show values grafana/grafana|less
cat <<YML | helm install -n grafana grafana grafana/grafana -f -
ingress:
  enabled: true
  hosts:
  - grafana.k8s.local
  tls:
  - secretName: grafana.k8s.local.tls
      hosts:
      - grafana.k8s.local
YML

ConfigMap

cat <<-'YML' | kubectl -n grafana apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasources
  namespace: grafana
data:
  datasources.yaml: |
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server.prometheus.svc.cluster.local:9090
      access: proxy
      isDefault: true
YML

Uninstall

helm uninstall -n grafana grafana
helm delete    -n grafana grafana

Playground

GRAFANA_POD_NAME="$(kubectl -n grafana get pod -l 'app.kubernetes.io/name=grafana' -o json|jq -r '.items[0].metadata.name')"

helm upgrade --install -f values.yaml grafana grafana/grafana
helm upgrade --install grafana grafana/grafana
helm show values grafana/grafana|less
kubectl -n grafana exec -it ${GRAFANA_POD_NAME} -- cat /etc/os-release
kubectl -n grafana exec -it ${GRAFANA_POD_NAME} -- bash
kubectl -n grafana exec -it ${GRAFANA_POD_NAME} -- sh

kubectl -n grafana logs -f ${GRAFANA_POD_NAME}
kubectl -n grafana rollout restart deploy grafana
kubectl -n grafana rollout restart sts grafana
kubectl -n grafana logs -f grafana-hash
kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten

kubectl -n grafana get pod -l 'app.kubernetes.io/name=grafana' -o json|jq -r '.items[0].metadata.name'
kubectl -n grafana get secret grafana -o json|jq -r '.data."admin-password"'|base64 -d;echo
kubectl -n grafana get secret grafana -o json|jq -r '.data."admin-user"'|base64 -d;echo
kubectl -n grafana get cm     grafana-datasources -o yaml
kubectl -n grafana get cm     grafana -o yaml
kubectl -n grafana get secret grafana -o yaml

kubectl -n grafana delete all --all
kubectl -n grafana delete ing --all
kubectl -n grafana delete sts --all
kubectl -n grafana delete svc --all
kubectl -n grafana delete pvc --all
kubectl -n grafana delete pv  --all

References