-
Notifications
You must be signed in to change notification settings - Fork 100
K8s control plane high-availability mode #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cvetkovic
wants to merge
7
commits into
main
Choose a base branch
from
k8s_ha_mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fa014a2
Control plane replication
cvetkovic b00bdc7
Keepalived health script install bugfix
cvetkovic b9b62b8
Interface substitution script
cvetkovic b91ec0f
Kubeadm fix with VRRP
cvetkovic 71ca4be
Disabling manual kubelet startup
cvetkovic c9a464e
Fixing bugs
cvetkovic a167a9a
Addressing Leonid's comments
cvetkovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
errorExit() { | ||
echo "*** $*" 1>&2 | ||
exit 1 | ||
} | ||
|
||
curl --silent --max-time 2 --insecure https://localhost:6443/ -o /dev/null || errorExit "Error GET https://localhost:6443/" | ||
if ip addr | grep -q 10.0.1.254; then | ||
curl --silent --max-time 2 --insecure https://10.0.1.254:6443/ -o /dev/null || errorExit "Error GET https://10.0.1.254:6443/" | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# /etc/haproxy/haproxy.cfg | ||
#--------------------------------------------------------------------- | ||
# Global settings | ||
#--------------------------------------------------------------------- | ||
global | ||
log /dev/log local0 | ||
log /dev/log local1 notice | ||
daemon | ||
|
||
#--------------------------------------------------------------------- | ||
# common defaults that all the 'listen' and 'backend' sections will | ||
# use if not designated in their block | ||
#--------------------------------------------------------------------- | ||
defaults | ||
mode http | ||
log global | ||
option httplog | ||
option dontlognull | ||
option http-server-close | ||
option forwardfor except 127.0.0.0/8 | ||
option redispatch | ||
retries 1 | ||
timeout http-request 10s | ||
timeout queue 20s | ||
timeout connect 5s | ||
timeout client 20s | ||
timeout server 20s | ||
timeout http-keep-alive 10s | ||
timeout check 10s | ||
|
||
#--------------------------------------------------------------------- | ||
# apiserver frontend which proxys to the control plane nodes | ||
#--------------------------------------------------------------------- | ||
frontend apiserver | ||
bind *:6443 | ||
mode tcp | ||
option tcplog | ||
default_backend apiserverbackend | ||
|
||
#--------------------------------------------------------------------- | ||
# round robin balancing for apiserver | ||
#--------------------------------------------------------------------- | ||
backend apiserverbackend | ||
option httpchk GET /healthz | ||
http-check expect status 200 | ||
mode tcp | ||
option ssl-hello-chk | ||
balance roundrobin | ||
server control_plane_1 10.0.1.1:6443 check | ||
server control_plane_2 10.0.1.2:6443 check | ||
server control_plane_3 10.0.1.3:6443 check | ||
server control_plane_4 10.0.1.4:6443 check | ||
server control_plane_5 10.0.1.5:6443 check | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! /etc/keepalived/keepalived.conf | ||
! Configuration File for keepalived | ||
global_defs { | ||
router_id LVS_DEVEL | ||
} | ||
vrrp_script check_apiserver { | ||
script "/etc/keepalived/check_apiserver.sh" | ||
interval 3 | ||
weight -2 | ||
fall 10 | ||
rise 2 | ||
} | ||
|
||
vrrp_instance VI_1 { | ||
state BACKUP | ||
interface $INTERFACE_NAME | ||
virtual_router_id 51 | ||
priority 100 | ||
authentication { | ||
auth_type PASS | ||
auth_pass 42 | ||
} | ||
virtual_ipaddress { | ||
10.0.1.254 | ||
} | ||
track_script { | ||
check_apiserver | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! /etc/keepalived/keepalived.conf | ||
! Configuration File for keepalived | ||
global_defs { | ||
router_id LVS_DEVEL | ||
} | ||
vrrp_script check_apiserver { | ||
script "/etc/keepalived/check_apiserver.sh" | ||
interval 3 | ||
weight -2 | ||
fall 10 | ||
rise 2 | ||
} | ||
|
||
vrrp_instance VI_1 { | ||
state MASTER | ||
interface $INTERFACE_NAME | ||
virtual_router_id 51 | ||
priority 101 | ||
authentication { | ||
auth_type PASS | ||
auth_pass 42 | ||
} | ||
virtual_ipaddress { | ||
10.0.1.254 | ||
} | ||
track_script { | ||
check_apiserver | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
|
||
export INTERFACE_NAME=$(ifconfig | grep -B1 "10.0.1" | head -n1 | sed 's/:.*//') | ||
|
||
cat $DIR/keepalived_master.conf | envsubst > $DIR/keepalived_master.conff | ||
cat $DIR/keepalived_backup.conf | envsubst > $DIR/keepalived_backup.conff | ||
|
||
echo "Successfully created HA load balancer configuration!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.