'Can not access deployed service on K8S cluster
I have a k8s cluster with one master node and three worker nodes. The cluster is working well; when I deploy my app on the master node, it will schedule the pod to one of the nodes. here is the YAML that I am using to deploy my app:
apiVersion: apps/v1
kind: Deployment
metadata:
name: s-deployment
labels:
app: s
spec:
replicas: 1
selector:
matchLabels:
app: s
template:
metadata:
labels:
app: s
spec:
containers:
- name: s
image: redis
imagePullPolicy: Always
ports:
- containerPort: 23
---
apiVersion: v1
kind: Service
metadata:
name: service
spec:
type: NodePort
selector:
app: s
ports:
- name: ans
protocol: TCP
port: 23
targetPort: 23
nodePort: 30100
the master sends the app pod to one of the worker nodes (for example, 192.168.10.222), and the master is on 192.168.10.221
However, I got the timed-out error when I tried to access the deployed app using postman (192.168.10.221:30100). If I use the worker's address:192.168.10.222:30100, everything is fine.
Am I missing something here?
Actually, I used to have one worker. After the master schedules the worker's app, I can access the app by using the master's address and the app's nodePort. The master can send the request to the right place. I add two more workers later, and I get the problem.
k8s :
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.3", GitCommit:"816c97ab8cff8a1c72eccca1026f7820e93e0d25", GitTreeState:"clean", BuildDate:"2022-01-25T21:25:17Z", GoVersion:"go1.17.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.4", GitCommit:"b695d79d4f967c403a96986f1750a35eb75e75f1", GitTreeState:"clean", BuildDate:"2021-11-17T15:42:41Z", GoVersion:"go1.16.10", Compiler:"gc", Platform:"linux/amd64"}
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
