Helm/Grafana: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
  helm repo add grafana https://grafana.github.io/helm-charts
  helm repo add grafana https://grafana.github.io/helm-charts
  helm repo update
  helm repo update && helm repo list
helm repo list
kubectl config get-contexts


==Config==
==Config==
Line 13: Line 13:
<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
kubectl create namespace grafana
kubectl create namespace grafana
helm show values grafana/grafana|less
cat <<YML | helm install -n grafana grafana grafana/grafana -f -
cat <<YML | helm install -n grafana grafana grafana/grafana -f -
ingress:
ingress:
Line 18: Line 19:
   hosts:
   hosts:
   - grafana.k8s.local
   - grafana.k8s.local
  tls:
  - secretName: grafana.k8s.local.tls
      hosts:
      - grafana.k8s.local
YML
YML
</syntaxhighlight>


kubectl get secret -n grafana grafana -o json|jq -r '.data."admin-password"'|base64 -d;echo
==ConfigMap==
kubectl get secret -n grafana grafana -o json|jq -r '.data."admin-user"'|base64 -d;echo
<syntaxhighlight lang="yaml">
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
</syntaxhighlight>
</syntaxhighlight>


Line 32: Line 54:
==Playground==
==Playground==
{|
{|
| valign="top" colspan="2" |
<syntaxhighlight lang="bash">
GRAFANA_POD_NAME="$(kubectl -n grafana get pod -l 'app.kubernetes.io/name=grafana' -o json|jq -r '.items[0].metadata.name')"
</syntaxhighlight>
|-
| colspan="2" |
----
|-
| valign="top" |
| valign="top" |
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
helm upgrade --install -f values.yaml grafana grafana/grafana
helm upgrade --install -f values.yaml grafana grafana/grafana
helm upgrade --install grafana grafana/grafana
helm upgrade --install grafana grafana/grafana
helm show values grafana/grafana
helm show values grafana/grafana|less
</syntaxhighlight>
</syntaxhighlight>


| valign="top" |
| valign="top" |
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl exec -n grafana -it grafana-6fd8886fd4-4vwgh -- cat /etc/os-release
kubectl -n grafana exec -it ${GRAFANA_POD_NAME} -- cat /etc/os-release
kubectl exec -n grafana -it grafana-6fd8886fd4-4vwgh -- bash
kubectl -n grafana exec -it ${GRAFANA_POD_NAME} -- bash
kubectl exec -n grafana -it grafana-6fd8886fd4-4vwgh -- sh
kubectl -n grafana exec -it ${GRAFANA_POD_NAME} -- sh
</syntaxhighlight>
</syntaxhighlight>


Line 52: Line 83:
| valign="top" |
| valign="top" |
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl delete all --all -n grafana
kubectl -n grafana logs -f ${GRAFANA_POD_NAME}
kubectl delete ing --all -n grafana
kubectl -n grafana rollout restart deploy grafana
kubectl delete sts --all -n grafana
kubectl -n grafana rollout restart sts grafana
kubectl -n grafana logs -f grafana-hash
</syntaxhighlight>
</syntaxhighlight>


| valign="top" |
| valign="top" |
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl delete svc --all -n grafana
kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl delete pvc --all -n grafana
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten
kubectl delete pv  --all -n grafana
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten
</syntaxhighlight>
 
|-
| colspan="2" |
----
|-
| valign="top" colspan="2" |
<syntaxhighlight lang="bash">
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
</syntaxhighlight>
</syntaxhighlight>


Line 70: Line 117:
| valign="top" |
| valign="top" |
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl logs -f grafana-6fd8886fd4-4vwgh -n grafana
kubectl -n grafana delete all --all
kubectl rollout restart deploy grafana -n grafana
kubectl -n grafana delete ing --all
kubectl rollout restart sts grafana -n grafana
kubectl -n grafana delete sts --all
kubectl logs -f grafana-hash -n grafana
</syntaxhighlight>
</syntaxhighlight>


| valign="top" |
| valign="top" |
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl -n grafana delete svc --all
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten
kubectl -n grafana delete pvc --all
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl -n grafana delete pv  --all
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten
</syntaxhighlight>
</syntaxhighlight>


Line 90: Line 135:
| valign="top" |
| valign="top" |
* [https://stackoverflow.com/questions/75596795/ Helm » Pass YAML/JSON using <code>stdin</code>]
* [https://stackoverflow.com/questions/75596795/ Helm » Pass YAML/JSON using <code>stdin</code>]
* [[Helm/Prometheus Stack|Helm » Prometheus Stack]]
* [https://github.com/grafana/helm-charts/tree/main/charts/grafana Helm » Grafana » GitHub]
* [https://github.com/grafana/helm-charts/tree/main/charts/grafana Helm » Grafana » GitHub]
* [[Helm/Cert Manager|Helm » Cert Manager]]
* [https://artifacthub.io/packages/helm/grafana/grafana Helm » Grafana]
* [https://artifacthub.io/packages/helm/grafana/grafana Helm » Grafana]
* [[Helm]]
* [[Helm]]
Line 103: Line 150:
|-
|-
| valign="top" |
| valign="top" |
* [https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ K8s » Configure Service Accounts for Pods]
* [https://cloud.google.com/monitoring/agent/ops-agent/prometheus Grafana » GCP » Collect Prometheus metrics]
* [https://spacelift.io/blog/restart-kubernetes-pods-with-kubectl K8s » Restart Pods With Kubectl]
* [https://aws.amazon.com/blogs/mt/visualize-and-gain-insights-into-your-aws-cost-and-usage-with-amazon-managed-grafana/ Grafana » Prometheus » AWS Cost & Usage]
* [https://medium.com/@pczarkowski/kubernetes-tip-run-an-interactive-pod-d701766a12 K8s » Interactive Pod]
* [https://grafana.com/grafana/dashboards/315-kubernetes-cluster-monitoring-via-prometheus/ Grafana » Dashboards » K8s » Prometheus]
* [https://spacelift.io/blog/restart-kubernetes-pods-with-kubectl K8s » Restart Pods]
* [https://grafana.com/docs/grafana-cloud/monitor-infrastructure/integrations/integration-reference/integration-azure-metrics/  Grafana » Azure » Metrics integration]
* [https://earthly.dev/blog/docker-and-makefiles/ Docker » Makefile]
* [https://grafana.com/docs/grafana-cloud/monitor-infrastructure/integrations/integration-reference/integration-gcp-metrics/ Grafana » GCP » Metrics Integration]
* [[Kubernetes]]
* [https://www.linode.com/marketplace/apps/linode/prometheus-grafana/ Grafana » Prometheus » Linode]
* [[Minikube]]
* [[Kubectl]]
* [[CURL]]
* [[K8s]]
 
| valign="top" |
* [https://grafana.com/docs/grafana/latest/setup-grafana/installation/helm/ Grafana » Helm » Install]
* [https://grafana.com/docs/grafana/latest/setup-grafana/installation/helm/ Grafana » Helm » Install]
* [https://grafana.com/docs/grafana/latest/setup-grafana/installation/kubernetes/ Grafana » K8s » Install]
* [https://grafana.com/docs/grafana/latest/setup-grafana/installation/kubernetes/ Grafana » K8s » Install]
* [https://grafana.com/grafana/dashboards/ Grafana » Dashboards]
* [https://grafana.com/grafana/ Grafana]
* [https://grafana.com/grafana/ Grafana]
| valign="top" |


| valign="top" |
| valign="top" |
Line 126: Line 170:
|-
|-
| valign="top" |
| valign="top" |
* [https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ K8s » Configure Service Accounts for Pods]
* [https://spacelift.io/blog/restart-kubernetes-pods-with-kubectl K8s » Restart Pods With Kubectl]
* [https://medium.com/@pczarkowski/kubernetes-tip-run-an-interactive-pod-d701766a12 K8s » Interactive Pod]
* [https://spacelift.io/blog/restart-kubernetes-pods-with-kubectl K8s » Restart Pods]
* [https://earthly.dev/blog/docker-and-makefiles/ Docker » Makefile]
* [[Kubernetes]]
* [[Minikube]]
* [[Kubectl]]
* [[CURL]]
* [[K8s]]


| valign="top" |
| valign="top" |
* [[K8s/CSI Hostpath Driver|K8s » CSI Hostpath Driver]]


| valign="top" |
| valign="top" |


|}
|}

Latest revision as of 12:15, 22 August 2024

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