kubernetes 如何调试KEDA+Prometheus自动缩放部署

oiopk7p5  于 2023-08-03  发布在  Kubernetes
关注(0)|答案(1)|浏览(122)

我有这个repo terraform1
我已经使用virtualbox创建了minikube(也可以使用docker,但是docker在我的机器上有很多问题,特别是网络部分)

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube start --driver=virtualbox

字符串
用prometheus指标构建了虚拟docker,并将其推送到我的docker hub:

docker login -u kokizzu 
docker build -t pf1 .
docker image ls pf1
# REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
# pf1          latest    204670ee86bd   2 minutes ago   89.3MB

docker image tag pf1 kokizzu/pf1:latest
docker image push kokizzu/pf1:latest


使minikube能够从docker注册表中拉取(需要docker登录)

minikube addons configure registry-creds
Do you want to enable AWS Elastic Container Registry? [y/n]: n
Do you want to enable Google Container Registry? [y/n]: n
Do you want to enable Docker Registry? [y/n]: y
-- Enter docker registry server url:
--Error, please enter a value:-- Enter docker registry server url: https://hub.docker.com/
-- Enter docker registry username: kokizzu
-- Enter docker registry password:
Do you want to enable Azure Container Registry? [y/n]: n
✅  registry-creds was successfully configured


然后,我使用terraform-kubernetesterraform-helm作为KEDA(因为hcl比yaml更容易引用变量,但yaml可以更好地进行继承)

terraform init
terraform apply


它正确地创建了pod,没有任何问题:

alias k='minikube kubectl --'
k get pods -w -n pf1ns                                                                                     130 ↵
NAME                                               READY   STATUS    RESTARTS  AGE
keda-admission-webhooks-78dcd76878-h797w           1/1     Running   0         17m
keda-operator-c76d89655-f2dc5                      1/1     Running   0         17m
keda-operator-metrics-apiserver-6cdcd87dfd-9gcts   1/1     Running   0         17m
pf1deploy-6657c4d485-q569h                         1/1     Running   0         27h
prom1stateful-0                                    1/1     Running   0         24h

minikube service list
|-------------|---------------------------------|--------------|-----------------------------|
|  NAMESPACE  |              NAME               | TARGET PORT  |             URL             |
|-------------|---------------------------------|--------------|-----------------------------|
| default     | kubernetes                      | No node port |                             |
| kube-system | kube-dns                        | No node port |                             |
| pf1ns       | keda-admission-webhooks         | No node port |                             |
| pf1ns       | keda-operator                   | No node port |                             |
| pf1ns       | keda-operator-metrics-apiserver | No node port |                             |
| pf1ns       | pf1svc                          |        33000 | http://192.168.59.100:31344 |
| pf1ns       | prom1svc                        |        10902 | http://192.168.59.100:30958 |
|-------------|---------------------------------|--------------|-----------------------------|


然后使用hey进行负载测试:

hey -c 100 -n 1000000 http://192.168.59.100:31344


prometheus上正确显示的请求地址是:


的数据
在keda pod上没有任何错误:

k logs -f keda-admission-webhooks-78dcd76878-h797w -n pf1ns
k logs -f keda-operator-metrics-apiserver-6cdcd87dfd-9gcts -n pf1ns 
k logs -f keda-operator-c76d89655-f2dc5 -n pf1ns
2023-06-27T21:59:10Z    INFO    Reconciling ScaledObject        {"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "ScaledObject": {"name":"pf1keda","namespace":"pf1ns"}, "namespace": "pf1ns", "name": "pf1keda", "reconcileID": "7409b0a1-5363-4813-99bf-bdcfd3101ee8"}


我应该做什么来调试自动缩放的哪个部分不起作用?(来自k get pods -w -n pf1ns在负载测试期间没有显示任何pod增加)

y0u0uwnf

y0u0uwnf1#

仍然不知道如何调试,但在我的情况下,由于没有错误消息,问题是prometheus查询是错误的,检查prometheus UI以确认查询是正确的。

相关问题