Skip to content

Commit 1f756e4

Browse files
authored
Merge pull request kubernetes#92669 from Jefftree/netproxy-configure-helper
Separate network proxy flag for apiserver egress and starting pods
2 parents 84096f0 + 0e5d057 commit 1f756e4

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

cluster/gce/config-default.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,19 @@ 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-
# Optional: Create apiserver konnectivity server and agent.
522-
export ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE="${KUBE_ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}"
521+
# When KUBE_ENABLE_KONNECTIVITY_SERVICE is enabled, the three variables below will
522+
# default to true to enable the konnectivity network proxy and start the required pods.
523+
# Their values can be overridden for more granular control of the proxy.
524+
525+
# Optional: Whether to do the setup for the konnectivity service
526+
# Includes setting up kubeconfig, tokens, egress files, and firewall rules
527+
export PREPARE_KONNECTIVITY_SERVICE="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
528+
# Optional: Whether to use konnectivity network proxy for all egress from apiserver.
529+
export EGRESS_VIA_KONNECTIVITY="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
530+
# Optional: Whether to start the konnectivity server and agent pods.
531+
export RUN_KONNECTIVITY_PODS="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
532+
# Proxy Protocol Mode determines the protocol to use to communicate between apiserver and network proxy.
533+
# Valid options are grpc and http-connect. Default is grpc.
523534
export KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE="${KUBE_KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}"
524535

525536
# Optional: Enable Windows CSI-Proxy

cluster/gce/gci/configure-helper.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ contexts:
922922
name: webhook
923923
EOF
924924
fi
925-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
925+
if [[ "${PREPARE_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
@@ -2606,7 +2606,7 @@ EOF
26062606
setup-node-termination-handler-manifest ''
26072607
fi
26082608
# Setting up the konnectivity-agent daemonset
2609-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
2609+
if [[ "${RUN_KONNECTIVITY_PODS:-false}" == "true" ]]; then
26102610
setup-addon-manifests "addons" "konnectivity-agent"
26112611
setup-konnectivity-agent-manifest
26122612
fi
@@ -3035,7 +3035,7 @@ function main() {
30353035
if [[ "${ENABLE_APISERVER_INSECURE_PORT:-false}" != "true" ]]; then
30363036
KUBE_BOOTSTRAP_TOKEN="$(secure_random 32)"
30373037
fi
3038-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
3038+
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
30393039
KONNECTIVITY_SERVER_TOKEN="$(secure_random 32)"
30403040
fi
30413041
if [[ "${ENABLE_MONITORING_TOKEN:-false}" == "true" ]]; then
@@ -3096,7 +3096,7 @@ function main() {
30963096
fi
30973097
source ${KUBE_BIN}/configure-kubeapiserver.sh
30983098
start-kube-apiserver
3099-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
3099+
if [[ "${RUN_KONNECTIVITY_PODS:-false}" == "true" ]]; then
31003100
start-konnectivity-server
31013101
fi
31023102
start-kube-controller-manager

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 [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
344+
if [[ "${PREPARE_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: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,9 +1506,19 @@ EOF
15061506
MAX_PODS_PER_NODE: $(yaml-quote "${MAX_PODS_PER_NODE}")
15071507
EOF
15081508
fi
1509-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
1510-
cat >>"$file" <<EOF
1511-
ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE: $(yaml-quote "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE}")
1509+
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
1510+
cat >>$file <<EOF
1511+
PREPARE_KONNECTIVITY_SERVICE: $(yaml-quote "${PREPARE_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}")
1517+
EOF
1518+
fi
1519+
if [[ "${RUN_KONNECTIVITY_PODS:-false}" == "true" ]]; then
1520+
cat >>$file <<EOF
1521+
RUN_KONNECTIVITY_PODS: $(yaml-quote "${RUN_KONNECTIVITY_PODS}")
15121522
EOF
15131523
fi
15141524
if [[ -n "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-}" ]]; then
@@ -2573,7 +2583,7 @@ function create-master() {
25732583
--allow tcp:443 &
25742584

25752585
echo "Configuring firewall for apiserver konnectivity server"
2576-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
2586+
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
25772587
gcloud compute firewall-rules create "${MASTER_NAME}-konnectivity-server" \
25782588
--project "${NETWORK_PROJECT}" \
25792589
--network "${NETWORK}" \

0 commit comments

Comments
 (0)