HiveBrain v1.2.0
Get Started
← Back to all entries
patternkubernetesMinor

Kubernetes External Access Of A Single Pod

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
kubernetessingleexternalpodaccess

Problem

I am running a kubernetes cluster in AWS. I have 2 nodes. I have one pod that should be accessible externally. The problem is, that pod can be on either node.

The solution according to the docs:

  • Expose the deployment as a NodePort service.



  • get pods to find the name of the node running the pod.



  • get nodes to find the IP address of the named node.



  • Open the NodePort port through EC2 Security Group.



The problem here is that this pod could be restarted/switch nodes, I think? At that point the application will be unavailable by the previous node IP address.

How can I make sure an application is always available, even if this specific pod switches nodes during a restart/etc?

Note: I definitely only want one of this specific pod. I do not want replicas.

Solution

The NodePort will resolve correctly, no matter the node where the pods is (even if it gets rescheduled on a different node).

Any : will resolve to a Service type NodePort, no matter what node the pods are running.

Every node will forward traffic to that port to the Service.

You need to be on the same network (or create a SSH tunnel) or open that port in one of your nodes to the world.

Context

StackExchange DevOps Q#2468, answer score: 3

Revisions (0)

No revisions yet.