@@ -10,6 +10,8 @@ set -euoE pipefail ## -E option will cause functions to inherit trap
1010. /usr/local/bin/bootstrap-cluster-gather.sh
1111# shellcheck source=bootstrap-verify-api-server-urls.sh
1212. /usr/local/bin/bootstrap-verify-api-server-urls.sh
13+ # shellcheck source=konnectivity.sh.template
14+ . /usr/local/bin/konnectivity.sh
1315
1416mkdir --parents /etc/kubernetes/{manifests,bootstrap-configs,bootstrap-manifests}
1517
@@ -19,6 +21,12 @@ BOOTSTRAP_INPLACE=true
1921BOOTSTRAP_INPLACE=false
2022{{ end -}}
2123
24+ {{- if .KonnectivityEnabled }}
25+ KONNECTIVITY_ENABLED=true
26+ {{- else }}
27+ KONNECTIVITY_ENABLED=false
28+ {{- end }}
29+
2230ETCD_ENDPOINTS=
2331
2432bootkube_podman_run () {
@@ -66,7 +74,6 @@ OPENSHIFT_HYPERKUBE_IMAGE=$(image_for hyperkube)
6674OPENSHIFT_CLUSTER_POLICY_IMAGE=$( image_for cluster-policy-controller)
6775
6876CLUSTER_BOOTSTRAP_IMAGE=$( image_for cluster-bootstrap)
69- KONNECTIVITY_IMAGE=$( image_for apiserver-network-proxy)
7077
7178mkdir --parents ./{bootstrap-manifests,manifests}
7279
@@ -246,36 +253,7 @@ then
246253 record_service_stage_success
247254fi
248255
249- # Detect bootstrap node IP at runtime using the default route source address
250- # This is needed for Konnectivity agents to connect back to the bootstrap server.
251- {{- if .UseIPv6ForNodeIP }}
252- BOOTSTRAP_NODE_IP=$( ip -6 -j route get 2001:4860:4860::8888 | jq -r ' .[0].prefsrc' )
253- {{- else }}
254- BOOTSTRAP_NODE_IP=$( ip -j route get 1.1.1.1 | jq -r ' .[0].prefsrc' )
255- {{- end }}
256- echo " Detected bootstrap node IP: ${BOOTSTRAP_NODE_IP} "
257-
258- # Generate Konnectivity certificates (self-signed CA, server cert, agent cert)
259- if [ ! -f konnectivity-certs.done ]
260- then
261- record_service_stage_start " konnectivity-certs"
262- /usr/local/bin/konnectivity-certs.sh " ${BOOTSTRAP_NODE_IP} "
263- touch konnectivity-certs.done
264- record_service_stage_success
265- fi
266-
267- # Create Konnectivity server static pod manifest.
268- # This runs on the bootstrap node and provides a proxy for the bootstrap KAS
269- # to reach webhooks in the cluster's pod network.
270- if [ ! -f konnectivity-server-bootstrap.done ]
271- then
272- record_service_stage_start " konnectivity-server-bootstrap"
273- echo " Creating Konnectivity server static pod manifest..."
274- export KONNECTIVITY_IMAGE
275- envsubst < /opt/openshift/konnectivity-server-pod.yaml > /etc/kubernetes/manifests/konnectivity-server-pod.yaml
276- touch konnectivity-server-bootstrap.done
277- record_service_stage_success
278- fi
256+ konnectivity_setup
279257
280258if [ ! -f kube-apiserver-bootstrap.done ]
281259then
305283 --config-override-files=/assets/konnectivity-config-override.yaml
306284
307285 cp kube-apiserver-bootstrap/config /etc/kubernetes/bootstrap-configs/kube-apiserver-config.yaml
308- # Copy egress selector config to bootstrap-configs where KAS can read it
309- cp /opt/openshift/egress-selector-config.yaml /etc/kubernetes/bootstrap-configs/egress-selector-config.yaml
286+ if [ " ${KONNECTIVITY_ENABLED} " = " true" ]; then
287+ cp /opt/openshift/egress-selector-config.yaml /etc/kubernetes/bootstrap-configs/egress-selector-config.yaml
288+ fi
310289 cp kube-apiserver-bootstrap/bootstrap-manifests/* bootstrap-manifests/
311290 cp kube-apiserver-bootstrap/manifests/* manifests/
312291
@@ -601,31 +580,7 @@ then
601580 record_service_stage_success
602581fi
603582
604- # Create Konnectivity agent manifests for cluster deployment.
605- # The namespace, secret, and daemonset templates live as separate files
606- # under /opt/openshift/ and are populated with runtime values here.
607- if [ ! -f konnectivity-agent-manifest.done ]
608- then
609- record_service_stage_start " konnectivity-agent-manifest"
610- echo " Creating Konnectivity agent manifests..."
611-
612- KONNECTIVITY_CERT_DIR=/opt/openshift/tls/konnectivity
613-
614- # Namespace
615- cp /opt/openshift/konnectivity-namespace.yaml manifests/konnectivity-namespace.yaml
616-
617- # Agent certs secret (export base64-encoded cert data for envsubst)
618- export KONNECTIVITY_AGENT_CERT_BASE64=$( base64 -w0 " ${KONNECTIVITY_CERT_DIR} /agent.crt" )
619- export KONNECTIVITY_AGENT_KEY_BASE64=$( base64 -w0 " ${KONNECTIVITY_CERT_DIR} /agent.key" )
620- export KONNECTIVITY_CA_CERT_BASE64=$( base64 -w0 " ${KONNECTIVITY_CERT_DIR} /ca.crt" )
621- envsubst < /opt/openshift/konnectivity-agent-certs-secret.yaml > manifests/konnectivity-agent-certs.yaml
622-
623- export BOOTSTRAP_NODE_IP
624- envsubst < /opt/openshift/konnectivity-agent-daemonset.yaml > manifests/konnectivity-agent-daemonset.yaml
625-
626- touch konnectivity-agent-manifest.done
627- record_service_stage_success
628- fi
583+ konnectivity_manifests
629584
630585REQUIRED_PODS=" openshift-kube-apiserver/kube-apiserver,openshift-kube-scheduler/openshift-kube-scheduler,openshift-kube-controller-manager/kube-controller-manager,openshift-cluster-version/cluster-version-operator"
631586if [ " $BOOTSTRAP_INPLACE " = true ]
@@ -712,18 +667,7 @@ if [ ! -f api-int-dns-check.done ]; then
712667 fi
713668fi
714669
715- # Clean up bootstrap konnectivity resources by deleting the namespace.
716- # This cascades to all resources (DaemonSet, Secret) within it.
717- if [ ! -f konnectivity-cleanup.done ]; then
718- record_service_stage_start " konnectivity-cleanup"
719- echo " Cleaning up bootstrap konnectivity resources..."
720- oc delete namespace openshift-bootstrap-konnectivity \
721- --kubeconfig=/opt/openshift/auth/kubeconfig \
722- --ignore-not-found=true || true
723- rm -f /etc/kubernetes/manifests/konnectivity-server-pod.yaml
724- touch konnectivity-cleanup.done
725- record_service_stage_success
726- fi
670+ konnectivity_cleanup
727671
728672# Workaround for https://github.com/opencontainers/runc/pull/1807
729673touch /opt/openshift/.bootkube.done
0 commit comments