k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cluster/gce/config-test.sh (about) 1 #!/usr/bin/env bash 2 3 # Copyright 2014 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # TODO(jbeda): Provide a way to override project 18 # gcloud multiplexing for shared GCE/GKE tests. 19 KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. 20 source "${KUBE_ROOT}/cluster/gce/config-common.sh" 21 22 # Specifying KUBE_GCE_API_ENDPOINT will override the default GCE Compute API endpoint (https://www.googleapis.com/compute/v1/). 23 # This endpoint has to be pointing to v1 api. For example, https://www.googleapis.com/compute/staging_v1/ 24 export GCE_API_ENDPOINT=${KUBE_GCE_API_ENDPOINT:-} 25 ZONE=${KUBE_GCE_ZONE:-us-central1-b} 26 export REGION=${ZONE%-*} 27 RELEASE_REGION_FALLBACK=${RELEASE_REGION_FALLBACK:-false} 28 REGIONAL_KUBE_ADDONS=${REGIONAL_KUBE_ADDONS:-true} 29 NODE_SIZE=${NODE_SIZE:-e2-standard-2} 30 NUM_NODES=${NUM_NODES:-3} 31 NUM_WINDOWS_NODES=${NUM_WINDOWS_NODES:-0} 32 MASTER_SIZE=${MASTER_SIZE:-e2-standard-$(get-master-size)} 33 MASTER_MIN_CPU_ARCHITECTURE=${MASTER_MIN_CPU_ARCHITECTURE:-} # To allow choosing better architectures. 34 export MASTER_DISK_TYPE=pd-ssd 35 MASTER_DISK_SIZE=${MASTER_DISK_SIZE:-$(get-master-disk-size)} 36 MASTER_ROOT_DISK_SIZE=${MASTER_ROOT_DISK_SIZE:-$(get-master-root-disk-size)} 37 NODE_DISK_TYPE=${NODE_DISK_TYPE:-pd-standard} 38 NODE_DISK_SIZE=${NODE_DISK_SIZE:-100GB} 39 NODE_LOCAL_SSDS=${NODE_LOCAL_SSDS:-0} 40 NODE_LABELS=${KUBE_NODE_LABELS:-} 41 WINDOWS_NODE_LABELS=${WINDOWS_NODE_LABELS:-} 42 NODE_LOCAL_SSDS_EPHEMERAL=${NODE_LOCAL_SSDS_EPHEMERAL:-} 43 # Turning GRPC based Konnectivity testing on id advance of 44 # removing the SSHTunnel code. 45 export KUBE_ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE=true 46 export PREPARE_KONNECTIVITY_SERVICE="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-true}" 47 export EGRESS_VIA_KONNECTIVITY="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-true}" 48 export RUN_KONNECTIVITY_PODS="${KUBE_ENABLE_KONNECTIVITY_SERVICE:-true}" 49 export KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE="${KUBE_KONNECTIVITY_SERVICE_PROXY_PROTOCOL_MODE:-grpc}" 50 51 # KUBE_CREATE_NODES can be used to avoid creating nodes, while master will be sized for NUM_NODES nodes. 52 # Firewalls and node templates are still created. 53 KUBE_CREATE_NODES=${KUBE_CREATE_NODES:-true} 54 55 # An extension to local SSDs allowing users to specify block/fs and SCSI/NVMe devices 56 # Format of this variable will be "#,scsi/nvme,block/fs" you can specify multiple 57 # configurations by separating them by a semi-colon ex. "2,scsi,fs;1,nvme,block" 58 # is a request for 2 SCSI formatted and mounted SSDs and 1 NVMe block device SSD. 59 NODE_LOCAL_SSDS_EXT=${NODE_LOCAL_SSDS_EXT:-} 60 NODE_ACCELERATORS=${NODE_ACCELERATORS:-''} 61 export REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-true} 62 export KUBE_APISERVER_REQUEST_TIMEOUT=300 63 # Increase initial delay for the apiserver liveness probe, to avoid prematurely tearing it down 64 KUBE_APISERVER_LIVENESS_PROBE_INITIAL_DELAY_SEC=${KUBE_APISERVER_LIVENESS_PROBE_INITIAL_DELAY_SEC:-45} 65 # Also increase the initial delay for etcd just to be safe 66 ETCD_LIVENESS_PROBE_INITIAL_DELAY_SEC=${ETCD_LIVENESS_PROBE_INITIAL_DELAY_SEC:-45} 67 PREEMPTIBLE_NODE=${PREEMPTIBLE_NODE:-false} 68 PREEMPTIBLE_MASTER=${PREEMPTIBLE_MASTER:-false} 69 KUBE_DELETE_NODES=${KUBE_DELETE_NODES:-true} 70 KUBE_DELETE_NETWORK=${KUBE_DELETE_NETWORK:-true} 71 CREATE_CUSTOM_NETWORK=${CREATE_CUSTOM_NETWORK:-false} 72 MIG_WAIT_UNTIL_STABLE_TIMEOUT=${MIG_WAIT_UNTIL_STABLE_TIMEOUT:-1800} 73 74 MASTER_OS_DISTRIBUTION=${KUBE_MASTER_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}} 75 NODE_OS_DISTRIBUTION=${KUBE_NODE_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}} 76 WINDOWS_NODE_OS_DISTRIBUTION=${WINDOWS_NODE_OS_DISTRIBUTION:-win2019} 77 78 if [[ "${MASTER_OS_DISTRIBUTION}" = 'cos' ]]; then 79 MASTER_OS_DISTRIBUTION='gci' 80 fi 81 82 if [[ "${NODE_OS_DISTRIBUTION}" = 'cos' ]]; then 83 NODE_OS_DISTRIBUTION='gci' 84 fi 85 86 # GPUs supported in GCE do not have compatible drivers in Debian 7. 87 if [[ "${NODE_OS_DISTRIBUTION}" = 'debian' ]]; then 88 NODE_ACCELERATORS='' 89 fi 90 91 # To avoid failing large tests due to some flakes in starting nodes, allow 92 # for a small percentage of nodes to not start during cluster startup. 93 ALLOWED_NOTREADY_NODES=${ALLOWED_NOTREADY_NODES:-$(($(get-num-nodes) / 100))} 94 95 # By default a cluster will be started with the master and nodes 96 # on Container-optimized OS (cos, previously known as gci). If 97 # you are updating the os image versions, update this variable. 98 # Also please update corresponding image for node e2e at: 99 # https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/jenkins/image-config.yaml 100 # 101 # By default, the latest image from the image family will be used unless an 102 # explicit image will be set. 103 GCI_VERSION=${KUBE_GCI_VERSION:-} 104 IMAGE_FAMILY=${KUBE_IMAGE_FAMILY:-cos-109-lts} 105 export MASTER_IMAGE=${KUBE_GCE_MASTER_IMAGE:-} 106 export MASTER_IMAGE_FAMILY=${KUBE_GCE_MASTER_IMAGE_FAMILY:-${IMAGE_FAMILY}} 107 export MASTER_IMAGE_PROJECT=${KUBE_GCE_MASTER_PROJECT:-cos-cloud} 108 export NODE_IMAGE=${KUBE_GCE_NODE_IMAGE:-${GCI_VERSION}} 109 export NODE_IMAGE_FAMILY=${KUBE_GCE_NODE_IMAGE_FAMILY:-${IMAGE_FAMILY}} 110 export NODE_IMAGE_PROJECT=${KUBE_GCE_NODE_PROJECT:-cos-cloud} 111 export NODE_SERVICE_ACCOUNT=${KUBE_GCE_NODE_SERVICE_ACCOUNT:-default} 112 113 export CONTAINER_RUNTIME_ENDPOINT=${KUBE_CONTAINER_RUNTIME_ENDPOINT:-unix:///run/containerd/containerd.sock} 114 export CONTAINER_RUNTIME_NAME=${KUBE_CONTAINER_RUNTIME_NAME:-containerd} 115 export LOAD_IMAGE_COMMAND=${KUBE_LOAD_IMAGE_COMMAND:-ctr -n=k8s.io images import} 116 export LOG_DUMP_SYSTEMD_SERVICES=${LOG_DUMP_SYSTEMD_SERVICES:-containerd} 117 export CONTAINER_RUNTIME_TEST_HANDLER="true" 118 119 export GCI_DOCKER_VERSION=${KUBE_GCI_DOCKER_VERSION:-} 120 121 # Ability to inject custom versions (Ubuntu OS images ONLY) 122 # if KUBE_UBUNTU_INSTALL_CONTAINERD_VERSION or KUBE_UBUNTU_INSTALL_RUNC_VERSION 123 # is set to empty then we do not override the version(s) and just 124 # use whatever is in the default installation of containerd package 125 export UBUNTU_INSTALL_CONTAINERD_VERSION=${KUBE_UBUNTU_INSTALL_CONTAINERD_VERSION:-} 126 export UBUNTU_INSTALL_RUNC_VERSION=${KUBE_UBUNTU_INSTALL_RUNC_VERSION:-} 127 128 # Ability to inject custom versions (COS images ONLY) 129 # if KUBE_COS_INSTALL_CONTAINERD_VERSION or KUBE_COS_INSTALL_RUNC_VERSION 130 # is set to empty then we do not override the version(s) and just 131 # use whatever is in the default installation of containerd package 132 export COS_INSTALL_CONTAINERD_VERSION=${KUBE_COS_INSTALL_CONTAINERD_VERSION:-} 133 export COS_INSTALL_RUNC_VERSION=${KUBE_COS_INSTALL_RUNC_VERSION:-} 134 135 # MASTER_EXTRA_METADATA is the extra instance metadata on master instance separated by commas. 136 export MASTER_EXTRA_METADATA=${KUBE_MASTER_EXTRA_METADATA:-${KUBE_EXTRA_METADATA:-}} 137 # MASTER_EXTRA_METADATA is the extra instance metadata on node instance separated by commas. 138 export NODE_EXTRA_METADATA=${KUBE_NODE_EXTRA_METADATA:-${KUBE_EXTRA_METADATA:-}} 139 140 NETWORK=${KUBE_GCE_NETWORK:-e2e-test-${USER}} 141 if [[ "${CREATE_CUSTOM_NETWORK}" = true ]]; then 142 SUBNETWORK=${SUBNETWORK:-${NETWORK}-custom-subnet} 143 fi 144 INSTANCE_PREFIX=${KUBE_GCE_INSTANCE_PREFIX:-e2e-test-${USER}} 145 CLUSTER_NAME=${CLUSTER_NAME:-${INSTANCE_PREFIX}} 146 MASTER_NAME="${INSTANCE_PREFIX}-master" 147 export AGGREGATOR_MASTER_NAME="${INSTANCE_PREFIX}-aggregator" 148 export INITIAL_ETCD_CLUSTER=${MASTER_NAME} 149 export MASTER_TAG="${INSTANCE_PREFIX}-master" 150 export NODE_TAG="${INSTANCE_PREFIX}-minion" 151 152 CLUSTER_IP_RANGE=${CLUSTER_IP_RANGE:-$(get-cluster-ip-range)} 153 MASTER_IP_RANGE=${MASTER_IP_RANGE:-10.246.0.0/24} 154 # NODE_IP_RANGE is used when ENABLE_IP_ALIASES=true or CREATE_CUSTOM_NETWORK=true. 155 # It is the primary range in the subnet and is the range used for node instance IPs. 156 NODE_IP_RANGE=$(get-node-ip-range) 157 export NODE_IP_RANGE 158 159 export RUNTIME_CONFIG=${KUBE_RUNTIME_CONFIG:-} 160 161 if [[ "${KUBE_FEATURE_GATES:-}" = 'AllAlpha=true' ]]; then 162 RUNTIME_CONFIG=${KUBE_RUNTIME_CONFIG:-api/all=true} 163 fi 164 165 # By default disable gkenetworkparamset controller in CCM 166 RUN_CCM_CONTROLLERS="${RUN_CCM_CONTROLLERS:-*,-gkenetworkparamset}" 167 168 # Optional: set feature gates 169 # shellcheck disable=SC2034 # Variables sourced in other scripts. 170 FEATURE_GATES=${KUBE_FEATURE_GATES:-} 171 172 TERMINATED_POD_GC_THRESHOLD=${TERMINATED_POD_GC_THRESHOLD:-100} 173 174 # Extra docker options for nodes. 175 EXTRA_DOCKER_OPTS=${EXTRA_DOCKER_OPTS:-} 176 177 # Enable the docker debug mode. 178 EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS} --debug" 179 180 export SERVICE_CLUSTER_IP_RANGE='10.0.0.0/16' # formerly PORTAL_NET 181 182 # When set to true, Docker Cache is enabled by default as part of the cluster bring up. 183 export ENABLE_DOCKER_REGISTRY_CACHE=true 184 185 # Optional: Deploy a L7 loadbalancer controller to fulfill Ingress requests: 186 # glbc - CE L7 Load Balancer Controller 187 export ENABLE_L7_LOADBALANCING=${KUBE_ENABLE_L7_LOADBALANCING:-glbc} 188 189 # Optional: Enable Metrics Server. Metrics Server should be enable everywhere, 190 # since it's a critical component, but in the first release we need a way to disable 191 # this in case of stability issues. 192 # TODO(piosz) remove this option once Metrics Server became a stable thing. 193 export ENABLE_METRICS_SERVER=${KUBE_ENABLE_METRICS_SERVER:-true} 194 195 # Optional: Metadata agent to setup as part of the cluster bring up: 196 # none - No metadata agent 197 # stackdriver - Stackdriver metadata agent 198 # Metadata agent is a daemon set that provides metadata of kubernetes objects 199 # running on the same node for exporting metrics and logs. 200 export ENABLE_METADATA_AGENT=${KUBE_ENABLE_METADATA_AGENT:-none} 201 202 # One special node out of NUM_NODES would be created of this type if specified. 203 # Useful for scheduling heapster in large clusters with nodes of small size. 204 HEAPSTER_MACHINE_TYPE=${HEAPSTER_MACHINE_TYPE:-} 205 206 # Optional: Additional nodes would be created if their type and number is specified. 207 # NUM_NODES would be lowered respectively. 208 # Useful for running cluster-level addons that needs more resources than would fit 209 # on small nodes, like network plugins. 210 NUM_ADDITIONAL_NODES=${NUM_ADDITIONAL_NODES:-} 211 ADDITIONAL_MACHINE_TYPE=${ADDITIONAL_MACHINE_TYPE:-} 212 213 # Set etcd image (e.g. registry.k8s.io/etcd) and version (e.g. v3.5.1-0) if you need 214 # non-default version. 215 export ETCD_IMAGE=${TEST_ETCD_IMAGE:-} 216 export ETCD_DOCKER_REPOSITORY=${TEST_ETCD_DOCKER_REPOSITORY:-} 217 export ETCD_VERSION=${TEST_ETCD_VERSION:-} 218 219 # Default Log level for all components in test clusters and variables to override it in specific components. 220 TEST_CLUSTER_LOG_LEVEL=${TEST_CLUSTER_LOG_LEVEL:---v=4} 221 KUBELET_TEST_LOG_LEVEL=${KUBELET_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL} 222 DOCKER_TEST_LOG_LEVEL=${DOCKER_TEST_LOG_LEVEL:---log-level=info} 223 API_SERVER_TEST_LOG_LEVEL=${API_SERVER_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL} 224 CONTROLLER_MANAGER_TEST_LOG_LEVEL=${CONTROLLER_MANAGER_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL} 225 SCHEDULER_TEST_LOG_LEVEL=${SCHEDULER_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL} 226 KUBEPROXY_TEST_LOG_LEVEL=${KUBEPROXY_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL} 227 228 VOLUME_PLUGIN_DIR=${VOLUME_PLUGIN_DIR:-/home/kubernetes/flexvolume} 229 230 TEST_CLUSTER_DELETE_COLLECTION_WORKERS=${TEST_CLUSTER_DELETE_COLLECTION_WORKERS:---delete-collection-workers=1} 231 TEST_CLUSTER_MAX_REQUESTS_INFLIGHT=${TEST_CLUSTER_MAX_REQUESTS_INFLIGHT:-} 232 TEST_CLUSTER_RESYNC_PERIOD=${TEST_CLUSTER_RESYNC_PERIOD:---min-resync-period=3m} 233 234 # ContentType used by all components to communicate with apiserver. 235 TEST_CLUSTER_API_CONTENT_TYPE=${TEST_CLUSTER_API_CONTENT_TYPE:-} 236 237 # Enable debug handlers (port forwarding, exec, container logs, etc.). 238 KUBELET_ENABLE_DEBUGGING_HANDLERS=${KUBELET_ENABLE_DEBUGGING_HANDLERS:-true} 239 MASTER_KUBELET_ENABLE_DEBUGGING_HANDLERS=${MASTER_KUBELET_ENABLE_DEBUGGING_HANDLERS:-${KUBELET_ENABLE_DEBUGGING_HANDLERS}} 240 241 KUBELET_TEST_ARGS="${KUBELET_TEST_ARGS:-} --serialize-image-pulls=false ${TEST_CLUSTER_API_CONTENT_TYPE}" 242 if [[ "${NODE_OS_DISTRIBUTION}" = 'gci' ]] || [[ "${NODE_OS_DISTRIBUTION}" = 'ubuntu' ]] || [[ "${NODE_OS_DISTRIBUTION}" = 'custom' ]]; then 243 NODE_KUBELET_TEST_ARGS="${NODE_KUBELET_TEST_ARGS:-} --kernel-memcg-notification=true" 244 fi 245 if [[ "${MASTER_OS_DISTRIBUTION}" = 'gci' ]] || [[ "${MASTER_OS_DISTRIBUTION}" = 'ubuntu' ]]; then 246 MASTER_KUBELET_TEST_ARGS="${MASTER_KUBELET_TEST_ARGS:-} --kernel-memcg-notification=true" 247 fi 248 APISERVER_TEST_ARGS="${APISERVER_TEST_ARGS:-} --runtime-config=extensions/v1beta1,scheduling.k8s.io/v1alpha1 ${TEST_CLUSTER_DELETE_COLLECTION_WORKERS} ${TEST_CLUSTER_MAX_REQUESTS_INFLIGHT}" 249 CONTROLLER_MANAGER_TEST_ARGS="${CONTROLLER_MANAGER_TEST_ARGS:-} ${TEST_CLUSTER_RESYNC_PERIOD} ${TEST_CLUSTER_API_CONTENT_TYPE}" 250 SCHEDULER_TEST_ARGS="${SCHEDULER_TEST_ARGS:-} ${TEST_CLUSTER_API_CONTENT_TYPE}" 251 KUBEPROXY_TEST_ARGS="${KUBEPROXY_TEST_ARGS:-} ${TEST_CLUSTER_API_CONTENT_TYPE}" 252 253 export MASTER_NODE_LABELS=${KUBE_MASTER_NODE_LABELS:-} 254 # NON_MASTER_NODE_LABELS are labels will only be applied on non-master nodes. 255 NON_MASTER_NODE_LABELS=${KUBE_NON_MASTER_NODE_LABELS:-} 256 WINDOWS_NON_MASTER_NODE_LABELS=${WINDOWS_NON_MASTER_NODE_LABELS:-} 257 258 if [[ "${PREEMPTIBLE_MASTER}" = 'true' ]]; then 259 NODE_LABELS="${NODE_LABELS},cloud.google.com/gke-preemptible=true" 260 WINDOWS_NODE_LABELS="${WINDOWS_NODE_LABELS},cloud.google.com/gke-preemptible=true" 261 elif [[ "${PREEMPTIBLE_NODE}" = 'true' ]]; then 262 NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS},cloud.google.com/gke-preemptible=true" 263 WINDOWS_NON_MASTER_NODE_LABELS="${WINDOWS_NON_MASTER_NODE_LABELS},cloud.google.com/gke-preemptible=true" 264 fi 265 266 # Optional: Enable netd. 267 ENABLE_NETD=${KUBE_ENABLE_NETD:-false} 268 export CUSTOM_NETD_YAML=${KUBE_CUSTOM_NETD_YAML:-} 269 export CUSTOM_CALICO_NODE_DAEMONSET_YAML=${KUBE_CUSTOM_CALICO_NODE_DAEMONSET_YAML:-} 270 export CUSTOM_TYPHA_DEPLOYMENT_YAML=${KUBE_CUSTOM_TYPHA_DEPLOYMENT_YAML:-} 271 272 # To avoid running netd on a node that is not configured appropriately, 273 # label each Node so that the DaemonSet can run the Pods only on ready Nodes. 274 # Windows nodes do not support netd. 275 if [[ ${ENABLE_NETD:-} = 'true' ]]; then 276 NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS:+${NON_MASTER_NODE_LABELS},}cloud.google.com/gke-netd-ready=true" 277 fi 278 279 export ENABLE_NODELOCAL_DNS=${KUBE_ENABLE_NODELOCAL_DNS:-false} 280 281 # To avoid running Calico on a node that is not configured appropriately, 282 # label each Node so that the DaemonSet can run the Pods only on ready Nodes. 283 # Windows nodes do not support Calico. 284 if [[ ${NETWORK_POLICY_PROVIDER:-} = 'calico' ]]; then 285 NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS:+${NON_MASTER_NODE_LABELS},}projectcalico.org/ds-ready=true" 286 fi 287 288 # Enable metadata concealment by firewalling pod traffic to the metadata server 289 # and run a proxy daemonset on nodes. 290 ENABLE_METADATA_CONCEALMENT=${ENABLE_METADATA_CONCEALMENT:-true} # true, false 291 METADATA_CONCEALMENT_NO_FIREWALL=${METADATA_CONCEALMENT_NO_FIREWALL:-false} # true, false 292 if [[ ${ENABLE_METADATA_CONCEALMENT:-} = 'true' ]]; then 293 # Put the necessary label on the node so the daemonset gets scheduled. 294 NODE_LABELS="${NODE_LABELS},cloud.google.com/metadata-proxy-ready=true" 295 # Add to the provider custom variables. 296 PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_METADATA_CONCEALMENT METADATA_CONCEALMENT_NO_FIREWALL" 297 fi 298 299 # Optional: Enable node logging. 300 export ENABLE_NODE_LOGGING=${KUBE_ENABLE_NODE_LOGGING:-true} 301 export LOGGING_DESTINATION=${KUBE_LOGGING_DESTINATION:-gcp} # options: gcp 302 303 # Optional: When set to true, Elasticsearch and Kibana will be setup as part of the cluster bring up. 304 export ENABLE_CLUSTER_LOGGING=${KUBE_ENABLE_CLUSTER_LOGGING:-true} 305 export ELASTICSEARCH_LOGGING_REPLICAS=1 306 307 # Optional: Don't require https for registries in our local RFC1918 network 308 if [[ ${KUBE_ENABLE_INSECURE_REGISTRY:-false} = 'true' ]]; then 309 EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS} --insecure-registry 10.0.0.0/8" 310 fi 311 312 if [[ -n "${NODE_ACCELERATORS}" ]]; then 313 if [[ "${NODE_ACCELERATORS}" =~ .*type=([a-zA-Z0-9-]+).* ]]; then 314 NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS},cloud.google.com/gke-accelerator=${BASH_REMATCH[1]}" 315 fi 316 fi 317 318 # List of the set of feature gates recognized by the GCP CCM 319 export CCM_FEATURE_GATES="APIPriorityAndFairness,APIResponseCompression,APIServerIdentity,APIServerTracing,AllAlpha,AllBeta,CustomResourceValidationExpressions,KMSv2,OpenAPIEnums,OpenAPIV3,ServerSideFieldValidation,StorageVersionAPI,StorageVersionHash" 320 321 # Optional: Install cluster DNS. 322 # Set CLUSTER_DNS_CORE_DNS to 'false' to install kube-dns instead of CoreDNS. 323 CLUSTER_DNS_CORE_DNS=${CLUSTER_DNS_CORE_DNS:-true} 324 export ENABLE_CLUSTER_DNS=${KUBE_ENABLE_CLUSTER_DNS:-true} 325 export DNS_SERVER_IP='10.0.0.10' 326 export LOCAL_DNS_IP=${KUBE_LOCAL_DNS_IP:-169.254.20.10} 327 export DNS_DOMAIN='cluster.local' 328 export DNS_MEMORY_LIMIT=${KUBE_DNS_MEMORY_LIMIT:-170Mi} 329 330 # Optional: Enable DNS horizontal autoscaler 331 export ENABLE_DNS_HORIZONTAL_AUTOSCALER=${KUBE_ENABLE_DNS_HORIZONTAL_AUTOSCALER:-true} 332 333 # Optional: Install node problem detector. 334 # none - Not run node problem detector. 335 # daemonset - Run node problem detector as daemonset. 336 # standalone - Run node problem detector as standalone system daemon. 337 export ENABLE_NODE_PROBLEM_DETECTOR=${KUBE_ENABLE_NODE_PROBLEM_DETECTOR:-daemonset} 338 NODE_PROBLEM_DETECTOR_VERSION=${NODE_PROBLEM_DETECTOR_VERSION:-} 339 NODE_PROBLEM_DETECTOR_TAR_HASH=${NODE_PROBLEM_DETECTOR_TAR_HASH:-} 340 NODE_PROBLEM_DETECTOR_RELEASE_PATH=${NODE_PROBLEM_DETECTOR_RELEASE_PATH:-} 341 NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS=${NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS:-} 342 343 CNI_HASH=${CNI_HASH:-} 344 CNI_TAR_PREFIX=${CNI_TAR_PREFIX:-cni-plugins-linux-amd64-} 345 CNI_STORAGE_URL_BASE=${CNI_STORAGE_URL_BASE:-https://storage.googleapis.com/k8s-artifacts-cni/release} 346 347 # Optional: Create autoscaler for cluster's nodes. 348 export ENABLE_CLUSTER_AUTOSCALER=${KUBE_ENABLE_CLUSTER_AUTOSCALER:-false} 349 if [[ "${ENABLE_CLUSTER_AUTOSCALER}" = 'true' ]]; then 350 export AUTOSCALER_MIN_NODES=${KUBE_AUTOSCALER_MIN_NODES:-} 351 export AUTOSCALER_MAX_NODES=${KUBE_AUTOSCALER_MAX_NODES:-} 352 export AUTOSCALER_ENABLE_SCALE_DOWN=${KUBE_AUTOSCALER_ENABLE_SCALE_DOWN:-false} 353 export AUTOSCALER_EXPANDER_CONFIG=${KUBE_AUTOSCALER_EXPANDER_CONFIG:---expander=price} 354 fi 355 356 # Optional: Enable allocation of pod IPs using IP aliases. 357 # 358 # BETA FEATURE. 359 # 360 # IP_ALIAS_SIZE is the size of the podCIDR allocated to a node. 361 # IP_ALIAS_SUBNETWORK is the subnetwork to allocate from. If empty, a 362 # new subnetwork will be created for the cluster. 363 ENABLE_IP_ALIASES=${KUBE_GCE_ENABLE_IP_ALIASES:-true} 364 export NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-RangeAllocator} 365 if [ "${ENABLE_IP_ALIASES}" = true ]; then 366 # Number of Pods that can run on this node. 367 MAX_PODS_PER_NODE=${MAX_PODS_PER_NODE:-110} 368 # Size of ranges allocated to each node. 369 IP_ALIAS_SIZE="/$(get-alias-range-size "${MAX_PODS_PER_NODE}")" 370 IP_ALIAS_SUBNETWORK=${KUBE_GCE_IP_ALIAS_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-default} 371 # If we're using custom network, use the subnet we already create for it as the one for ip-alias. 372 # Note that this means SUBNETWORK would override KUBE_GCE_IP_ALIAS_SUBNETWORK in case of custom network. 373 if [[ "${CREATE_CUSTOM_NETWORK}" = true ]]; then 374 IP_ALIAS_SUBNETWORK=${SUBNETWORK} 375 fi 376 export IP_ALIAS_SIZE 377 export IP_ALIAS_SUBNETWORK 378 # Reserve the services IP space to avoid being allocated for other GCP resources. 379 export SERVICE_CLUSTER_IP_SUBNETWORK=${KUBE_GCE_SERVICE_CLUSTER_IP_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-services} 380 NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-CloudAllocator} 381 SECONDARY_RANGE_NAME=${SECONDARY_RANGE_NAME:-} 382 # Add to the provider custom variables. 383 PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_IP_ALIASES" 384 PROVIDER_VARS="${PROVIDER_VARS:-} NODE_IPAM_MODE" 385 PROVIDER_VARS="${PROVIDER_VARS:-} SECONDARY_RANGE_NAME" 386 else 387 if [[ -n "${MAX_PODS_PER_NODE:-}" ]]; then 388 # Should not have MAX_PODS_PER_NODE set for route-based clusters. 389 echo -e "${color_red:-}Cannot set MAX_PODS_PER_NODE for route-based projects for ${PROJECT}." >&2 390 exit 1 391 fi 392 if [[ "$(get-num-nodes)" -gt 100 ]]; then 393 echo -e "${color_red:-}Cannot create cluster with more than 100 nodes for route-based projects for ${PROJECT}." >&2 394 exit 1 395 fi 396 fi 397 398 # Enable GCE Alpha features. 399 if [[ -n "${GCE_ALPHA_FEATURES:-}" ]]; then 400 PROVIDER_VARS="${PROVIDER_VARS:-} GCE_ALPHA_FEATURES" 401 fi 402 403 # Disable Docker live-restore. 404 if [[ -n "${DISABLE_DOCKER_LIVE_RESTORE:-}" ]]; then 405 PROVIDER_VARS="${PROVIDER_VARS:-} DISABLE_DOCKER_LIVE_RESTORE" 406 fi 407 408 # Override default GLBC image 409 if [[ -n "${GCE_GLBC_IMAGE:-}" ]]; then 410 PROVIDER_VARS="${PROVIDER_VARS:-} GCE_GLBC_IMAGE" 411 fi 412 CUSTOM_INGRESS_YAML=${CUSTOM_INGRESS_YAML:-} 413 414 if [[ -z "${KUBE_ADMISSION_CONTROL:-}" ]]; then 415 ADMISSION_CONTROL='NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,Priority,StorageObjectInUseProtection,PersistentVolumeClaimResize,RuntimeClass' 416 # ResourceQuota must come last, or a creation is recorded, but the pod may be forbidden. 417 ADMISSION_CONTROL="${ADMISSION_CONTROL},MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota" 418 else 419 ADMISSION_CONTROL=${KUBE_ADMISSION_CONTROL} 420 fi 421 422 ENABLE_APISERVER_DYNAMIC_AUDIT=${ENABLE_APISERVER_DYNAMIC_AUDIT:-false} 423 424 # Optional: if set to true kube-up will automatically check for existing resources and clean them up. 425 KUBE_UP_AUTOMATIC_CLEANUP=${KUBE_UP_AUTOMATIC_CLEANUP:-false} 426 427 # Optional: setting it to true denotes this is a testing cluster, 428 # so that we can use pulled kubernetes binaries, even if binaries 429 # are pre-installed in the image. Note that currently this logic 430 # is only supported in trusty or GCI. 431 TEST_CLUSTER=${TEST_CLUSTER:-true} 432 433 # Storage backend. 'etcd2' and 'etcd3' are supported. 434 STORAGE_BACKEND=${STORAGE_BACKEND:-} 435 # Storage media type: application/json and application/vnd.kubernetes.protobuf are supported. 436 STORAGE_MEDIA_TYPE=${STORAGE_MEDIA_TYPE:-} 437 438 NETWORK_PROVIDER=${NETWORK_PROVIDER:-kubenet} # none, kubenet 439 440 # Network Policy plugin specific settings. 441 NETWORK_POLICY_PROVIDER=${NETWORK_POLICY_PROVIDER:-none} # calico 442 443 export NON_MASQUERADE_CIDR='0.0.0.0/0' 444 445 # How should the kubelet configure hairpin mode? 446 HAIRPIN_MODE=${HAIRPIN_MODE:-hairpin-veth} # promiscuous-bridge, hairpin-veth, none 447 448 # Optional: if set to true, kube-up will configure the cluster to run e2e tests. 449 export E2E_STORAGE_TEST_ENVIRONMENT=${KUBE_E2E_STORAGE_TEST_ENVIRONMENT:-false} 450 451 # Evict pods whenever compute resource availability on the nodes gets below a threshold. 452 EVICTION_HARD=${EVICTION_HARD:-memory.available<250Mi,nodefs.available<10%,nodefs.inodesFree<5%} 453 454 # Optional: custom scheduling algorithm 455 SCHEDULING_ALGORITHM_PROVIDER=${SCHEDULING_ALGORITHM_PROVIDER:-} 456 457 # Optional: install a default StorageClass 458 ENABLE_DEFAULT_STORAGE_CLASS=${ENABLE_DEFAULT_STORAGE_CLASS:-false} 459 460 # Optional: install volume snapshot CRDs 461 ENABLE_VOLUME_SNAPSHOTS=${ENABLE_VOLUME_SNAPSHOTS:-true} 462 463 # Optional: Enable legacy ABAC policy that makes all service accounts superusers. 464 # Disabling this by default in tests ensures default RBAC policies are sufficient from 1.6+ 465 # Upgrade test jobs that go from a version < 1.6 to a version >= 1.6 should override this to be true. 466 ENABLE_LEGACY_ABAC=${ENABLE_LEGACY_ABAC:-false} # true, false 467 468 # Enable a simple "AdvancedAuditing" setup for testing. 469 ENABLE_APISERVER_ADVANCED_AUDIT=${ENABLE_APISERVER_ADVANCED_AUDIT:-true} # true, false 470 ADVANCED_AUDIT_LOG_MODE=${ADVANCED_AUDIT_LOG_MODE:-batch} # batch, blocking 471 472 ENABLE_BIG_CLUSTER_SUBNETS=${ENABLE_BIG_CLUSTER_SUBNETS:-false} 473 474 # Optional: Enable log rotation for k8s services 475 ENABLE_LOGROTATE_FILES="${ENABLE_LOGROTATE_FILES:-true}" 476 PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_LOGROTATE_FILES" 477 if [[ -n "${LOGROTATE_FILES_MAX_COUNT:-}" ]]; then 478 PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_FILES_MAX_COUNT" 479 fi 480 if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then 481 PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE" 482 fi 483 484 # Optional: Enable log rotation for pod logs 485 ENABLE_POD_LOG="${ENABLE_POD_LOG:-false}" 486 PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_POD_LOG" 487 488 if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then 489 PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE" 490 fi 491 492 if [[ -n "${POD_LOG_MAX_SIZE:-}" ]]; then 493 PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_SIZE" 494 fi 495 496 # Fluentd requirements 497 # YAML exists to trigger a configuration refresh when changes are made. 498 export FLUENTD_GCP_YAML_VERSION='v3.2.0' 499 FLUENTD_GCP_VERSION=${FLUENTD_GCP_VERSION:-1.6.17} 500 FLUENTD_GCP_MEMORY_LIMIT=${FLUENTD_GCP_MEMORY_LIMIT:-} 501 FLUENTD_GCP_CPU_REQUEST=${FLUENTD_GCP_CPU_REQUEST:-} 502 FLUENTD_GCP_MEMORY_REQUEST=${FLUENTD_GCP_MEMORY_REQUEST:-} 503 504 # Heapster requirements 505 HEAPSTER_GCP_BASE_MEMORY=${HEAPSTER_GCP_BASE_MEMORY:-140Mi} 506 HEAPSTER_GCP_MEMORY_PER_NODE=${HEAPSTER_GCP_MEMORY_PER_NODE:-4} 507 HEAPSTER_GCP_BASE_CPU=${HEAPSTER_GCP_BASE_CPU:-80m} 508 HEAPSTER_GCP_CPU_PER_NODE=${HEAPSTER_GCP_CPU_PER_NODE:-0.5} 509 510 # Default Stackdriver resources version exported by Fluentd-gcp addon 511 LOGGING_STACKDRIVER_RESOURCE_TYPES=${LOGGING_STACKDRIVER_RESOURCE_TYPES:-old} 512 513 # Adding to PROVIDER_VARS, since this is GCP-specific. 514 PROVIDER_VARS="${PROVIDER_VARS:-} FLUENTD_GCP_YAML_VERSION FLUENTD_GCP_VERSION FLUENTD_GCP_MEMORY_LIMIT FLUENTD_GCP_CPU_REQUEST FLUENTD_GCP_MEMORY_REQUEST HEAPSTER_GCP_BASE_MEMORY HEAPSTER_GCP_MEMORY_PER_NODE HEAPSTER_GCP_BASE_CPU HEAPSTER_GCP_CPU_PER_NODE LOGGING_STACKDRIVER_RESOURCE_TYPES" 515 516 # Fluentd configuration for node-journal 517 ENABLE_NODE_JOURNAL=${ENABLE_NODE_JOURNAL:-false} 518 519 # prometheus-to-sd configuration 520 PROMETHEUS_TO_SD_ENDPOINT=${PROMETHEUS_TO_SD_ENDPOINT:-https://monitoring.googleapis.com/} 521 PROMETHEUS_TO_SD_PREFIX=${PROMETHEUS_TO_SD_PREFIX:-custom.googleapis.com} 522 ENABLE_PROMETHEUS_TO_SD=${ENABLE_PROMETHEUS_TO_SD:-true} 523 524 # TODO(#51292): Make kube-proxy Daemonset default and remove the configuration here. 525 # Optional: [Experiment Only] Run kube-proxy as a DaemonSet if set to true, run as static pods otherwise. 526 KUBE_PROXY_DAEMONSET=${KUBE_PROXY_DAEMONSET:-false} # true, false 527 528 # Control whether the startup scripts manage the lifecycle of kube-proxy 529 # When true, the startup scripts do not enable kube-proxy either as a daemonset addon or as a static pod 530 # regardless of the value of KUBE_PROXY_DAEMONSET. 531 # When false, the value of KUBE_PROXY_DAEMONSET controls whether kube-proxy comes up as a static pod or 532 # as an addon daemonset. 533 KUBE_PROXY_DISABLE="${KUBE_PROXY_DISABLE:-false}" # true, false 534 535 # Optional: Change the kube-proxy implementation. Choices are [iptables, ipvs, nftables]. 536 KUBE_PROXY_MODE=${KUBE_PROXY_MODE:-iptables} 537 538 # Will be passed into the kube-proxy via `--detect-local-mode` 539 DETECT_LOCAL_MODE="${DETECT_LOCAL_MODE:-NodeCIDR}" 540 541 # Optional: duration of cluster signed certificates. 542 CLUSTER_SIGNING_DURATION=${CLUSTER_SIGNING_DURATION:-} 543 544 # Optional: enable certificate rotation of the kubelet certificates. 545 ROTATE_CERTIFICATES=${ROTATE_CERTIFICATES:-} 546 547 # The number of services that are allowed to sync concurrently. Will be passed 548 # into kube-controller-manager via `--concurrent-service-syncs` 549 CONCURRENT_SERVICE_SYNCS=${CONCURRENT_SERVICE_SYNCS:-5} 550 551 # The value kubernetes.default.svc.cluster.local is only usable for full 552 # OIDC discovery flows in Pods in the same cluster. For some providers 553 # with configurations that support non-traditional KSA authentication methods, 554 # this value may make sense, but if the expectation is traditional OIDC, don't 555 # use this value in production. If you do use it, the FQDN is preferred to 556 # kubernetes.default.svc, to avoid something outside the cluster attempting 557 # to resolve the partially qualified name. 558 export SERVICEACCOUNT_ISSUER='https://kubernetes.default.svc.cluster.local' 559 560 # Taint Windows nodes by default to prevent Linux workloads from being 561 # scheduled onto them. 562 WINDOWS_NODE_TAINTS=${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSchedule} 563 564 # Whether to set up a private GCE cluster, i.e. a cluster where nodes have only private IPs. 565 export GCE_PRIVATE_CLUSTER=${KUBE_GCE_PRIVATE_CLUSTER:-false} 566 export GCE_PRIVATE_CLUSTER_PORTS_PER_VM=${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-} 567 568 export ETCD_LISTEN_CLIENT_IP=0.0.0.0 569 570 export GCE_UPLOAD_KUBCONFIG_TO_MASTER_METADATA=true 571 572 # Optoinal: Enable Windows CSI-Proxy 573 export ENABLE_CSI_PROXY="${ENABLE_CSI_PROXY:-true}" 574 575 # KUBE_APISERVER_HEALTHCHECK_ON_HOST_IP decides whether 576 # kube-apiserver is healthchecked on host IP instead of 127.0.0.1. 577 export KUBE_APISERVER_HEALTHCHECK_ON_HOST_IP="${KUBE_APISERVER_HEALTHCHECK_ON_HOST_IP:-false}" 578 579 # ETCD_PROGRESS_NOTIFY_INTERVAL defines the interval for etcd watch progress notify events. 580 export ETCD_PROGRESS_NOTIFY_INTERVAL="${ETCD_PROGRESS_NOTIFY_INTERVAL:-5s}" 581 582 # Optional: Install Pigz on Windows. 583 # Pigz is a multi-core optimized version of unzip.exe. 584 # It improves container image pull performance since most time is spent 585 # unzipping the image layers to disk. 586 export WINDOWS_ENABLE_PIGZ="${WINDOWS_ENABLE_PIGZ:-true}" 587 588 # Enable Windows DSR (Direct Server Return) 589 export WINDOWS_ENABLE_DSR="${WINDOWS_ENABLE_DSR:-false}" 590 591 # Install Node Problem Detector (NPD) on Windows nodes. 592 # NPD analyzes the host for problems that can disrupt workloads. 593 export WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR="${WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR:-none}" 594 export WINDOWS_NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS="${WINDOWS_NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS:-}" 595 596 # TLS_CIPHER_SUITES defines cipher suites allowed to be used by kube-apiserver. 597 # If this variable is unset or empty, kube-apiserver will allow its default set of cipher suites. 598 export TLS_CIPHER_SUITES="" 599 600 # CLOUD_PROVIDER_FLAG defines the cloud-provider value presented to KCM, apiserver, 601 # and kubelet 602 export CLOUD_PROVIDER_FLAG="${CLOUD_PROVIDER_FLAG:-external}" 603 604 # Don't run the node-ipam-controller on the KCM if cloud-provider external 605 if [[ "${CLOUD_PROVIDER_FLAG}" == "external" ]]; then 606 RUN_CONTROLLERS="${RUN_CONTROLLERS:-*,-node-ipam-controller}" 607 fi 608 609 # When ENABLE_AUTH_PROVIDER_GCP is set, following flags for out-of-tree credential provider for GCP 610 # are presented to kubelet: 611 # --image-credential-provider-config=${path-to-config} 612 # --image-credential-provider-bin-dir=${path-to-auth-provider-binary} 613 # Also, it is required that DisableKubeletCloudCredentialProviders and KubeletCredentialProviders 614 # feature gates are set to true for kubelet to use external credential provider. 615 export ENABLE_AUTH_PROVIDER_GCP="${ENABLE_AUTH_PROVIDER_GCP:-true}"