Helm/Prometheus: Difference between revisions
Jump to navigation
Jump to search
Line 87: | Line 87: | ||
==Playground== | ==Playground== | ||
{| | {| | ||
| valign="top" colspan="2" | | |||
<syntaxhighlight lang="bash"> | |||
PROMETHEUS_POD_NAME="$(kubectl -n prometheus get pod -l 'app.kubernetes.io/name=prometheus' -o json|jq -r '.items[0].metadata.name')" | |||
</syntaxhighlight> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 96: | Line 105: | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl -n prometheus exec -it | kubectl -n prometheus exec -it ${PROMETHEUS_POD_NAME} -- cat /etc/config/prometheus.yml | ||
kubectl -n prometheus exec -it | kubectl -n prometheus exec -it ${PROMETHEUS_POD_NAME} -- ls -lah /etc/config/ | ||
kubectl -n prometheus exec -it | kubectl -n prometheus exec -it ${PROMETHEUS_POD_NAME} -- /bin/sh | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 107: | Line 116: | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl -n prometheus logs -f | kubectl -n prometheus logs -f ${PROMETHEUS_POD_NAME} | ||
kubectl -n prometheus rollout restart deploy prometheus-server | kubectl -n prometheus rollout restart deploy prometheus-server | ||
kubectl -n prometheus logs -f prometheus-server-hash | kubectl -n prometheus logs -f prometheus-server-hash |
Revision as of 04:08, 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|less
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
PROMETHEUS_POD_NAME="$(kubectl -n prometheus get pod -l 'app.kubernetes.io/name=prometheus' -o json|jq -r '.items[0].metadata.name')"
| |
| |
helm upgrade --install -f values.yaml prometheus prometheus/prometheus
helm upgrade --install prometheus prometheus/prometheus
helm show values prometheus/prometheus|less
|
kubectl -n prometheus exec -it ${PROMETHEUS_POD_NAME} -- cat /etc/config/prometheus.yml
kubectl -n prometheus exec -it ${PROMETHEUS_POD_NAME} -- ls -lah /etc/config/
kubectl -n prometheus exec -it ${PROMETHEUS_POD_NAME} -- /bin/sh
|
| |
kubectl -n prometheus logs -f ${PROMETHEUS_POD_NAME}
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 get cm prometheus-server-conf -o yaml
kubectl -n prometheus edit deploy prometheus-server -o yaml
kubectl -n prometheus get deploy prometheus-server -o yaml
|
prometheus-prometheus-pushgateway.prometheus.svc.cluster.local:9091 prometheus-alertmanager.prometheus.svc.cluster.local prometheus-server.prometheus.svc.cluster.local |
| |
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
| ||
| ||