Kubernetes High Availability
Contents
High Availability in Kubernetes
HA in Kubernetes
In Kubernetes for high availability, you need load balancing system.
I refer to this official document
In this post, I focus on 2 master nodes.
Prerequisites
Prerequisites
I’m going to progress in Ubuntu 20.04.2 LTS based on VirtualBox.
keepalived
keepalived
The
keepalived provides a virtual IP that is in the same IP subnet for health check.Install keepalived
| |
Firewall Config
master01
| |
master02
| |
keepalived Config
Config
| |
Template
| |
| Value | Description | Example |
|---|---|---|
| ${STATE} | MASTER or BACKUP | MASTER |
| ${INTERFACE} | Network Interface | eth0 |
| ${ROUTER_ID} | It should be the same for all keepalived cluster hosts in the same subnet. | 51 |
| ${PRIORITY} | It should be higher on the MASTER than on the BACKUP | 110 |
| ${AUTH_PASS} | It should be the same for all keepalived cluster hosts. | pass1122 |
| ${APISERVER_VIP} | It is a virtual IP address negotiated between the keepalived cluster hosts. | 10.0.2.100 |
Example for master01
| |
Example for master02
| |
Track Script
| |
Template
| |
| Value | Description | Example |
|---|---|---|
| ${APISERVER_VIP} | It is the virtual IP address negotiated between the keepalived cluster hosts. | 10.0.2.100 |
| ${APISERVER_DEST_PORT} | The port through which Kubernetes will talk to the API Server | 1644 |
Example
| |
haproxy
haproxy
Tha
haproxy is simple stream-based load balancing.Install haproxy
| |
haproxy Config
Template
| |
| Value | Description | Example |
|---|---|---|
| ${APISERVER_DEST_PORT} | The port through which Kubernetes will talk to the API Server | 1644 |
| ${APISERVER_SRC_PORT} | The port used by the API Server instances | 6443 |
| ${HOST1_ID} | A symbolic name | master01 |
| ${HOST1_ADDRESS} | A resolvable address (DNS name, IP address) | 10.0.2.10 |
Example
| |
Enable haproxy and keepalived
| |
Test
IP Status on master01
| |
| |
IP Status on master02
| |
| |
Stop keepalived on master01
| |
IP Status on master01
| |
| |
IP Status on master02
| |
| |
CozyFex