I am using Kubernetes Engine on the Google Cloud Platform. I have a pod running a process in a Docker scratch container. I also have a load balancer service that gives me access to the pod from the outside world.
The process running in the pod needs to know what its external IP address is. How can I get this?
Prior to using Kubernetes Engine I was using Compute Engine and could find the external IP address by the following:
curl -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip
Are there any internal tools I can use that would be available to my process? Or would I need the process to call an external site that can mirror back the IP address?
Type "cmd" in the search box in the Start Menu or taskbar and click the Command Prompt icon to open the Windows command prompt. Type "ipconfig" in the command prompt window and take note of the IP address displayed.
The nodes of an internet-facing load balancer have public IP addresses. The DNS name of an internet-facing load balancer is publicly resolvable to the public IP addresses of the nodes. Therefore, internet-facing load balancers can route requests from clients over the internet.
Create rules in Application Load Balancer to Deny the IP This is one more efficient way of blocking IP at the Elastic Load Balancer Level. Remember, This can be done only at the Application and network load balancer as Classic Load Balancer does not support the rules for processing.
Another important difference is that while LoadBalancers are provisioned automatically by Kubernetes if you're in a supported cloud environment, External IPs are manually provisioned by you, which might mean more or less flexibility, depending on your setup.
Every Pod (unless configured not to do so) has valid kubernetes credentials in /var/run/secrets/kubernetes.io/serviceaccount/token
as described here so the answer is to use the kubernetes API to ask the Service
in front of the Pod(s) for its status:loadBalancer:ingress:ip:
as described here which I have every reason to believe GKE will keep up-to-date with any changes to the load balancer. The kubernetes API is always(?) located at https://kubernetes
(that's normally enough, or https://kubernetes.default.svc.cluster.local
is its full name), so there should be very little configuration the Pod would need in order to carry out the lookup.
The asterisk to that response is that one must provide the name of the Service to the Pod(s) of the Service sitting in front of it, because (for the most part) there is no way for the Pod to know how many Services point to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With