mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #92669 from Jefftree/netproxy-configure-helper
Separate network proxy flag for apiserver egress and starting pods
This commit is contained in:
commit
1f756e4a37
@ -518,8 +518,19 @@ WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSche
|
|||||||
export GCE_PRIVATE_CLUSTER="${KUBE_GCE_PRIVATE_CLUSTER:-false}"
|
export GCE_PRIVATE_CLUSTER="${KUBE_GCE_PRIVATE_CLUSTER:-false}"
|
||||||
export GCE_PRIVATE_CLUSTER_PORTS_PER_VM="${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-}"
|
export GCE_PRIVATE_CLUSTER_PORTS_PER_VM="${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-}"
|
||||||
|
|
||||||
# Optional: Create apiserver konnectivity server and agent.
|
# When KUBE_ENABLE_KONNECTIVITY_SERVICE is enabled, the three variables below will
|
||||||
export ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE="${KUBE_ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}"
|
# default to true to enable the konnectivity network proxy and start the required pods.
|
||||||
|
# Their values can be overridden for more granular control of the proxy.
|
||||||
|
|
||||||
|
# Optional: Whether to do the setup for the konnectivity service
|
||||||
|
# Includes setting up kubeconfig, tokens, egress files, and firewall rules
|
||||||
|
export PREPARE_KONNECTIVITY_SERVICE="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
|
||||||
|
# Optional: Whether to use konnectivity network proxy for all egress from apiserver.
|
||||||
|
export EGRESS_VIA_KONNECTIVITY="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
|
||||||
|
# Optional: Whether to start the konnectivity server and agent pods.
|
||||||
|
export RUN_KONNECTIVITY_PODS="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-false}"
|
||||||
|
# Proxy Protocol Mode determines the protocol to use to communicate between apiserver and network proxy.
|
||||||
|
# Valid options are grpc and http-connect. Default is grpc.
|
||||||
export KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE="${KUBE_KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}"
|
export KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE="${KUBE_KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}"
|
||||||
|
|
||||||
# Optional: Enable Windows CSI-Proxy
|
# Optional: Enable Windows CSI-Proxy
|
||||||
|
@ -922,7 +922,7 @@ contexts:
|
|||||||
name: webhook
|
name: webhook
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
||||||
if [[ "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}" == 'grpc' ]]; then
|
if [[ "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}" == 'grpc' ]]; then
|
||||||
cat <<EOF >/etc/srv/kubernetes/egress_selector_configuration.yaml
|
cat <<EOF >/etc/srv/kubernetes/egress_selector_configuration.yaml
|
||||||
apiVersion: apiserver.k8s.io/v1beta1
|
apiVersion: apiserver.k8s.io/v1beta1
|
||||||
@ -2606,7 +2606,7 @@ EOF
|
|||||||
setup-node-termination-handler-manifest ''
|
setup-node-termination-handler-manifest ''
|
||||||
fi
|
fi
|
||||||
# Setting up the konnectivity-agent daemonset
|
# Setting up the konnectivity-agent daemonset
|
||||||
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
if [[ "${RUN_KONNECTIVITY_PODS:-false}" == "true" ]]; then
|
||||||
setup-addon-manifests "addons" "konnectivity-agent"
|
setup-addon-manifests "addons" "konnectivity-agent"
|
||||||
setup-konnectivity-agent-manifest
|
setup-konnectivity-agent-manifest
|
||||||
fi
|
fi
|
||||||
@ -3035,7 +3035,7 @@ function main() {
|
|||||||
if [[ "${ENABLE_APISERVER_INSECURE_PORT:-false}" != "true" ]]; then
|
if [[ "${ENABLE_APISERVER_INSECURE_PORT:-false}" != "true" ]]; then
|
||||||
KUBE_BOOTSTRAP_TOKEN="$(secure_random 32)"
|
KUBE_BOOTSTRAP_TOKEN="$(secure_random 32)"
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
||||||
KONNECTIVITY_SERVER_TOKEN="$(secure_random 32)"
|
KONNECTIVITY_SERVER_TOKEN="$(secure_random 32)"
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_MONITORING_TOKEN:-false}" == "true" ]]; then
|
if [[ "${ENABLE_MONITORING_TOKEN:-false}" == "true" ]]; then
|
||||||
@ -3096,7 +3096,7 @@ function main() {
|
|||||||
fi
|
fi
|
||||||
source ${KUBE_BIN}/configure-kubeapiserver.sh
|
source ${KUBE_BIN}/configure-kubeapiserver.sh
|
||||||
start-kube-apiserver
|
start-kube-apiserver
|
||||||
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
if [[ "${RUN_KONNECTIVITY_PODS:-false}" == "true" ]]; then
|
||||||
start-konnectivity-server
|
start-konnectivity-server
|
||||||
fi
|
fi
|
||||||
start-kube-controller-manager
|
start-kube-controller-manager
|
||||||
|
@ -341,17 +341,19 @@ function start-kube-apiserver {
|
|||||||
local csc_config_volume=""
|
local csc_config_volume=""
|
||||||
local default_konnectivity_socket_vol=""
|
local default_konnectivity_socket_vol=""
|
||||||
local default_konnectivity_socket_mnt=""
|
local default_konnectivity_socket_mnt=""
|
||||||
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
||||||
# Create the EgressSelectorConfiguration yaml file to control the Egress Selector.
|
# Create the EgressSelectorConfiguration yaml file to control the Egress Selector.
|
||||||
csc_config_mount="{\"name\": \"cscconfigmount\",\"mountPath\": \"/etc/srv/kubernetes/egress_selector_configuration.yaml\", \"readOnly\": false},"
|
csc_config_mount="{\"name\": \"cscconfigmount\",\"mountPath\": \"/etc/srv/kubernetes/egress_selector_configuration.yaml\", \"readOnly\": false},"
|
||||||
csc_config_volume="{\"name\": \"cscconfigmount\",\"hostPath\": {\"path\": \"/etc/srv/kubernetes/egress_selector_configuration.yaml\", \"type\": \"FileOrCreate\"}},"
|
csc_config_volume="{\"name\": \"cscconfigmount\",\"hostPath\": {\"path\": \"/etc/srv/kubernetes/egress_selector_configuration.yaml\", \"type\": \"FileOrCreate\"}},"
|
||||||
params+=" --egress-selector-config-file=/etc/srv/kubernetes/egress_selector_configuration.yaml"
|
|
||||||
|
|
||||||
# UDS socket for communication between apiserver and konnectivity-server
|
# UDS socket for communication between apiserver and konnectivity-server
|
||||||
local default_konnectivity_socket_path="/etc/srv/kubernetes/konnectivity-server"
|
local default_konnectivity_socket_path="/etc/srv/kubernetes/konnectivity-server"
|
||||||
default_konnectivity_socket_vol="{ \"name\": \"konnectivity-socket\", \"hostPath\": {\"path\": \"${default_konnectivity_socket_path}\", \"type\": \"DirectoryOrCreate\"}},"
|
default_konnectivity_socket_vol="{ \"name\": \"konnectivity-socket\", \"hostPath\": {\"path\": \"${default_konnectivity_socket_path}\", \"type\": \"DirectoryOrCreate\"}},"
|
||||||
default_konnectivity_socket_mnt="{ \"name\": \"konnectivity-socket\", \"mountPath\": \"${default_konnectivity_socket_path}\", \"readOnly\": false},"
|
default_konnectivity_socket_mnt="{ \"name\": \"konnectivity-socket\", \"mountPath\": \"${default_konnectivity_socket_path}\", \"readOnly\": false},"
|
||||||
fi
|
fi
|
||||||
|
if [[ "${EGRESS_VIA_KONNECTIVITY:-false}" == "true" ]]; then
|
||||||
|
params+=" --egress-selector-config-file=/etc/srv/kubernetes/egress_selector_configuration.yaml"
|
||||||
|
fi
|
||||||
|
|
||||||
local container_env=""
|
local container_env=""
|
||||||
if [[ -n "${ENABLE_CACHE_MUTATION_DETECTOR:-}" ]]; then
|
if [[ -n "${ENABLE_CACHE_MUTATION_DETECTOR:-}" ]]; then
|
||||||
|
@ -1506,9 +1506,19 @@ EOF
|
|||||||
MAX_PODS_PER_NODE: $(yaml-quote "${MAX_PODS_PER_NODE}")
|
MAX_PODS_PER_NODE: $(yaml-quote "${MAX_PODS_PER_NODE}")
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
||||||
cat >>"$file" <<EOF
|
cat >>$file <<EOF
|
||||||
ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE: $(yaml-quote "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE}")
|
PREPARE_KONNECTIVITY_SERVICE: $(yaml-quote "${PREPARE_KONNECTIVITY_SERVICE}")
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [[ "${EGRESS_VIA_KONNECTIVITY:-false}" == "true" ]]; then
|
||||||
|
cat >>$file <<EOF
|
||||||
|
EGRESS_VIA_KONNECTIVITY: $(yaml-quote "${EGRESS_VIA_KONNECTIVITY}")
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [[ "${RUN_KONNECTIVITY_PODS:-false}" == "true" ]]; then
|
||||||
|
cat >>$file <<EOF
|
||||||
|
RUN_KONNECTIVITY_PODS: $(yaml-quote "${RUN_KONNECTIVITY_PODS}")
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [[ -n "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-}" ]]; then
|
if [[ -n "${KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-}" ]]; then
|
||||||
@ -2573,7 +2583,7 @@ function create-master() {
|
|||||||
--allow tcp:443 &
|
--allow tcp:443 &
|
||||||
|
|
||||||
echo "Configuring firewall for apiserver konnectivity server"
|
echo "Configuring firewall for apiserver konnectivity server"
|
||||||
if [[ "${ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
if [[ "${PREPARE_KONNECTIVITY_SERVICE:-false}" == "true" ]]; then
|
||||||
gcloud compute firewall-rules create "${MASTER_NAME}-konnectivity-server" \
|
gcloud compute firewall-rules create "${MASTER_NAME}-konnectivity-server" \
|
||||||
--project "${NETWORK_PROJECT}" \
|
--project "${NETWORK_PROJECT}" \
|
||||||
--network "${NETWORK}" \
|
--network "${NETWORK}" \
|
||||||
|
Loading…
Reference in New Issue
Block a user