|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# 11-fixup-ovn-lb.sh: Patch ccm-cloud-config secret to use ovn LB provider |
| 4 | +# |
| 5 | +# This is required to make the OCCM create octavia-ovn LBs for workloads. |
| 6 | +# This is a temporary solution. We should have a proper setting in cluster-settings.env |
| 7 | +# that gets passed down and is being consumed when the creaton of ccm-cloud-config |
| 8 | +# happens. |
| 9 | +# |
| 10 | +# (c) Kurt Garloff <s7n@garloff.de>, 7/2025 |
| 11 | +# SPDX-License-Identifier: CC-BY-SA-4.0 |
| 12 | +set -e |
| 13 | +THISDIR=$(dirname $0) |
| 14 | +# We need settings |
| 15 | +#unset KUBECONFIG |
| 16 | +if test -n "$1"; then |
| 17 | + SET="$1" |
| 18 | +else |
| 19 | + if test -e cluster-settings.env; then SET=cluster-settings.env; |
| 20 | + else echo "You need to pass a cluster-settings.env file as parameter"; exit 1 |
| 21 | + fi |
| 22 | +fi |
| 23 | +# Read settings -- make sure you can trust it |
| 24 | +source "$SET" |
| 25 | +# Do this on the workload cluster, ensure we have a config |
| 26 | +#clusterctl get kubeconfig -n $CS_NAMESPACE $CL_NAME > ~/.kube/$CS_NAMESPACE.$CL_NAME |
| 27 | +export KUBECONFIG=~/.kube/$CS_NAMESPACE.$CL_NAME |
| 28 | +CCONF_SECRET="$(kubectl get -n kube-system secrets ccm-cloud-config -o yaml)" |
| 29 | +CCONF=$(echo "$CCONF_SECRET" | grep '^\s*cloud.conf:' | sed 's/^\s*cloud.conf: //') |
| 30 | +NCCONF=$(LB=0; while read line; do |
| 31 | + if test $LB = 0; then echo "$line"; fi |
| 32 | + if test "$line" != "[LoadBalancer]" -a $LB = 0; then continue; fi |
| 33 | + if test "${line:0:1}" = "[" -a $LB = 1; then LB=0; echo "$line"; continue; fi |
| 34 | + if test "$line" = "[LoadBalancer]"; then LB=1; continue; fi |
| 35 | + # If we got here, we are in the Loadbalancer section |
| 36 | + if test -z "$line"; then echo -e "enabled = true\nlb-provider = ovn\nlb-method = SOURCE_IP_PORT\ncreate-monitor = true\n"; fi |
| 37 | + # Don't output anything else here |
| 38 | + done < <(echo "$CCONF" | base64 -d) | base64 -w0) |
| 39 | +NCONF_SECRET=$(while IFS="" read line; do |
| 40 | + if echo "$line" | grep '^\s*cloud.conf' >/dev/null 2>&1; then |
| 41 | + echo "$line" | sed "s/cloud.conf: .*\$/cloud.conf: $NCCONF/" |
| 42 | + else |
| 43 | + echo "$line" |
| 44 | + fi |
| 45 | + done < <(echo "$CCONF_SECRET")) |
| 46 | +# echo echo "$NCONF_SECRET" "| kubectl apply -f -" |
| 47 | +echo "$NCONF_SECRET" | kubectl apply -f - |
| 48 | +kubectl rollout restart -n kube-system daemonset openstack-cloud-controller-manager |
0 commit comments