patternkubernetesMinor
Kubernetes External Access Of A Single Pod
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:
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.
The solution according to the docs:
- Expose the deployment as a
NodePortservice.
get podsto find the name of the node running the pod.
get nodesto find the IP address of the named node.
- Open the
NodePortport 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
Any
Every node will forward traffic to that port to the
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.
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.