Skip to content

Commit

Permalink
OCTOPUS-466: add the new intel nodes to the loadbalancers
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed Oct 20, 2023
1 parent ef79298 commit b1a370f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
34 changes: 34 additions & 0 deletions modules/7_post/files/update-lbs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
################################################################
# Copyright 2023 - IBM Corporation. All rights reserved
# SPDX-License-Identifier: Apache-2.0
################################################################

# The script updates the haproxy entries for the new intel nodes.

## Example
# backend ingress-http
# balance source
# server ZYZ-worker-0-http-router0 192.168.200.254:80 check
# server ZYZ-worker-1-http-router1 192.168.200.79:80 check
# server ZYZ-x86-worker-0-http-router2 10.245.0.45:80 check

# backend ingress-https
# balance source
# server ZYZ-worker-0-https-router0 192.168.200.254:443 check
# server ZYZ-worker-1-https-router1 192.168.200.79:443 check
# server ZYZ-x86-worker-0-http-router2 10.245.0.45:443 check

for INTEL_WORKER in $(oc get nodes -lkubernetes.io/arch=amd64 --no-headers=true -ojson | jq -c '.items[].status.addresses')
do
T_IP=$(echo "${INTEL_WORKER}" | jq -r '.[] | select(.type == "InternalIP").address')
T_HOSTNAME=$(echo "${INTEL_WORKER}" | jq -r '.[] | select(.type == "Hostname").address')
echo "FOUND: ${T_IP} ${T_HOSTNAME}"
HTTP_LN=$(grep -Rn -A3 'backend ingress-http$' /etc/haproxy/haproxy.cfg | grep 'server ' | head -n 1 | sed 's|-| |' | awk '{print $1}')
sed -i.bak "${HTTP_LN}i\
server ${T_HOSTNAME}-http-router0 ${T_IP}:80 check
" /etc/haproxy/haproxy.cfg
HTTPS_LN=$(grep -Rn -A3 'backend ingress-https$' /etc/haproxy/haproxy.cfg | grep 'server ' | head -n 1 | sed 's|-| |' | awk '{print $1}')
sed -i.bak "${HTTPS_LN}i\
server ${T_HOSTNAME}-https-router0 ${T_IP}:443 check
" /etc/haproxy/haproxy.cfg
done
32 changes: 32 additions & 0 deletions modules/7_post/post.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,38 @@ resource "null_resource" "patch_nfs_arch_ppc64le" {
provisioner "remote-exec" {
inline = [<<EOF
oc patch deployments nfs-client-provisioner -n nfs-provisioner -p '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/arch": "ppc64le"}}}}}'
EOF
]
}
}

resource "null_resource" "create_resolv_conf_for_intel_workers" {
depends_on = [null_resource.limit_csi_arch]
connection {
type = "ssh"
user = "root"
private_key = file(var.private_key_file)
host = var.bastion_public_ip
agent = var.ssh_agent
}

provisioner "remote-exec" {
inline = [<<EOF
mkdir -p /root/ocp4-upi-compute-powervs-ibmcloud/intel/lbs/
EOF
]
}

provisioner "file" {
source = "${path.module}/files/update-lbs.sh"
destination = "/root/ocp4-upi-compute-powervs-ibmcloud/intel/lbs/"
}

# Dev Note: Updates the load balancers
provisioner "remote-exec" {
inline = [<<EOF
cd /root/ocp4-upi-compute-powervs-ibmcloud/intel/lbs/
bash update-lbs.sh
EOF
]
}
Expand Down

0 comments on commit b1a370f

Please sign in to comment.