Reputation: 14028
I've deployed a Kubernetes cluster on AWS using kops
and I'm able to expose my pods using a service with --type=LoadBalancer
:
kubectl run sample-nginx --image=nginx --replicas=2 --port=80
kubectl expose deployment sample-nginx --port=80 --type=LoadBalancer
However, I cannot get it to work by specifying service.spec.externalIPs
with the public IP of my master node.
I've allowed ingress traffic the specified port and used https://kubernetes.io/docs/concepts/services-networking/service/#external-ips as documentation.
Can anyone clarify how to expose a service on AWS without using the cloud provider's native load balancer?
Upvotes: 0
Views: 393
Reputation: 6853
If you want to avoid using Loadbalancer
then you case use NodePort
type of service.
NodePort
exposes service on each Node’s IP at a static port (the NodePort
).
ClusterIP
service that NodePort
service routes is created along. You will be able to reach the NodePort
service, from outside by requesting:
<NodeIP>:<NodePort>
That means that if you access any node with that port you will be able to reach your service. It worth to remember that NodePorts are high-numbered ports (30 000 - 32767)
Coming back specifically to AWS here is theirs official document how to expose a services along with NodePort
explained.
Do note very important inforamation there about enabling the ports:
Note: Before you access NodeIP:NodePort from an outside cluster, you must enable the security group of the nodes to allow incoming traffic through your service port.
Let me know if this helps.
Upvotes: 0