Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Prometheus-operator installation with Helm

  • Prometheus, Grafana, kube-state-metrics, prometheus-node-exporter on Kubernetes

helm Chart

Prerequisites

  • Kubernetes 1.19+
  • Helm 3.2.0+
  • A persistent storage resource and RW access to it
  • Kubernetes StorageClass for dynamic provisioning

Document

helm update

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

Install

helm install prometheus-stack prometheus-community/kube-prometheus-stack \
  --create-namespace \
  --namespace prometheus-stack \
  --set grafana.adminPassword=prom-operator

image

clusterIP to NodePort
kubectl patch svc prometheus-stack-grafana -n prometheus-stack --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"},{"op":"replace","path":"/spec/ports/0/nodePort","value":32071}]'
Connect
instance_public_ip="$(curl ifconfig.me --silent)"
echo "https://$instance_public_ip:32071"
echo "ID: admin"
echo "PW: " $(kubectl get secret --namespace prometheus-stack prometheus-stack-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo)

image

@taking
Copy link
Author

taking commented Jul 15, 2022

(Option) 멀티클러스터 시 thanos 수집

Prometheus 설치 후

cat <<'EOF' | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: prometheus-stack-kube-prom-thanos-discovery
  namespace: monitoring
spec:
  ports:
  - name: grpc
    port: 10901
    protocol: TCP
    nodePort: 32073
    targetPort: grpc
  - name: http
    port: 10902
    protocol: TCP
    targetPort: http
  selector:
    app.kubernetes.io/name: prometheus
    prometheus: prometheus-stack-kube-prom-prometheus
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}
EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment