Skip to content

Commit ed52ad3

Browse files
committed
Add SETUP_KONNECTIVITY_SERVICE flag
1 parent 7820b05 commit ed52ad3

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

cluster/gce/config-default.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,15 @@ WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSche
518518
export GCE_PRIVATE_CLUSTER="${KUBE_GCE_PRIVATE_CLUSTER:-false}"
519519
export GCE_PRIVATE_CLUSTER_PORTS_PER_VM="${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-}"
520520

521-
# When KUBE_ENABLE_KONNECTIVITY_SERVICE is enabled, the two variables below will
521+
# When KUBE_ENABLE_KONNECTIVITY_SERVICE is enabled, the three variables below will
522522
# will default to true to enable the konnectivity network proxy and start the required pods.
523523
# Their values can be overridden for more granular control of the proxy.
524524

525+
# Optional: Whether to do the setup for the konnectivity service
526+
# Includes setting up kubeconfig, tokens, egress files, and firewall rules
527+
export SETUP_KONNECTIVITY_SERVICE="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
525528
# Optional: Whether to use konnectivity network proxy for all egress from apiserver.
526-
export EGRESS_VIA_KONNECTIVITY_SERVICE="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
529+
export EGRESS_VIA_KONNECTIVITY="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
527530
# Optional: Whether to start the konnectivity server and agent pods.
528531
export RUN_KONNECTIVITY_SERVICE_PODS="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
529532
# Proxy Protocol Mode determines the protocol to use to communicate between apiserver and network proxy.

cluster/gce/gci/configure-helper.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ contexts:
922922
name: webhook
923923
EOF
924924
fi
925-
if [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
925+
if [[ "${SETUP_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
926926
if [[ "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}" == 'grpc' ]]; then
927927
cat <<EOF >/etc/srv/kubernetes/egress_selector_configuration.yaml
928928
apiVersion: apiserver.k8s.io/v1beta1
@@ -3028,7 +3028,7 @@ function main() {
30283028
if [[ "${ENABLE_APISERVER_INSECURE_PORT:-false}" != "true" ]]; then
30293029
KUBE_BOOTSTRAP_TOKEN="$(secure_random 32)"
30303030
fi
3031-
if [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
3031+
if [[ "${SETUP_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
30323032
KONNECTIVITY_SERVER_TOKEN="$(secure_random 32)"
30333033
fi
30343034
if [[ "${ENABLE_MONITORING_TOKEN:-false}" == "true" ]]; then

cluster/gce/gci/configure-kubeapiserver.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,19 @@ function start-kube-apiserver {
341341
local csc_config_volume=""
342342
local default_konnectivity_socket_vol=""
343343
local default_konnectivity_socket_mnt=""
344-
if [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
344+
if [[ "${SETUP_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
345345
# Create the EgressSelectorConfiguration yaml file to control the Egress Selector.
346346
csc_config_mount="{\"name\": \"cscconfigmount\",\"mountPath\": \"/etc/srv/kubernetes/egress_selector_configuration.yaml\", \"readOnly\": false},"
347347
csc_config_volume="{\"name\": \"cscconfigmount\",\"hostPath\": {\"path\": \"/etc/srv/kubernetes/egress_selector_configuration.yaml\", \"type\": \"FileOrCreate\"}},"
348-
params+=" --egress-selector-config-file=/etc/srv/kubernetes/egress_selector_configuration.yaml"
349348

350349
# UDS socket for communication between apiserver and konnectivity-server
351350
local default_konnectivity_socket_path="/etc/srv/kubernetes/konnectivity-server"
352351
default_konnectivity_socket_vol="{ \"name\": \"konnectivity-socket\", \"hostPath\": {\"path\": \"${default_konnectivity_socket_path}\", \"type\": \"DirectoryOrCreate\"}},"
353352
default_konnectivity_socket_mnt="{ \"name\": \"konnectivity-socket\", \"mountPath\": \"${default_konnectivity_socket_path}\", \"readOnly\": false},"
354353
fi
354+
if [[ "${EGRESS_VIA_KONNECTIVITY:-false}" == "true" ]]; then
355+
params+=" --egress-selector-config-file=/etc/srv/kubernetes/egress_selector_configuration.yaml"
356+
fi
355357

356358
local container_env=""
357359
if [[ -n "${ENABLE_CACHE_MUTATION_DETECTOR:-}" ]]; then

cluster/gce/util.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,14 +1506,19 @@ EOF
15061506
MAX_PODS_PER_NODE: $(yaml-quote "${MAX_PODS_PER_NODE}")
15071507
EOF
15081508
fi
1509-
if [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
1509+
if [[ "${SETUP_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
15101510
cat >>$file <<EOF
1511-
EGRESS_VIA_KONNECTIVITY_SERVICE: $(yaml-quote "${EGRESS_VIA_KONNECTIVITY_SERVICE}")
1511+
SETUP_KONNECTIVITY_SERVICE: $(yaml-quote "${SETUP_KONNECTIVITY_SERVICE}")
1512+
EOF
1513+
fi
1514+
if [[ "${EGRESS_VIA_KONNECTIVITY:-false}" == "true" ]]; then
1515+
cat >>$file <<EOF
1516+
EGRESS_VIA_KONNECTIVITY: $(yaml-quote "${EGRESS_VIA_KONNECTIVITY}")
15121517
EOF
15131518
fi
15141519
if [[ "${RUN_KONNECTIVITY_SERVICE_PODS:-false}" == "true" ]]; then
15151520
cat >>$file <<EOF
1516-
RUN_KONNECTIVITY_SERVICE_PODS: $(yaml-quote "${RUN_KONNECTIVITY_SERVICE_PODS}"")
1521+
RUN_KONNECTIVITY_SERVICE_PODS: $(yaml-quote "${RUN_KONNECTIVITY_SERVICE_PODS}")
15171522
EOF
15181523
fi
15191524
if [[ -n "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-}" ]]; then
@@ -2578,7 +2583,7 @@ function create-master() {
25782583
--allow tcp:443 &
25792584

25802585
echo "Configuring firewall for apiserver konnectivity server"
2581-
if [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
2586+
if [[ "${SETUP_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
25822587
gcloud compute firewall-rules create "${MASTER_NAME}-konnectivity-server" \
25832588
--project "${NETWORK_PROJECT}" \
25842589
--network "${NETWORK}" \

0 commit comments

Comments
 (0)