Reputation: 532
I have 3 node K8S cluster, I have created 3 replica pods on which application - app1 is running on all the pods, I have established service by running service yaml file and I can see my cluster-Ip created by running kubectl get service
When I try to do curl from one of the node I am getting " curl: (7) Failed to connect - failed to connect" when I try to curl inside the pod I am getting ... "command terminated with exit code 7"
Commands Ran:
kubectl run kubia --image=kubia --port=8080 --generator=run/v1
kubectl scale rc kubia --replicas=3
Manifest file used:
apiVersion: v1
kind: Service
metadata:
name: kubia
spec: ports:
- port: 80
targetPort: 8080.
selector: app: kubia
Can any body help me on this. Thanks
Upvotes: 4
Views: 17812
Reputation: 1
I am using 2 Node (+ Control Plane Node) Kubernetes cluster in my VirtualBox. All of the VMs that are the part of this cluster are running CentOS. I had the same error when i tried to hit my Service endpoint IP using curl command inside one of my pods that is running on worker nodes (command terminated with exit code 7).
Solution: Firewall was up and running, and the port 80 that Service is listening on was not open. After i changed firewall configuration to accept 80/TCP traffic on my Control Plane Node, the curl command from inside the container was able to hit the service IP.
Worker Node to Control plane Node request over 80/TCP was approved.
Upvotes: 0
Reputation: 532
Solution : In yaml file - selector should be run: kubia instead of app: kubia, deleted the old service and again created new service , I am able to do curl on the internal ip from the pod. Thanks.
Upvotes: 2