Home > Mobile >  How to keep IP address of a pod static after pod dies
How to keep IP address of a pod static after pod dies

Time:10-11

I am new to learning kubernetes, and I understand that pods have dynamic IP and require some other "service" resource to be attached to a pod to use the fixed IP address. What service do I require and what is the process of configuration & How does AWS-ECR fit into all this.

So if I have to communicate from a container of a pod to google.com, Can I assume my source as the IP address of the "service", if I have to establish a connection?

CodePudding user response:

Well, for example on Azure, this feature [Feature Request] Pod Static IP is under request:

See https://github.com/Azure/AKS/issues/2189

Also, as I know, you can currently assign an existing IP adress to a load balancer service or an ingress controller

See https://learn.microsoft.com/en-us/azure/aks/static-ip

By default, the public IP address assigned to a load balancer resource created by an AKS cluster is only valid for the lifespan of that resource. If you delete the Kubernetes service, the associated load balancer and IP address are also deleted. If you want to assign a specific IP address or retain an IP address for redeployed Kubernetes services, you can create and use a static public IP address

CodePudding user response:

As you said we needs to define a service which selects all the required pods and then you would be sending requests to this service instead of the pods. I would suggest you to go through this https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types.

The type of service you need basically depends on the use-case. I will give a small overview so you get an idea.

  • Usually when pods only have internal requests ClusterIP is used
  • Node port allow external requests but is basically used for testing and not for production cases
  • If you also have requests coming from outside the cluster you would usually use load balancer
  • Then there is another option for ingress

As for AWS-ECR, its basically a container registry where you store your docker images and pull from it.

  • Related