Helm/Prometheus: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
helm repo add prometheus https://prometheus-community.github.io/helm-charts | helm repo add prometheus https://prometheus-community.github.io/helm-charts | ||
helm repo update | helm repo update && helm repo list | ||
kubectl config get-contexts | |||
==Config== | ==Config== | ||
Line 13: | Line 13: | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
kubectl create namespace prometheus | kubectl create namespace prometheus | ||
helm show values prometheus/prometheus | helm show values prometheus/prometheus|less | ||
cat <<YML | helm install -n prometheus prometheus prometheus/prometheus -f - | cat <<YML | helm install -n prometheus prometheus prometheus/prometheus -f - | ||
server: | server: | ||
Line 20: | Line 20: | ||
hosts: | hosts: | ||
- prometheus.k8s.local | - prometheus.k8s.local | ||
tls: | |||
- secretName: prometheus.k8s.local.tls | |||
hosts: | |||
- prometheus.k8s.local | |||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 87: | Line 91: | ||
==Playground== | ==Playground== | ||
{| | {| | ||
| valign="top" colspan="2" | | |||
<syntaxhighlight lang="bash"> | |||
PROMETHEUS_PUSH_POD_NAME="$(kubectl -n prometheus get pod -l 'app.kubernetes.io/name=prometheus-pushgateway' -o json|jq -r '.items[0].metadata.name')" | |||
PROMETHEUS_STATE_POD_NAME="$(kubectl -n prometheus get pod -l 'app.kubernetes.io/name=kube-state-metrics' -o json|jq -r '.items[0].metadata.name')" | |||
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"> | ||
helm upgrade --install -f values.yaml prometheus prometheus/prometheus | helm upgrade --install -f values.yaml prometheus prometheus/prometheus | ||
helm upgrade --install prometheus prometheus/prometheus | helm upgrade --install prometheus prometheus/prometheus | ||
helm show values prometheus/prometheus | helm show values prometheus/prometheus|less | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| 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 122: | ||
| 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 | ||
Line 131: | Line 146: | ||
| valign="top" | | | valign="top" | | ||
prometheus-prometheus-pushgateway.prometheus.svc.cluster.local:9091 | |||
prometheus-alertmanager.prometheus.svc.cluster.local | |||
prometheus-server.prometheus.svc.cluster.local | |||
|- | |- | ||
Line 165: | Line 183: | ||
* [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>] | ||
* [https://github.com/prometheus-community/helm-charts Helm » Prometheus » GitHub] | * [https://github.com/prometheus-community/helm-charts Helm » Prometheus » GitHub] | ||
* [[Helm/Prometheus Stack|Helm » Prometheus Stack]] | |||
* [[Helm/Cert Manager|Helm » Cert Manager]] | |||
* [https://artifacthub.io/packages/helm/prometheus-community/prometheus Helm » Prometheus] | * [https://artifacthub.io/packages/helm/prometheus-community/prometheus Helm » Prometheus] | ||
* [[Helm]] | * [[Helm]] | ||
Line 210: | Line 230: | ||
| valign="top" | | | valign="top" | | ||
* [[K8s/CSI Hostpath Driver|K8s » CSI Hostpath Driver]] | |||
| valign="top" | | | valign="top" | | ||
|} | |} |
Latest revision as of 12:14, 22 August 2024
helm repo add prometheus https://prometheus-community.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 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
tls:
- secretName: prometheus.k8s.local.tls
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_PUSH_POD_NAME="$(kubectl -n prometheus get pod -l 'app.kubernetes.io/name=prometheus-pushgateway' -o json|jq -r '.items[0].metadata.name')"
PROMETHEUS_STATE_POD_NAME="$(kubectl -n prometheus get pod -l 'app.kubernetes.io/name=kube-state-metrics' -o json|jq -r '.items[0].metadata.name')"
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
| ||
| ||