Skip to content

Commit

Permalink
Interface substitution script
Browse files Browse the repository at this point in the history
Signed-off-by: Lazar Cvetković <[email protected]>
  • Loading branch information
cvetkovic committed Feb 19, 2024
1 parent e51049b commit 1aa123a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion configs/k8s_ha/keepalived_backup.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ vrrp_script check_apiserver {

vrrp_instance VI_1 {
state BACKUP
interface enp4s0f1
interface $INTERFACE_NAME
virtual_router_id 51
priority 101
authentication {
Expand Down
2 changes: 1 addition & 1 deletion configs/k8s_ha/keepalived_master.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ vrrp_script check_apiserver {

vrrp_instance VI_1 {
state MASTER
interface enp4s0f1
interface $INTERFACE_NAME
virtual_router_id 51
priority 101
authentication {
Expand Down
8 changes: 8 additions & 0 deletions configs/k8s_ha/substitute_interface.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

export INTERFACE_NAME=$(ifconfig | grep -B1 "10.0.1" | head -n1 | sed 's/:.*//')

cat keepalived_master.conf | envsubst > keepalived_master.conf
cat keepalived_backup.conf | envsubst > keepalived_backup.conf

echo "Successfully created HA load balancer configuration!"
5 changes: 5 additions & 0 deletions scripts/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ func SetupSystem(haMode string) error {
return err
}

_, err = utils.ExecVHiveBashScript("configs/k8s_ha/substitute_interface.sh")
if !utils.CheckErrorWithTagAndMsg(err, "Failed to create HA load balancer !\n") {
return err
}

if haMode == "MASTER" {
err = utils.CopyToDir(path.Join(k8s_ha_path, "keepalived_master.conf"), "/etc/keepalived/keepalived.conf", true)
if !utils.CheckErrorWithMsg(err, "Failed to copy files to /etc/keepalived/keepalived.conf!\n") {
Expand Down

0 comments on commit 1aa123a

Please sign in to comment.