config-test.sh 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. #!/usr/bin/env bash
  2. # Copyright 2014 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # TODO(jbeda): Provide a way to override project
  16. # gcloud multiplexing for shared GCE/GKE tests.
  17. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
  18. source "${KUBE_ROOT}/cluster/gce/config-common.sh"
  19. # Specifying KUBE_GCE_API_ENDPOINT will override the default GCE Compute API endpoint (https://www.googleapis.com/compute/v1/).
  20. # This endpoint has to be pointing to v1 api. For example, https://www.googleapis.com/compute/staging_v1/
  21. GCE_API_ENDPOINT=${KUBE_GCE_API_ENDPOINT:-}
  22. GCLOUD=gcloud
  23. ZONE=${KUBE_GCE_ZONE:-us-central1-b}
  24. REGION=${ZONE%-*}
  25. RELEASE_REGION_FALLBACK=${RELEASE_REGION_FALLBACK:-false}
  26. REGIONAL_KUBE_ADDONS=${REGIONAL_KUBE_ADDONS:-true}
  27. NODE_SIZE=${NODE_SIZE:-n1-standard-2}
  28. NUM_NODES=${NUM_NODES:-3}
  29. NUM_WINDOWS_NODES=${NUM_WINDOWS_NODES:-0}
  30. MASTER_SIZE=${MASTER_SIZE:-n1-standard-$(get-master-size)}
  31. MASTER_MIN_CPU_ARCHITECTURE=${MASTER_MIN_CPU_ARCHITECTURE:-} # To allow choosing better architectures.
  32. MASTER_DISK_TYPE=pd-ssd
  33. MASTER_DISK_SIZE=${MASTER_DISK_SIZE:-$(get-master-disk-size)}
  34. MASTER_ROOT_DISK_SIZE=${MASTER_ROOT_DISK_SIZE:-$(get-master-root-disk-size)}
  35. NODE_DISK_TYPE=${NODE_DISK_TYPE:-pd-standard}
  36. NODE_DISK_SIZE=${NODE_DISK_SIZE:-100GB}
  37. NODE_LOCAL_SSDS=${NODE_LOCAL_SSDS:-0}
  38. NODE_LABELS="${KUBE_NODE_LABELS:-}"
  39. WINDOWS_NODE_LABELS="${WINDOWS_NODE_LABELS:-}"
  40. # KUBE_CREATE_NODES can be used to avoid creating nodes, while master will be sized for NUM_NODES nodes.
  41. # Firewalls and node templates are still created.
  42. KUBE_CREATE_NODES="${KUBE_CREATE_NODES:-true}"
  43. # An extension to local SSDs allowing users to specify block/fs and SCSI/NVMe devices
  44. # Format of this variable will be "#,scsi/nvme,block/fs" you can specify multiple
  45. # configurations by separating them by a semi-colon ex. "2,scsi,fs;1,nvme,block"
  46. # is a request for 2 SCSI formatted and mounted SSDs and 1 NVMe block device SSD.
  47. NODE_LOCAL_SSDS_EXT=${NODE_LOCAL_SSDS_EXT:-}
  48. NODE_ACCELERATORS=${NODE_ACCELERATORS:-""}
  49. REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-true}
  50. KUBE_APISERVER_REQUEST_TIMEOUT=300
  51. # Increase initial delay for the apiserver liveness probe, to avoid prematurely tearing it down
  52. KUBE_APISERVER_LIVENESS_PROBE_INITIAL_DELAY_SEC=${KUBE_APISERVER_LIVENESS_PROBE_INITIAL_DELAY_SEC:-45}
  53. # Also increase the initial delay for etcd just to be safe
  54. ETCD_LIVENESS_PROBE_INITIAL_DELAY_SEC=${ETCD_LIVENESS_PROBE_INITIAL_DELAY_SEC:-45}
  55. PREEMPTIBLE_NODE=${PREEMPTIBLE_NODE:-false}
  56. PREEMPTIBLE_MASTER=${PREEMPTIBLE_MASTER:-false}
  57. KUBE_DELETE_NODES=${KUBE_DELETE_NODES:-true}
  58. KUBE_DELETE_NETWORK=${KUBE_DELETE_NETWORK:-true}
  59. CREATE_CUSTOM_NETWORK=${CREATE_CUSTOM_NETWORK:-false}
  60. MIG_WAIT_UNTIL_STABLE_TIMEOUT=${MIG_WAIT_UNTIL_STABLE_TIMEOUT:-1800}
  61. MASTER_OS_DISTRIBUTION=${KUBE_MASTER_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}}
  62. NODE_OS_DISTRIBUTION=${KUBE_NODE_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}}
  63. WINDOWS_NODE_OS_DISTRIBUTION=${WINDOWS_NODE_OS_DISTRIBUTION:-win2019}
  64. if [[ "${MASTER_OS_DISTRIBUTION}" == "cos" ]]; then
  65. MASTER_OS_DISTRIBUTION="gci"
  66. fi
  67. if [[ "${NODE_OS_DISTRIBUTION}" == "cos" ]]; then
  68. NODE_OS_DISTRIBUTION="gci"
  69. fi
  70. # GPUs supported in GCE do not have compatible drivers in Debian 7.
  71. if [[ "${NODE_OS_DISTRIBUTION}" == "debian" ]]; then
  72. NODE_ACCELERATORS=""
  73. fi
  74. # To avoid failing large tests due to some flakes in starting nodes, allow
  75. # for a small percentage of nodes to not start during cluster startup.
  76. ALLOWED_NOTREADY_NODES="${ALLOWED_NOTREADY_NODES:-$(($(get-num-nodes) / 100))}"
  77. # By default a cluster will be started with the master and nodes
  78. # on Container-optimized OS (cos, previously known as gci). If
  79. # you are updating the os image versions, update this variable.
  80. # Also please update corresponding image for node e2e at:
  81. # https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/jenkins/image-config.yaml
  82. GCI_VERSION=${KUBE_GCI_VERSION:-cos-77-12371-175-0}
  83. MASTER_IMAGE=${KUBE_GCE_MASTER_IMAGE:-}
  84. MASTER_IMAGE_PROJECT=${KUBE_GCE_MASTER_PROJECT:-cos-cloud}
  85. NODE_IMAGE=${KUBE_GCE_NODE_IMAGE:-${GCI_VERSION}}
  86. NODE_IMAGE_PROJECT=${KUBE_GCE_NODE_PROJECT:-cos-cloud}
  87. NODE_SERVICE_ACCOUNT=${KUBE_GCE_NODE_SERVICE_ACCOUNT:-default}
  88. CONTAINER_RUNTIME=${KUBE_CONTAINER_RUNTIME:-docker}
  89. CONTAINER_RUNTIME_ENDPOINT=${KUBE_CONTAINER_RUNTIME_ENDPOINT:-}
  90. CONTAINER_RUNTIME_NAME=${KUBE_CONTAINER_RUNTIME_NAME:-}
  91. LOAD_IMAGE_COMMAND=${KUBE_LOAD_IMAGE_COMMAND:-}
  92. GCI_DOCKER_VERSION=${KUBE_GCI_DOCKER_VERSION:-}
  93. if [[ "${CONTAINER_RUNTIME}" == "containerd" ]]; then
  94. CONTAINER_RUNTIME_NAME=${KUBE_CONTAINER_RUNTIME_NAME:-containerd}
  95. LOAD_IMAGE_COMMAND=${KUBE_LOAD_IMAGE_COMMAND:-ctr -n=k8s.io images import}
  96. fi
  97. # Ability to inject custom versions (Ubuntu OS images ONLY)
  98. # if KUBE_UBUNTU_INSTALL_CONTAINERD_VERSION or KUBE_UBUNTU_INSTALL_RUNC_VERSION
  99. # is set to empty then we do not override the version(s) and just
  100. # use whatever is in the default installation of containerd package
  101. UBUNTU_INSTALL_CONTAINERD_VERSION=${KUBE_UBUNTU_INSTALL_CONTAINERD_VERSION:-}
  102. UBUNTU_INSTALL_RUNC_VERSION=${KUBE_UBUNTU_INSTALL_RUNC_VERSION:-}
  103. # MASTER_EXTRA_METADATA is the extra instance metadata on master instance separated by commas.
  104. MASTER_EXTRA_METADATA=${KUBE_MASTER_EXTRA_METADATA:-${KUBE_EXTRA_METADATA:-}}
  105. # MASTER_EXTRA_METADATA is the extra instance metadata on node instance separated by commas.
  106. NODE_EXTRA_METADATA=${KUBE_NODE_EXTRA_METADATA:-${KUBE_EXTRA_METADATA:-}}
  107. NETWORK=${KUBE_GCE_NETWORK:-e2e-test-${USER}}
  108. if [[ "${CREATE_CUSTOM_NETWORK}" == true ]]; then
  109. SUBNETWORK="${SUBNETWORK:-${NETWORK}-custom-subnet}"
  110. fi
  111. INSTANCE_PREFIX="${KUBE_GCE_INSTANCE_PREFIX:-e2e-test-${USER}}"
  112. CLUSTER_NAME="${CLUSTER_NAME:-${INSTANCE_PREFIX}}"
  113. MASTER_NAME="${INSTANCE_PREFIX}-master"
  114. AGGREGATOR_MASTER_NAME="${INSTANCE_PREFIX}-aggregator"
  115. INITIAL_ETCD_CLUSTER="${MASTER_NAME}"
  116. MASTER_TAG="${INSTANCE_PREFIX}-master"
  117. NODE_TAG="${INSTANCE_PREFIX}-minion"
  118. CLUSTER_IP_RANGE="${CLUSTER_IP_RANGE:-$(get-cluster-ip-range)}"
  119. MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}"
  120. # NODE_IP_RANGE is used when ENABLE_IP_ALIASES=true or CREATE_CUSTOM_NETWORK=true.
  121. # It is the primary range in the subnet and is the range used for node instance IPs.
  122. NODE_IP_RANGE="$(get-node-ip-range)"
  123. RUNTIME_CONFIG="${KUBE_RUNTIME_CONFIG:-}"
  124. if [[ "${KUBE_FEATURE_GATES:-}" == "AllAlpha=true" ]]; then
  125. RUNTIME_CONFIG="${KUBE_RUNTIME_CONFIG:-api/all=true}"
  126. fi
  127. # If feature gates includes AllAlpha or EndpointSlice, and EndpointSlice has not been disabled, add EndpointSlice controller to list of controllers to run.
  128. if [[ (( "${KUBE_FEATURE_GATES:-}" == *"AllAlpha=true"* ) || ( "${KUBE_FEATURE_GATES:-}" == *"EndpointSlice=true"* )) && "${KUBE_FEATURE_GATES:-}" != *"EndpointSlice=false"* ]]; then
  129. RUN_CONTROLLERS="${RUN_CONTROLLERS:-*,endpointslice}"
  130. fi
  131. # Optional: set feature gates
  132. FEATURE_GATES="${KUBE_FEATURE_GATES:-}"
  133. TERMINATED_POD_GC_THRESHOLD=${TERMINATED_POD_GC_THRESHOLD:-100}
  134. # Extra docker options for nodes.
  135. EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS:-}"
  136. # Enable the docker debug mode.
  137. EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS} --debug"
  138. SERVICE_CLUSTER_IP_RANGE="10.0.0.0/16" # formerly PORTAL_NET
  139. # When set to true, Docker Cache is enabled by default as part of the cluster bring up.
  140. ENABLE_DOCKER_REGISTRY_CACHE=true
  141. # Optional: Deploy a L7 loadbalancer controller to fulfill Ingress requests:
  142. # glbc - CE L7 Load Balancer Controller
  143. ENABLE_L7_LOADBALANCING="${KUBE_ENABLE_L7_LOADBALANCING:-glbc}"
  144. # Optional: Enable Metrics Server. Metrics Server should be enable everywhere,
  145. # since it's a critical component, but in the first release we need a way to disable
  146. # this in case of stability issues.
  147. # TODO(piosz) remove this option once Metrics Server became a stable thing.
  148. ENABLE_METRICS_SERVER="${KUBE_ENABLE_METRICS_SERVER:-true}"
  149. # Optional: Metadata agent to setup as part of the cluster bring up:
  150. # none - No metadata agent
  151. # stackdriver - Stackdriver metadata agent
  152. # Metadata agent is a daemon set that provides metadata of kubernetes objects
  153. # running on the same node for exporting metrics and logs.
  154. ENABLE_METADATA_AGENT="${KUBE_ENABLE_METADATA_AGENT:-none}"
  155. # One special node out of NUM_NODES would be created of this type if specified.
  156. # Useful for scheduling heapster in large clusters with nodes of small size.
  157. HEAPSTER_MACHINE_TYPE="${HEAPSTER_MACHINE_TYPE:-}"
  158. # Optional: Additional nodes would be created if their type and number is specified.
  159. # NUM_NODES would be lowered respectively.
  160. # Useful for running cluster-level addons that needs more resources than would fit
  161. # on small nodes, like network plugins.
  162. NUM_ADDITIONAL_NODES="${NUM_ADDITIONAL_NODES:-}"
  163. ADDITIONAL_MACHINE_TYPE="${ADDITIONAL_MACHINE_TYPE:-}"
  164. # Set etcd image (e.g. k8s.gcr.io/etcd) and version (e.g. 3.4.3-0) if you need
  165. # non-default version.
  166. ETCD_IMAGE="${TEST_ETCD_IMAGE:-}"
  167. ETCD_DOCKER_REPOSITORY="${TEST_ETCD_DOCKER_REPOSITORY:-}"
  168. ETCD_VERSION="${TEST_ETCD_VERSION:-}"
  169. # Default Log level for all components in test clusters and variables to override it in specific components.
  170. TEST_CLUSTER_LOG_LEVEL="${TEST_CLUSTER_LOG_LEVEL:---v=4}"
  171. KUBELET_TEST_LOG_LEVEL="${KUBELET_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL}"
  172. DOCKER_TEST_LOG_LEVEL="${DOCKER_TEST_LOG_LEVEL:---log-level=info}"
  173. API_SERVER_TEST_LOG_LEVEL="${API_SERVER_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL}"
  174. CONTROLLER_MANAGER_TEST_LOG_LEVEL="${CONTROLLER_MANAGER_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL}"
  175. SCHEDULER_TEST_LOG_LEVEL="${SCHEDULER_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL}"
  176. KUBEPROXY_TEST_LOG_LEVEL="${KUBEPROXY_TEST_LOG_LEVEL:-$TEST_CLUSTER_LOG_LEVEL}"
  177. VOLUME_PLUGIN_DIR="${VOLUME_PLUGIN_DIR:-/home/kubernetes/flexvolume}"
  178. TEST_CLUSTER_DELETE_COLLECTION_WORKERS="${TEST_CLUSTER_DELETE_COLLECTION_WORKERS:---delete-collection-workers=1}"
  179. TEST_CLUSTER_MAX_REQUESTS_INFLIGHT="${TEST_CLUSTER_MAX_REQUESTS_INFLIGHT:-}"
  180. TEST_CLUSTER_RESYNC_PERIOD="${TEST_CLUSTER_RESYNC_PERIOD:---min-resync-period=3m}"
  181. # ContentType used by all components to communicate with apiserver.
  182. TEST_CLUSTER_API_CONTENT_TYPE="${TEST_CLUSTER_API_CONTENT_TYPE:-}"
  183. KUBELET_TEST_ARGS="${KUBELET_TEST_ARGS:-} --serialize-image-pulls=false ${TEST_CLUSTER_API_CONTENT_TYPE}"
  184. if [[ "${NODE_OS_DISTRIBUTION}" == "gci" ]] || [[ "${NODE_OS_DISTRIBUTION}" == "ubuntu" ]] || [[ "${NODE_OS_DISTRIBUTION}" == "custom" ]]; then
  185. NODE_KUBELET_TEST_ARGS="${NODE_KUBELET_TEST_ARGS:-} --experimental-kernel-memcg-notification=true"
  186. fi
  187. if [[ "${MASTER_OS_DISTRIBUTION}" == "gci" ]] || [[ "${MASTER_OS_DISTRIBUTION}" == "ubuntu" ]]; then
  188. MASTER_KUBELET_TEST_ARGS="${MASTER_KUBELET_TEST_ARGS:-} --experimental-kernel-memcg-notification=true"
  189. fi
  190. APISERVER_TEST_ARGS="${APISERVER_TEST_ARGS:-} --runtime-config=extensions/v1beta1,scheduling.k8s.io/v1alpha1,settings.k8s.io/v1alpha1 ${TEST_CLUSTER_DELETE_COLLECTION_WORKERS} ${TEST_CLUSTER_MAX_REQUESTS_INFLIGHT}"
  191. CONTROLLER_MANAGER_TEST_ARGS="${CONTROLLER_MANAGER_TEST_ARGS:-} ${TEST_CLUSTER_RESYNC_PERIOD} ${TEST_CLUSTER_API_CONTENT_TYPE}"
  192. SCHEDULER_TEST_ARGS="${SCHEDULER_TEST_ARGS:-} ${TEST_CLUSTER_API_CONTENT_TYPE}"
  193. KUBEPROXY_TEST_ARGS="${KUBEPROXY_TEST_ARGS:-} ${TEST_CLUSTER_API_CONTENT_TYPE}"
  194. MASTER_NODE_LABELS="${KUBE_MASTER_NODE_LABELS:-}"
  195. # NON_MASTER_NODE_LABELS are labels will only be applied on non-master nodes.
  196. NON_MASTER_NODE_LABELS="${KUBE_NON_MASTER_NODE_LABELS:-}"
  197. WINDOWS_NON_MASTER_NODE_LABELS="${WINDOWS_NON_MASTER_NODE_LABELS:-}"
  198. if [[ "${PREEMPTIBLE_MASTER}" == "true" ]]; then
  199. NODE_LABELS="${NODE_LABELS},cloud.google.com/gke-preemptible=true"
  200. WINDOWS_NODE_LABELS="${WINDOWS_NODE_LABELS},cloud.google.com/gke-preemptible=true"
  201. elif [[ "${PREEMPTIBLE_NODE}" == "true" ]]; then
  202. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS},cloud.google.com/gke-preemptible=true"
  203. WINDOWS_NON_MASTER_NODE_LABELS="${WINDOWS_NON_MASTER_NODE_LABELS},cloud.google.com/gke-preemptible=true"
  204. fi
  205. # Optional: Enable netd.
  206. ENABLE_NETD="${KUBE_ENABLE_NETD:-false}"
  207. CUSTOM_NETD_YAML="${KUBE_CUSTOM_NETD_YAML:-}"
  208. CUSTOM_CALICO_NODE_DAEMONSET_YAML="${KUBE_CUSTOM_CALICO_NODE_DAEMONSET_YAML:-}"
  209. CUSTOM_TYPHA_DEPLOYMENT_YAML="${KUBE_CUSTOM_TYPHA_DEPLOYMENT_YAML:-}"
  210. # To avoid running netd on a node that is not configured appropriately,
  211. # label each Node so that the DaemonSet can run the Pods only on ready Nodes.
  212. # Windows nodes do not support netd.
  213. if [[ ${ENABLE_NETD:-} == "true" ]]; then
  214. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS:+${NON_MASTER_NODE_LABELS},}cloud.google.com/gke-netd-ready=true"
  215. fi
  216. ENABLE_NODELOCAL_DNS="${KUBE_ENABLE_NODELOCAL_DNS:-false}"
  217. # To avoid running Calico on a node that is not configured appropriately,
  218. # label each Node so that the DaemonSet can run the Pods only on ready Nodes.
  219. # Windows nodes do not support Calico.
  220. if [[ ${NETWORK_POLICY_PROVIDER:-} == "calico" ]]; then
  221. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS:+${NON_MASTER_NODE_LABELS},}projectcalico.org/ds-ready=true"
  222. fi
  223. # Enable metadata concealment by firewalling pod traffic to the metadata server
  224. # and run a proxy daemonset on nodes.
  225. ENABLE_METADATA_CONCEALMENT="${ENABLE_METADATA_CONCEALMENT:-true}" # true, false
  226. METADATA_CONCEALMENT_NO_FIREWALL="${METADATA_CONCEALMENT_NO_FIREWALL:-false}" # true, false
  227. if [[ ${ENABLE_METADATA_CONCEALMENT:-} == "true" ]]; then
  228. # Put the necessary label on the node so the daemonset gets scheduled.
  229. NODE_LABELS="${NODE_LABELS},cloud.google.com/metadata-proxy-ready=true"
  230. # Add to the provider custom variables.
  231. PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_METADATA_CONCEALMENT METADATA_CONCEALMENT_NO_FIREWALL"
  232. fi
  233. # Optional: Enable node logging.
  234. ENABLE_NODE_LOGGING="${KUBE_ENABLE_NODE_LOGGING:-true}"
  235. LOGGING_DESTINATION="${KUBE_LOGGING_DESTINATION:-gcp}" # options: elasticsearch, gcp
  236. # Optional: When set to true, Elasticsearch and Kibana will be setup as part of the cluster bring up.
  237. ENABLE_CLUSTER_LOGGING="${KUBE_ENABLE_CLUSTER_LOGGING:-true}"
  238. ELASTICSEARCH_LOGGING_REPLICAS=1
  239. # Optional: Don't require https for registries in our local RFC1918 network
  240. if [[ ${KUBE_ENABLE_INSECURE_REGISTRY:-false} == "true" ]]; then
  241. EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS} --insecure-registry 10.0.0.0/8"
  242. fi
  243. if [[ ! -z "${NODE_ACCELERATORS}" ]]; then
  244. if [[ -z "${FEATURE_GATES:-}" ]]; then
  245. FEATURE_GATES="DevicePlugins=true"
  246. else
  247. FEATURE_GATES="${FEATURE_GATES},DevicePlugins=true"
  248. fi
  249. if [[ "${NODE_ACCELERATORS}" =~ .*type=([a-zA-Z0-9-]+).* ]]; then
  250. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS},cloud.google.com/gke-accelerator=${BASH_REMATCH[1]}"
  251. fi
  252. fi
  253. # Optional: Install cluster DNS.
  254. # Set CLUSTER_DNS_CORE_DNS to 'false' to install kube-dns instead of CoreDNS.
  255. CLUSTER_DNS_CORE_DNS="${CLUSTER_DNS_CORE_DNS:-true}"
  256. ENABLE_CLUSTER_DNS="${KUBE_ENABLE_CLUSTER_DNS:-true}"
  257. DNS_SERVER_IP="10.0.0.10"
  258. LOCAL_DNS_IP="${KUBE_LOCAL_DNS_IP:-169.254.20.10}"
  259. DNS_DOMAIN="cluster.local"
  260. DNS_MEMORY_LIMIT="${KUBE_DNS_MEMORY_LIMIT:-170Mi}"
  261. # Optional: Enable DNS horizontal autoscaler
  262. ENABLE_DNS_HORIZONTAL_AUTOSCALER="${KUBE_ENABLE_DNS_HORIZONTAL_AUTOSCALER:-true}"
  263. # Optional: Install Kubernetes UI
  264. ENABLE_CLUSTER_UI="${KUBE_ENABLE_CLUSTER_UI:-true}"
  265. # Optional: Install node problem detector.
  266. # none - Not run node problem detector.
  267. # daemonset - Run node problem detector as daemonset.
  268. # standalone - Run node problem detector as standalone system daemon.
  269. if [[ "${NODE_OS_DISTRIBUTION}" == "gci" ]]; then
  270. # Enable standalone mode by default for gci.
  271. ENABLE_NODE_PROBLEM_DETECTOR="${KUBE_ENABLE_NODE_PROBLEM_DETECTOR:-standalone}"
  272. else
  273. ENABLE_NODE_PROBLEM_DETECTOR="${KUBE_ENABLE_NODE_PROBLEM_DETECTOR:-daemonset}"
  274. fi
  275. NODE_PROBLEM_DETECTOR_VERSION="${NODE_PROBLEM_DETECTOR_VERSION:-}"
  276. NODE_PROBLEM_DETECTOR_TAR_HASH="${NODE_PROBLEM_DETECTOR_TAR_HASH:-}"
  277. NODE_PROBLEM_DETECTOR_RELEASE_PATH="${NODE_PROBLEM_DETECTOR_RELEASE_PATH:-}"
  278. NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS="${NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS:-}"
  279. CNI_SHA1="${CNI_SHA1:-}"
  280. CNI_TAR_PREFIX="${CNI_TAR_PREFIX:-cni-plugins-linux-amd64-}"
  281. CNI_STORAGE_URL_BASE="${CNI_STORAGE_URL_BASE:-https://storage.googleapis.com/k8s-artifacts-cni/release}"
  282. # Optional: Create autoscaler for cluster's nodes.
  283. ENABLE_CLUSTER_AUTOSCALER="${KUBE_ENABLE_CLUSTER_AUTOSCALER:-false}"
  284. if [[ "${ENABLE_CLUSTER_AUTOSCALER}" == "true" ]]; then
  285. AUTOSCALER_MIN_NODES="${KUBE_AUTOSCALER_MIN_NODES:-}"
  286. AUTOSCALER_MAX_NODES="${KUBE_AUTOSCALER_MAX_NODES:-}"
  287. AUTOSCALER_ENABLE_SCALE_DOWN="${KUBE_AUTOSCALER_ENABLE_SCALE_DOWN:-false}"
  288. AUTOSCALER_EXPANDER_CONFIG="${KUBE_AUTOSCALER_EXPANDER_CONFIG:---expander=price}"
  289. fi
  290. # Optional: Enable allocation of pod IPs using IP aliases.
  291. #
  292. # BETA FEATURE.
  293. #
  294. # IP_ALIAS_SIZE is the size of the podCIDR allocated to a node.
  295. # IP_ALIAS_SUBNETWORK is the subnetwork to allocate from. If empty, a
  296. # new subnetwork will be created for the cluster.
  297. ENABLE_IP_ALIASES=${KUBE_GCE_ENABLE_IP_ALIASES:-false}
  298. NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-RangeAllocator}
  299. if [ ${ENABLE_IP_ALIASES} = true ]; then
  300. # Number of Pods that can run on this node.
  301. MAX_PODS_PER_NODE=${MAX_PODS_PER_NODE:-110}
  302. # Size of ranges allocated to each node.
  303. IP_ALIAS_SIZE="/$(get-alias-range-size ${MAX_PODS_PER_NODE})"
  304. IP_ALIAS_SUBNETWORK=${KUBE_GCE_IP_ALIAS_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-default}
  305. # If we're using custom network, use the subnet we already create for it as the one for ip-alias.
  306. # Note that this means SUBNETWORK would override KUBE_GCE_IP_ALIAS_SUBNETWORK in case of custom network.
  307. if [[ "${CREATE_CUSTOM_NETWORK}" == true ]]; then
  308. IP_ALIAS_SUBNETWORK="${SUBNETWORK}"
  309. fi
  310. # Reserve the services IP space to avoid being allocated for other GCP resources.
  311. SERVICE_CLUSTER_IP_SUBNETWORK=${KUBE_GCE_SERVICE_CLUSTER_IP_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-services}
  312. NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-CloudAllocator}
  313. SECONDARY_RANGE_NAME=${SECONDARY_RANGE_NAME:-}
  314. # Add to the provider custom variables.
  315. PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_IP_ALIASES"
  316. PROVIDER_VARS="${PROVIDER_VARS:-} NODE_IPAM_MODE"
  317. PROVIDER_VARS="${PROVIDER_VARS:-} SECONDARY_RANGE_NAME"
  318. elif [[ -n "${MAX_PODS_PER_NODE:-}" ]]; then
  319. # Should not have MAX_PODS_PER_NODE set for route-based clusters.
  320. echo -e "${color_red}Cannot set MAX_PODS_PER_NODE for route-based projects for ${PROJECT}." >&2
  321. exit 1
  322. fi
  323. # Enable GCE Alpha features.
  324. if [[ -n "${GCE_ALPHA_FEATURES:-}" ]]; then
  325. PROVIDER_VARS="${PROVIDER_VARS:-} GCE_ALPHA_FEATURES"
  326. fi
  327. # Disable Docker live-restore.
  328. if [[ -n "${DISABLE_DOCKER_LIVE_RESTORE:-}" ]]; then
  329. PROVIDER_VARS="${PROVIDER_VARS:-} DISABLE_DOCKER_LIVE_RESTORE"
  330. fi
  331. # Override default GLBC image
  332. if [[ -n "${GCE_GLBC_IMAGE:-}" ]]; then
  333. PROVIDER_VARS="${PROVIDER_VARS:-} GCE_GLBC_IMAGE"
  334. fi
  335. CUSTOM_INGRESS_YAML="${CUSTOM_INGRESS_YAML:-}"
  336. if [[ -z "${KUBE_ADMISSION_CONTROL:-}" ]]; then
  337. ADMISSION_CONTROL="NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,PodPreset,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,Priority,StorageObjectInUseProtection,PersistentVolumeClaimResize,RuntimeClass"
  338. if [[ "${ENABLE_POD_SECURITY_POLICY:-}" == "true" ]]; then
  339. ADMISSION_CONTROL="${ADMISSION_CONTROL},PodSecurityPolicy"
  340. fi
  341. # ResourceQuota must come last, or a creation is recorded, but the pod may be forbidden.
  342. ADMISSION_CONTROL="${ADMISSION_CONTROL},MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
  343. else
  344. ADMISSION_CONTROL=${KUBE_ADMISSION_CONTROL}
  345. fi
  346. ENABLE_APISERVER_DYNAMIC_AUDIT="${ENABLE_APISERVER_DYNAMIC_AUDIT:-false}"
  347. # Optional: if set to true kube-up will automatically check for existing resources and clean them up.
  348. KUBE_UP_AUTOMATIC_CLEANUP=${KUBE_UP_AUTOMATIC_CLEANUP:-false}
  349. # Optional: setting it to true denotes this is a testing cluster,
  350. # so that we can use pulled kubernetes binaries, even if binaries
  351. # are pre-installed in the image. Note that currently this logic
  352. # is only supported in trusty or GCI.
  353. TEST_CLUSTER="${TEST_CLUSTER:-true}"
  354. # Storage backend. 'etcd2' and 'etcd3' are supported.
  355. STORAGE_BACKEND=${STORAGE_BACKEND:-}
  356. # Storage media type: application/json and application/vnd.kubernetes.protobuf are supported.
  357. STORAGE_MEDIA_TYPE=${STORAGE_MEDIA_TYPE:-}
  358. NETWORK_PROVIDER="${NETWORK_PROVIDER:-kubenet}" # none, kubenet
  359. # Network Policy plugin specific settings.
  360. NETWORK_POLICY_PROVIDER="${NETWORK_POLICY_PROVIDER:-none}" # calico
  361. NON_MASQUERADE_CIDR="0.0.0.0/0"
  362. # How should the kubelet configure hairpin mode?
  363. HAIRPIN_MODE="${HAIRPIN_MODE:-hairpin-veth}" # promiscuous-bridge, hairpin-veth, none
  364. # Optional: if set to true, kube-up will configure the cluster to run e2e tests.
  365. E2E_STORAGE_TEST_ENVIRONMENT=${KUBE_E2E_STORAGE_TEST_ENVIRONMENT:-false}
  366. # Evict pods whenever compute resource availability on the nodes gets below a threshold.
  367. EVICTION_HARD="${EVICTION_HARD:-memory.available<250Mi,nodefs.available<10%,nodefs.inodesFree<5%}"
  368. # Optional: custom scheduling algorithm
  369. SCHEDULING_ALGORITHM_PROVIDER="${SCHEDULING_ALGORITHM_PROVIDER:-}"
  370. # Optional: install a default StorageClass
  371. ENABLE_DEFAULT_STORAGE_CLASS="${ENABLE_DEFAULT_STORAGE_CLASS:-true}"
  372. # Optional: install volume snapshot CRDs
  373. ENABLE_VOLUME_SNAPSHOTS="${ENABLE_VOLUME_SNAPSHOTS:-true}"
  374. # Optional: Enable legacy ABAC policy that makes all service accounts superusers.
  375. # Disabling this by default in tests ensures default RBAC policies are sufficient from 1.6+
  376. # Upgrade test jobs that go from a version < 1.6 to a version >= 1.6 should override this to be true.
  377. ENABLE_LEGACY_ABAC="${ENABLE_LEGACY_ABAC:-false}" # true, false
  378. # Enable a simple "AdvancedAuditing" setup for testing.
  379. ENABLE_APISERVER_ADVANCED_AUDIT="${ENABLE_APISERVER_ADVANCED_AUDIT:-true}" # true, false
  380. ADVANCED_AUDIT_LOG_MODE="${ADVANCED_AUDIT_LOG_MODE:-batch}" # batch, blocking
  381. ENABLE_BIG_CLUSTER_SUBNETS="${ENABLE_BIG_CLUSTER_SUBNETS:-false}"
  382. if [[ -n "${LOGROTATE_FILES_MAX_COUNT:-}" ]]; then
  383. PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_FILES_MAX_COUNT"
  384. fi
  385. if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then
  386. PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE"
  387. fi
  388. if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then
  389. PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE"
  390. fi
  391. if [[ -n "${POD_LOG_MAX_SIZE:-}" ]]; then
  392. PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_SIZE"
  393. fi
  394. # Fluentd requirements
  395. # YAML exists to trigger a configuration refresh when changes are made.
  396. FLUENTD_GCP_YAML_VERSION="v3.2.0"
  397. FLUENTD_GCP_VERSION="${FLUENTD_GCP_VERSION:-1.6.17}"
  398. FLUENTD_GCP_MEMORY_LIMIT="${FLUENTD_GCP_MEMORY_LIMIT:-}"
  399. FLUENTD_GCP_CPU_REQUEST="${FLUENTD_GCP_CPU_REQUEST:-}"
  400. FLUENTD_GCP_MEMORY_REQUEST="${FLUENTD_GCP_MEMORY_REQUEST:-}"
  401. # Heapster requirements
  402. HEAPSTER_GCP_BASE_MEMORY="${HEAPSTER_GCP_BASE_MEMORY:-140Mi}"
  403. HEAPSTER_GCP_MEMORY_PER_NODE="${HEAPSTER_GCP_MEMORY_PER_NODE:-4}"
  404. HEAPSTER_GCP_BASE_CPU="${HEAPSTER_GCP_BASE_CPU:-80m}"
  405. HEAPSTER_GCP_CPU_PER_NODE="${HEAPSTER_GCP_CPU_PER_NODE:-0.5}"
  406. # Optional: custom system banner for dashboard addon
  407. CUSTOM_KUBE_DASHBOARD_BANNER="${CUSTOM_KUBE_DASHBOARD_BANNER:-}"
  408. # Default Stackdriver resources version exported by Fluentd-gcp addon
  409. LOGGING_STACKDRIVER_RESOURCE_TYPES="${LOGGING_STACKDRIVER_RESOURCE_TYPES:-old}"
  410. # Adding to PROVIDER_VARS, since this is GCP-specific.
  411. 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 CUSTOM_KUBE_DASHBOARD_BANNER LOGGING_STACKDRIVER_RESOURCE_TYPES"
  412. # Fluentd configuration for node-journal
  413. ENABLE_NODE_JOURNAL="${ENABLE_NODE_JOURNAL:-false}"
  414. # prometheus-to-sd configuration
  415. PROMETHEUS_TO_SD_ENDPOINT="${PROMETHEUS_TO_SD_ENDPOINT:-https://monitoring.googleapis.com/}"
  416. PROMETHEUS_TO_SD_PREFIX="${PROMETHEUS_TO_SD_PREFIX:-custom.googleapis.com}"
  417. ENABLE_PROMETHEUS_TO_SD="${ENABLE_PROMETHEUS_TO_SD:-true}"
  418. # TODO(#51292): Make kube-proxy Daemonset default and remove the configuration here.
  419. # Optional: [Experiment Only] Run kube-proxy as a DaemonSet if set to true, run as static pods otherwise.
  420. KUBE_PROXY_DAEMONSET="${KUBE_PROXY_DAEMONSET:-false}" # true, false
  421. # Optional: Change the kube-proxy implementation. Choices are [iptables, ipvs].
  422. KUBE_PROXY_MODE="${KUBE_PROXY_MODE:-iptables}"
  423. # Optional: duration of cluster signed certificates.
  424. CLUSTER_SIGNING_DURATION="${CLUSTER_SIGNING_DURATION:-}"
  425. # Optional: enable certificate rotation of the kubelet certificates.
  426. ROTATE_CERTIFICATES="${ROTATE_CERTIFICATES:-}"
  427. # The number of services that are allowed to sync concurrently. Will be passed
  428. # into kube-controller-manager via `--concurrent-service-syncs`
  429. CONCURRENT_SERVICE_SYNCS="${CONCURRENT_SERVICE_SYNCS:-}"
  430. SERVICEACCOUNT_ISSUER="https://kubernetes.io/${CLUSTER_NAME}"
  431. # Optional: Enable Node termination Handler for Preemptible and GPU VMs.
  432. # https://github.com/GoogleCloudPlatform/k8s-node-termination-handler
  433. ENABLE_NODE_TERMINATION_HANDLER="${ENABLE_NODE_TERMINATION_HANDLER:-false}"
  434. # Override default Node Termination Handler Image
  435. if [[ "${NODE_TERMINATION_HANDLER_IMAGE:-}" ]]; then
  436. PROVIDER_VARS="${PROVIDER_VARS:-} NODE_TERMINATION_HANDLER_IMAGE"
  437. fi
  438. # Taint Windows nodes by default to prevent Linux workloads from being
  439. # scheduled onto them.
  440. WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSchedule}"
  441. # Whether to set up a private GCE cluster, i.e. a cluster where nodes have only private IPs.
  442. GCE_PRIVATE_CLUSTER="${KUBE_GCE_PRIVATE_CLUSTER:-false}"
  443. GCE_PRIVATE_CLUSTER_PORTS_PER_VM="${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-}"
  444. ETCD_LISTEN_CLIENT_IP=0.0.0.0
  445. GCE_UPLOAD_KUBCONFIG_TO_MASTER_METADATA=true