Helm/Prometheus: Difference between revisions
Jump to navigation
Jump to search
Line 107: | Line 107: | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl -n prometheus | kubectl -n prometheus logs -f prometheus-server-5787759b8c-cmjlg | ||
kubectl -n prometheus | kubectl -n prometheus rollout restart deploy prometheus-server | ||
kubectl -n prometheus | kubectl -n prometheus logs -f prometheus-server-hash | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl - | kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten | ||
kubectl - | kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten | ||
kubectl - | kubectl config --kubeconfig=${HOME}/.kube/config view --flatten | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 125: | Line 125: | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl -n prometheus | kubectl -n prometheus delete all --all | ||
kubectl -n prometheus | kubectl -n prometheus delete ing --all | ||
kubectl -n prometheus | kubectl -n prometheus delete sts --all | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl | kubectl -n prometheus delete svc --all | ||
kubectl | kubectl -n prometheus delete pvc --all | ||
kubectl | kubectl -n prometheus delete pv --all | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 01:56, 2 July 2024
helm repo add prometheus https://prometheus-community.github.io/helm-charts helm repo update helm repo list
Config
export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"
Install
kubectl create namespace prometheus
helm show values prometheus/prometheus
cat <<YML | helm install -n prometheus prometheus prometheus/prometheus -f -
server:
ingress:
enabled: true
hosts:
- prometheus.k8s.local
YML
ConfigMap
cat <<-'YML' | kubectl -n prometheus apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-server-conf
namespace: prometheus
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'kubernetes-apiservers'
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: default;kubernetes;https
- job_name: 'kubernetes-nodes'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- target_label: __address__
replacement: kubernetes.default.svc:443
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /api/v1/nodes/${1}/proxy/metrics
- job_name: 'metrics-server'
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: kube-system;metrics-server;https
YML
kubectl -n prometheus get cm prometheus-server-conf -o yaml
Uninstall
helm uninstall -n prometheus prometheus
helm delete -n prometheus prometheus
Playground
helm upgrade --install -f values.yaml prometheus prometheus/prometheus
helm upgrade --install prometheus prometheus/prometheus
helm show values prometheus/prometheus
|
kubectl exec -n prometheus -it prometheus-server-5787759b8c-cmjlg -- cat /etc/config/prometheus.yml
kubectl exec -n prometheus -it prometheus-server-5787759b8c-cmjlg -- ls -lah /etc/config/
kubectl exec -n prometheus -it prometheus-server-5787759b8c-cmjlg -- /bin/sh
|
| |
kubectl -n prometheus logs -f prometheus-server-5787759b8c-cmjlg
kubectl -n prometheus rollout restart deploy prometheus-server
kubectl -n prometheus logs -f prometheus-server-hash
|
kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten
|
| |
kubectl -n prometheus delete all --all
kubectl -n prometheus delete ing --all
kubectl -n prometheus delete sts --all
|
kubectl -n prometheus delete svc --all
kubectl -n prometheus delete pvc --all
kubectl -n prometheus delete pv --all
|
| |
References
| ||
| ||