27
loading...
This website collects cookies to deliver better user experience
kubectl create namespace monitoring
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring --set grafana.service.type=NodePort --set prometheus.service.type=NodePort
~$ kubectl get deployments -n monitoring
NAME READY UP-TO-DATE AVAILABLE AGE
prometheus-grafana 1/1 1 1 19h
prometheus-kube-prometheus-operator 1/1 1 1 19h
prometheus-kube-state-metrics 1/1 1 1 19h
customValues.yaml
, pois nele iremos configurar a url para nosso prometheus e configuração adicional para obter métricas requisições por segundo que iremos utilizar logo mais a frente.prometheus:
url: "http://prometheus-kube-prometheus-prometheus"
rules:
custom:
- seriesQuery: '{container!="POD",namespace!="",pod!=""}'
resources:
template: <<.Resource>>
name:
matches: "^(.*)_seconds_count"
as: "${1}_per_second"
metricsQuery: (sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>))
helm install prometheus-adapter prometheus-community/prometheus-adapter -n monitoring -f customValues.yaml
chart/
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── hpa.yaml
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── serviceaccount.yaml
│ ├── servicemonitor.yaml
│ └── service.yaml
└── values.yaml
servicemonitor.yaml
é responsável por definir a captura de metricas do serviço, que no nosso caso é no path /actuator/prometheus
.gradle bootBuildImage
spring-auto-scaling:0.0.1
, feito isso poderemos agora intalar nosso chart no cluster.helm install article chart/
~$ kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
article-spring-auto-scaling Deployment/article-spring-auto-scaling 418m/1 1 5 1 65m
kubectl run -i --tty load-generator --rm --image=busybox --restart=Never -- /bin/sh -c "while sleep 0.1; do wget -q -O- http://article-spring-auto-scaling/users/latest; done"
kubectl describe hpa article-spring-auto-scaling
27