[英]Kubernetes service does not distribute requests between pods
a Kubernetes 服務有問題。 我的服務只向一個 pod 發送請求,而忽略其他 pod。 我不知道為什么以及如何調試它。 它應該以循環方式分發請求。 對我來說,服務似乎出了點問題,但我不知道要調試它。 kubectl 的輸出描述服務和節點以及端點
apiVersion: v1
kind: Service
metadata:
name: web-svc
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 30002
selector:
app: web
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
labels:
app: web
spec:
selector:
matchLabels:
app: web
replicas: 3
template:
metadata:
labels:
app: web
spec:
containers:
- name: web-app
image: webimage
ports:
- containerPort: 80
imagePullPolicy: Never
resources:
limits:
cpu: "0.5"
requests:
cpu: "0.5"
Name: web-svc
Namespace: default
Labels: <none>
Annotations: Selector: app=webpod
Type: NodePort
IP: 10.111.23.112
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 30002/TCP
Endpoints: 10.244.1.7:80,10.244.1.8:80,10.244.1.9:80
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Name: kubernetes
Namespace: default
Labels: component=apiserver
provider=kubernetes
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP: 10.96.0.1
Port: https 443/TCP
TargetPort: 6443/TCP
Endpoints: 172.18.0.3:6443
Session Affinity: None
Events: <none>
Name: web-depl-5c87b748f-kvtqr
Namespace: default
Priority: 0
Node: kind-worker/172.18.0.2
Start Time: Mon, 04 May 2020 04:20:34 +0000
Labels: app=webpod
pod-template-hash=5c87b748f
Annotations: <none>
Status: Running
IP: 10.244.1.8
IPs:
IP: 10.244.1.8
Controlled By: ReplicaSet/web-depl-5c87b748f
Containers:
web:
Container ID: containerd://8b431d80fd729c8b0d7e16fa898ad860d1a223b3e191367a68e3b65e330fe61a
Image: web
Image ID: sha256:16a4c5d1a652b1accbacc75807abc1d9a05e2be38115dc8a5f369a04a439fad2
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Mon, 04 May 2020 04:20:36 +0000
Ready: True
Restart Count: 0
Limits:
cpu: 500m
Requests:
cpu: 500m
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-c9tgf (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-c9tgf:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-c9tgf
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events: <none>
=========
Name: iweblens-svc
Namespace: default
Labels: <none>
Annotations: endpoints.kubernetes.io/last-change-trigger-time: 2020-05-04T04:20:36Z
Subsets:
Addresses: 10.244.1.7,10.244.1.8,10.244.1.9
NotReadyAddresses: <none>
Ports:
Name Port Protocol
---- ---- --------
<unset> 80 TCP
Events: <none>
我強烈建議根據官方文檔調試您的服務:
對於 Kubernetes 的新安裝,經常出現的一個問題是服務無法正常工作。 您已經通過部署(或其他工作負載控制器)運行您的 Pod 並創建了一個服務,但是當您嘗試訪問它時沒有得到任何響應。 本文檔有望幫助您找出問題所在。
在那里,您將找到一個分步指南,顯示哪些以及如何檢查可能 go 錯誤的每個組件。 例如:
服務定義是否正確?
Pod 工作正常嗎?
kube-proxy 工作正常嗎?
Go 逐步完成,如果您找到解決方案,請告訴我。 如果問題仍然存在,我們可以深入研究以解決它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.