This project demonstrates how to set up a High Availability (HA) Kubernetes cluster using HAProxy as a load balancer. The setup is designed to run on EC2 instances with specific security group configurations.
High Availability in Kubernetes is crucial for maintaining continuous operations and minimizing downtime. Here's why it's important:
- Fault Tolerance: HA setups ensure that if one component fails, others can take over, preventing system-wide outages.
- Load Distribution: Multiple nodes allow for better distribution of workloads, improving overall performance.
- Scalability: HA clusters can easily scale to handle increased demand.
- Maintenance Without Downtime: Updates and maintenance can be performed on individual components without affecting the entire system.
HAProxy is used as the load balancer in this setup. It's responsible for:
- Distributing incoming traffic across multiple Kubernetes API servers.
- Providing a single entry point for accessing the Kubernetes cluster.
- Improving fault tolerance by redirecting traffic if one API server becomes unavailable.
- AWS account with EC2 instances set up
- Security group with necessary inbound rules configured
- Basic understanding of Kubernetes and Linux administration
Follow these steps to set up your HA Kubernetes cluster:
- Launch EC2 instances for HAProxy, master nodes, and worker nodes.
- Ensure all instances are in the same VPC and can communicate with each other.
- Configure security groups to allow necessary traffic between instances.
- Install HAProxy on the designated load balancer instance.
- Configure HAProxy to distribute traffic to Kubernetes API servers.
- Install Kubernetes components on master nodes.
- Initialize the first master node.
- Join additional master nodes to the cluster.
- Install Kubernetes components on worker nodes.
- Join worker nodes to the cluster.
- Check the status of nodes and pods to ensure proper setup.
For step-by-step instructions, please refer to the HA-k8-cluster.md file in this repository. It contains detailed commands and explanations for each step of the setup process.
Key configuration files are included in this repository:
haproxy.cfg
: HAProxy configuration filekubeadm-config.yaml
: Kubernetes cluster configuration
-
HAProxy Stat Page Dashboard Highlighting Master node 3 is down after master node 3 hosted ec2 instance is deleted
-
Website deployed is still running post the master node 3 is terminated
Common issues and their solutions will be added here based on user feedback and experiences.
Contributions to improve this setup or documentation are welcome. Please submit pull requests or open issues to discuss proposed changes.