Kubernetes Virtual IP Exposure via Keepalived for High Availability
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing Kubernetes methods for external service exposure, such as nodeport, L7ingress, and L4 LoadBalancer, do not provide true high availability for multi-replica pods as they rely on DNS, which fails to detect anomalous pods and continues routing traffic to them until DNS corrects the traffic direction.
Innovation Solution
A method using keepalived to manage virtual IPs, where a mapping relationship between service resource labels and virtual IPs is established, allowing for load balancing and ensuring that traffic is redirected away from anomalous pods by monitoring and updating IP bindings in configuration files.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If DNS-based service exposure methods (nodeport, L7ingress, L4 LoadBalancer) are used, then service exposure is achieved, but high availability cannot be ensured because DNS fails to detect anomalous pods and continues routing traffic to them
Solution Approach 1:
The patent introduces keepalived as an intermediary component between the service exposure layer and the pods. Keepalived manages virtual IP addresses and monitors pod health status, acting as a mediator that redirects traffic away from anomalous pods while maintaining service availability. This resolves the contradiction by adding a dedicated monitoring and routing component that DNS alone cannot provide.
Solution Approach 2:
The patent implements a feedback mechanism where keepalived continuously monitors the health status of pods and dynamically adjusts traffic routing based on real-time pod conditions. When a pod is detected as anomalous, keepalived updates the virtual IP binding to exclude the faulty pod from receiving traffic, creating a closed-loop control system that ensures high availability while accurately detecting anomalies.
2Reliability
If virtual IP management with keepalived is implemented, then anomaly detection and traffic redirection capability is improved, but system complexity increases due to additional configuration files and monitoring mechanisms
Solution Approach 1:
The patent implements self-service mechanisms where the keepalived service automatically monitors pod health, detects anomalies, and updates virtual IP bindings without manual intervention. The system autonomously manages the complexity of configuration files and monitoring mechanisms, reducing the operational burden while maintaining enhanced reliability and anomaly detection capabilities.
Solution Approach 2:
The patent combines multiple functions into the keepalived component: virtual IP management, pod health monitoring, anomaly detection, and traffic routing control. By merging these previously separate functions into a single integrated service, the system reduces overall complexity while maintaining comprehensive anomaly detection and high availability capabilities.
Data Source
AI summary
Disclosed is a method for resource exposure in kubernetes, including: in response to receiving a request for applying for a service resource, judging whether a mapping relationship between a label corresponding to a type of the service resource and virtual IPs exists in a first configuration file of a keepalived service; in response to absence of the mapping relationship, acquiring new virtual IPs and establishing, in the first configuration file, a mapping relationship between the new virtual IPs and the label; and binding the virtual IPs corresponding to the label in the first configuration file to a plurality of pods corresponding to the service resource, so as to expose the plurality of the pods outside a kubernetes cluster by the virtual IP. Further disclosed are a system, a computer device and a readable storage medium.

