By Purnima Kumari and Anish Singh Walia
The main purpose of the Static Routes Operator is to offer greater flexibility and control over network traffic within your Kubernetes environment. It enables you to tailor the routing configuration to meet your application requirements and optimize network performance. It is deployed as a DaemonSet; hence, it will run on each node of your DigitalOcean Managed Kubernetes cluster.
In this tutorial, you will learn to manage the routing table of each worker node based on the CRD spec and set up a failing over gateway.
The main goal of this tutorial is to demonstrate how to manage the routing table of each worker node based on the CRD spec and Set up a failing over gateway.
Working DigitalOcean Managed Kubernetes cluster you have access to.
Kubectl CLI installed on your local machine (configured to point to your DigitalOcean Managed Kubernetes cluster)
NAT GW Droplets (2 or above) configured and running as detailed here.
Create a system to detect failures in a gateway Droplet that fits the user’s needs and ensures clear and accurate detection with minimal false alarms. Use monitoring services like Prometheus or Nagios, set up health check endpoints on the Droplet, or alerting tools like Alertmanager for notifications. For this purpose, you can use a monitoring stack from our marketplace.
Note: Ensure your NAT Gateway Droplet is created in the same VPC as your Kubernetes cluster.
Below is the architectural Diagram:
Deploy the latest release of the static routes operator to your DigitalOcean Managed Kubernetes cluster using kubectl
:
Note: You can check the latest version in the releases path from the k8s-staticroute-operator GitHub repo.
Let’s verify if the operator pods are up and running.
The output looks similar to the below:
Now let’s check the operator logs and no exceptions should be reported
You should observe the following output:
To mitigate the impact of gateway failures, it is advisable to have a standby gateway Droplet prepared for failover when required. Although true high availability (HA) is not supported by the operator at the moment, performing failover helps minimize the duration of service disruption.
Note: Considering all operator instances are up and running correctly at the time of the failover.
Suppose you have a designated destination IP address, 34.160.111.145
, which represents the active or primary gateway, with an IP address of 10.116.0.4
, responsible for transmitting traffic. This is stored in the primary.yaml
file.
Additionally, you will have a standby or secondary gateway with an IP address of 10.116.0.12
, ready to handle traffic for the same destination IP address. The StaticRoute definition in secondary.yaml
is identical to the primary one, except for the gateway IP address (and object name). This is stored in the file secondary.yaml
.
The actual failover procedure then consists of the following steps:
10.116.0.5
is failing.StaticRoute
.StaticRoute
.Now let’s delete the currently active StaticRoute
.
Wait 30 to 60 seconds to give each operator instance enough time to process the object deletion; that is, respond by removing the route from all nodes.
Let’s make the secondary StaticRoute
active.
The operator should pick up the new standby StaticRoute
and enter the corresponding routing table entries. Afterward, the failover is completed.
Note: Please avoid modifying an existing StaticRoute
by directly updating the gateway IP address using commands like kubectl edit staticroute primary
to modify only the spec.gateway
field. This operation is currently unsupported and may result in failures.
Each sample CRD creates a static route to two websites reporting your public IP - ifconfig.me/ip
, and ipinfo.io/ip
. A typical static route definition looks like the below:
To test the setup, download a sample manifest from the example location:
Example for ifconfig.me
& ipinfo.io
-
After downloading the manifests, replace each manifest file’s <>
placeholders. Then, apply each manifest using kubectl
:
Finally, test if the curl-test pod replies to your NAT Gateway public IP for each route:
You would need to use the same test during the failover testing. During the primary gateway Droplet failure, the result should give NAT GW public IP of the primary Droplet and during the secondary gateway Droplet/failover. The result should give NAT Gateway’s public IP of the secondary Droplet.
StaticRoute
object: If an error occurs, first look for errors in the static route event for each node where the rule is applied.To remove the operator and associated resources, please run the following kubectl
command (make sure you’re using the same release version as in the install step):
Note: Above command will also delete the associated namespace (static-routes). Make sure to back up your CRDs first, if needed later.
The output looks similar to:
Now, if you test the same curl
command, you will get the worker node IP as an output:
Now check the worker node’s public IP:
Implementing failover capabilities, even if true high availability (HA) is not fully supported, is a recommended approach to minimize the impact of gateway failures.
Organizations can significantly reduce the duration of service disruptions by having a standby gateway ready for failover when needed.
It is important to prepare a standby gateway droplet and ensure a smooth transition when failing over. While the implementation may vary depending on specific requirements, prioritizing failover readiness can contribute to maintaining reliable and uninterrupted service delivery.
You can refer to our documentation to configure Droplet as a gateway.
Our official Managed Kubernetes product documentation provides more information on the DigitalOcean Managed Kubernetes and its features.
You can contact our sales team to migrate to DigitalOcean or talk to our Solution Engineers.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!