简体   繁体   中英

kubernetes nodeport external ip not accessible

I have been trying to deploy the Spring Boot application on kubernetes cluseter. But somehow I can not access the rest end point from outside the cluster.

Here are the steps which i performed

  1. Setup the kubernetes cluster using kubespray following the guide - Kubernetes Cluster setup using Kubespray

  2. Pushed the spring boot docker image to docker hub

  3. Created kubernetes deployment

vagrant@node1:~/spring-boot$ kubectl create deployment demo --image=rahulwagh17/kubernetes:jhooq-k8s-springboot
deployment.apps/demo created
  1. Exposed the deployment with external IP = 1.1.1.1
kubectl expose deployment demo --type=LoadBalancer --name=demo-service --external-ip=1.1.1.1 --port=8080

service/demo-service exposed
  1. This is how my deployment is looking
vagrant@node1:~/spring-boot$ kubectl get deployment
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
demo   1/1     1            1           24s
  1. This is how my services are looking
vagrant@node1:~/spring-boot$ kubectl get service
NAME           TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
demo-service   LoadBalancer   10.233.31.159   1.1.1.1       8080:30099/TCP   13s
kubernetes     ClusterIP      10.233.0.1      <none>        443/TCP          23h
  1. I can curl the rest end point within the cluster without a problem
vagrant@node1:~/spring-boot$ curl 10.233.31.159:8080/hello
Hello - Jhooq-k8s

Problem I am facing - When i am trying to curl the rest point from outside the cluster, i can not do

$ curl http://1.1.1.1:30099/hello
curl: (7) Failed to connect to 1.1.1.1 port 30099: Operation timed out

I am little new to kubernetes, so any leads or suggestions are highly appreciated

Please try via below approach: Via Node Port :- Which means NodeIP:NodePort and in this case, please get any node-ip and then run a command

curl http://$NODE_IP:30099/hello

and you should be able to access your service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM