Skip to content

Commit 7820b05

Browse files
committed
Separate network proxy flag for apiserver egress and starting pods
1 parent ededd08 commit 7820b05

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

cluster/gce/config-default.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,16 @@ 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 two variables below will
522+
# will 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 use konnectivity network proxy for all egress from apiserver.
526+
export EGRESS_VIA_KONNECTIVITY_SERVICE="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
527+
# Optional: Whether to start the konnectivity server and agent pods.
528+
export RUN_KONNECTIVITY_SERVICE_PODS="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
529+
# Proxy Protocol Mode determines the protocol to use to communicate between apiserver and network proxy.
530+
# Valid options are grpc and http-connect. Default is grpc.
523531
export KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE="${KUBE_KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}"
524532

525533
# 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 [[ "${EGRESS_VIA_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
@@ -2599,7 +2599,7 @@ EOF
25992599
setup-node-termination-handler-manifest ''
26002600
fi
26012601
# Setting up the konnectivity-agent daemonset
2602-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
2602+
if [[ "${RUN_KONNECTIVITY_SERVICE_PODS:-false}" == "true" ]]; then
26032603
setup-addon-manifests "addons" "konnectivity-agent"
26042604
setup-konnectivity-agent-manifest
26052605
fi
@@ -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 [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
3031+
if [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
30323032
KONNECTIVITY_SERVER_TOKEN="$(secure_random 32)"
30333033
fi
30343034
if [[ "${ENABLE_MONITORING_TOKEN:-false}" == "true" ]]; then
@@ -3089,7 +3089,7 @@ function main() {
30893089
fi
30903090
source ${KUBE_BIN}/configure-kubeapiserver.sh
30913091
start-kube-apiserver
3092-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
3092+
if [[ "${RUN_KONNECTIVITY_SERVICE_PODS:-false}" == "true" ]]; then
30933093
start-konnectivity-server
30943094
fi
30953095
start-kube-controller-manager

cluster/gce/gci/configure-kubeapiserver.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ 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 [[ "${EGRESS_VIA_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\"}},"

cluster/gce/util.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,9 +1506,14 @@ 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 [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
1510+
cat >>$file <<EOF
1511+
EGRESS_VIA_KONNECTIVITY_SERVICE: $(yaml-quote "${EGRESS_VIA_KONNECTIVITY_SERVICE}")
1512+
EOF
1513+
fi
1514+
if [[ "${RUN_KONNECTIVITY_SERVICE_PODS:-false}" == "true" ]]; then
1515+
cat >>$file <<EOF
1516+
RUN_KONNECTIVITY_SERVICE_PODS: $(yaml-quote "${RUN_KONNECTIVITY_SERVICE_PODS}"")
15121517
EOF
15131518
fi
15141519
if [[ -n "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-}" ]]; then
@@ -2573,7 +2578,7 @@ function create-master() {
25732578
--allow tcp:443 &
25742579
25752580
echo "Configuring firewall for apiserver konnectivity server"
2576-
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
2581+
if [[ "${EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
25772582
gcloud compute firewall-rules create "${MASTER_NAME}-konnectivity-server" \
25782583
--project "${NETWORK_PROJECT}" \
25792584
--network "${NETWORK}" \

0 commit comments

Comments
 (0)