【发布时间】:2020-05-04 06:14:11
【问题描述】:
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>
【问题讨论】:
-
您是如何访问该服务的?总是使用相同的节点 ip 或不同的节点 ip?集群上有多少个工作节点?
-
我有 1 个工作节点,里面有 3 个 pod。
-
您如何访问该服务?使用节点 IP,
kubectl port-forward,还有别的吗?用什么客户端工具?您如何验证只有一个 pod 获得连接?
标签: docker kubernetes kubernetes-pod