Assign a Static IP Address to a Kubernetes Service
In IONOS Managed Kubernetes, LoadBalancer
service creation does not provision an external load balancer. Instead, IONOS automatically reserves a static public IP address and assigns it as a secondary IP address to one of your worker nodes. This node acts as an ingress node, accepting incoming traffic and forwarding it to the correct pod using kube-proxy
.
Functionality of LoadBalancer
services in IONOS Managed Kubernetes
LoadBalancer
services in IONOS Managed KubernetesWhen a
LoadBalancer
service is created, IONOS either assigns an existing pre-reserved static IP address or automatically reserves a new one.This IP address is attached as a secondary IP address to one of the worker nodes in the cluster.
The designated ingress node handles incoming traffic.
If the target pod runs on a different node,
kube-proxy
routes the traffic to the correct destination.
Reserve a static IP address
You can obtain a static IP address in either of the following ways:
Pre-reserving a static IP address: You can manually reserve an IP address beforehand and reference it in your service manifest. This ensures that the IP address remains assigned even if the service is deleted.
Automatic Reservation: If you do not specify a
loadBalancerIP
, IONOS dynamically reserves an IP address. However, this IP address is released when the service is deleted.
Example: Deploy an echo server with a static IP address
To demonstrate the behavior of the IONOS LoadBalancer
service, we will deploy an echo server that returns request details useful for verifying traffic routing.
Deploy the echo server: The following deployment runs two instances of the echo server to demonstrate traffic forwarding:
Create the LoadBalancer
service: Use either of the following options to create a LoadBalancer
service:
Verify the Assigned Static IP Address: Check the assigned external IP address after service creation:
Result: The following is an example output where 85.215.190.220
is the static IP address assigned by IONOS:
Test the Echo Server: You can send a request to the assigned IP address to verify traffic routing:
Result: The following is an example response:
Summary
This setup ensures a stable external IP address for applications without requiring an additional load balancer.
IONOS reserves a static IP address for each
LoadBalancer
service.You can either pre-reserve an IP address or let IONOS assign one automatically.
The static IP address is attached to an ingress node and used to route traffic via
kube-proxy
.If you do not specify a
loadBalancerIP
, the IP address is automatically released when you delete the service.
Last updated
Was this helpful?