0

I'm learning k8s & nodePort

  1. made 1 master node & 1 worker node at AWS EC2
  2. installed k8s, kubeadm
  3. Use flannel CNI
  4. deployed a nodejs app. with port 3000
  5. Attach a nodePort to nodejs app. so, 3000:31000
  6. I expected that i access to that nodejs app outside ec2 with url : "[master-node-pub-ip]:31000"
  7. But i can't access to "[master-node-pub-ip]:31000" and can access with "[worker-node-pub-ip]:31000"

I don't know what did i wrong...

How can i access that nodejs app via master nodes ip??

Thank you.

mecha kucha
  • 111
  • 1
  • 2
  • 10
  • 1
    This is expected behavior. The master nodes manage the cluster, they are not the ingress point for service trafic. – jordanm Mar 27 '22 at 15:35
  • you should expose your service by using ingress controller from the edge node. it is not a good practice by using ip to access your service. If you just want to access it from outside the kubernetes, you can use kube-proxy and access the pod with service ip.@mecha kucha – Dolphin Mar 27 '22 at 16:12
  • thanks!! i understood!! – mecha kucha Mar 28 '22 at 11:19

1 Answers1

2

Try to install an ingress controller

I prefer the helm way:

helm repo add nginx-stable https://helm.nginx.com/stable
helm repo update
helm install nginx-ingress nginx-stable/nginx-ingress --set rbac.create=true

Then you can access to you nodepert via the node public IP.

  • can you give an example for me?? i tried your comment, but it not works. EXTERNERL-IP of nginx-ingress is pending and can't access to my service with ingress – mecha kucha Mar 31 '22 at 02:26