config-default.sh 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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. # Accelerators to be attached to each node. Format "type=<accelerator-type>,count=<accelerator-count>"
  49. # More information on available GPUs here - https://cloud.google.com/compute/docs/gpus/
  50. NODE_ACCELERATORS=${NODE_ACCELERATORS:-""}
  51. REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-true}
  52. PREEMPTIBLE_NODE=${PREEMPTIBLE_NODE:-false}
  53. PREEMPTIBLE_MASTER=${PREEMPTIBLE_MASTER:-false}
  54. KUBE_DELETE_NODES=${KUBE_DELETE_NODES:-true}
  55. KUBE_DELETE_NETWORK=${KUBE_DELETE_NETWORK:-} # default value calculated below
  56. CREATE_CUSTOM_NETWORK=${CREATE_CUSTOM_NETWORK:-false}
  57. MIG_WAIT_UNTIL_STABLE_TIMEOUT=${MIG_WAIT_UNTIL_STABLE_TIMEOUT:-1800}
  58. MASTER_OS_DISTRIBUTION=${KUBE_MASTER_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}}
  59. NODE_OS_DISTRIBUTION=${KUBE_NODE_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}}
  60. WINDOWS_NODE_OS_DISTRIBUTION=${WINDOWS_NODE_OS_DISTRIBUTION:-win2019}
  61. if [[ "${MASTER_OS_DISTRIBUTION}" == "cos" ]]; then
  62. MASTER_OS_DISTRIBUTION="gci"
  63. fi
  64. if [[ "${NODE_OS_DISTRIBUTION}" == "cos" ]]; then
  65. NODE_OS_DISTRIBUTION="gci"
  66. fi
  67. # GPUs supported in GCE do not have compatible drivers in Debian 7.
  68. if [[ "${NODE_OS_DISTRIBUTION}" == "debian" ]]; then
  69. NODE_ACCELERATORS=""
  70. fi
  71. # By default a cluster will be started with the master and nodes
  72. # on Container-optimized OS (cos, previously known as gci). If
  73. # you are updating the os image versions, update this variable.
  74. # Also please update corresponding image for node e2e at:
  75. # https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/jenkins/image-config.yaml
  76. GCI_VERSION=${KUBE_GCI_VERSION:-cos-77-12371-175-0}
  77. MASTER_IMAGE=${KUBE_GCE_MASTER_IMAGE:-}
  78. MASTER_IMAGE_PROJECT=${KUBE_GCE_MASTER_PROJECT:-cos-cloud}
  79. NODE_IMAGE=${KUBE_GCE_NODE_IMAGE:-${GCI_VERSION}}
  80. NODE_IMAGE_PROJECT=${KUBE_GCE_NODE_PROJECT:-cos-cloud}
  81. NODE_SERVICE_ACCOUNT=${KUBE_GCE_NODE_SERVICE_ACCOUNT:-default}
  82. # KUBELET_TEST_ARGS are extra arguments passed to kubelet.
  83. KUBELET_TEST_ARGS=${KUBE_KUBELET_EXTRA_ARGS:-}
  84. CONTAINER_RUNTIME=${KUBE_CONTAINER_RUNTIME:-docker}
  85. CONTAINER_RUNTIME_ENDPOINT=${KUBE_CONTAINER_RUNTIME_ENDPOINT:-}
  86. CONTAINER_RUNTIME_NAME=${KUBE_CONTAINER_RUNTIME_NAME:-}
  87. LOAD_IMAGE_COMMAND=${KUBE_LOAD_IMAGE_COMMAND:-}
  88. if [[ "${CONTAINER_RUNTIME}" == "containerd" ]]; then
  89. CONTAINER_RUNTIME_NAME=${KUBE_CONTAINER_RUNTIME_NAME:-containerd}
  90. LOAD_IMAGE_COMMAND=${KUBE_LOAD_IMAGE_COMMAND:-ctr -n=k8s.io images import}
  91. fi
  92. # Ability to inject custom versions (Ubuntu OS images ONLY)
  93. # if KUBE_UBUNTU_INSTALL_CONTAINERD_VERSION or KUBE_UBUNTU_INSTALL_RUNC_VERSION
  94. # is set to empty then we do not override the version(s) and just
  95. # use whatever is in the default installation of containerd package
  96. UBUNTU_INSTALL_CONTAINERD_VERSION=${KUBE_UBUNTU_INSTALL_CONTAINERD_VERSION:-}
  97. UBUNTU_INSTALL_RUNC_VERSION=${KUBE_UBUNTU_INSTALL_RUNC_VERSION:-}
  98. # MASTER_EXTRA_METADATA is the extra instance metadata on master instance separated by commas.
  99. MASTER_EXTRA_METADATA=${KUBE_MASTER_EXTRA_METADATA:-${KUBE_EXTRA_METADATA:-}}
  100. # MASTER_EXTRA_METADATA is the extra instance metadata on node instance separated by commas.
  101. NODE_EXTRA_METADATA=${KUBE_NODE_EXTRA_METADATA:-${KUBE_EXTRA_METADATA:-}}
  102. NETWORK=${KUBE_GCE_NETWORK:-default}
  103. # Enable network deletion by default (for kube-down), unless we're using 'default' network.
  104. if [[ "${NETWORK}" == "default" ]]; then
  105. KUBE_DELETE_NETWORK=${KUBE_DELETE_NETWORK:-false}
  106. else
  107. KUBE_DELETE_NETWORK=${KUBE_DELETE_NETWORK:-true}
  108. fi
  109. if [[ "${CREATE_CUSTOM_NETWORK}" == true ]]; then
  110. SUBNETWORK="${SUBNETWORK:-${NETWORK}-custom-subnet}"
  111. fi
  112. INSTANCE_PREFIX="${KUBE_GCE_INSTANCE_PREFIX:-kubernetes}"
  113. CLUSTER_NAME="${CLUSTER_NAME:-${INSTANCE_PREFIX}}"
  114. MASTER_NAME="${INSTANCE_PREFIX}-master"
  115. AGGREGATOR_MASTER_NAME="${INSTANCE_PREFIX}-aggregator"
  116. INITIAL_ETCD_CLUSTER="${MASTER_NAME}"
  117. MASTER_TAG="${INSTANCE_PREFIX}-master"
  118. NODE_TAG="${INSTANCE_PREFIX}-minion"
  119. CLUSTER_IP_RANGE="${CLUSTER_IP_RANGE:-$(get-cluster-ip-range)}"
  120. MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}"
  121. # NODE_IP_RANGE is used when ENABLE_IP_ALIASES=true or CREATE_CUSTOM_NETWORK=true.
  122. # It is the primary range in the subnet and is the range used for node instance IPs.
  123. NODE_IP_RANGE="$(get-node-ip-range)"
  124. # NOTE: Avoid giving nodes empty scopes, because kubelet needs a service account
  125. # in order to initialize properly.
  126. NODE_SCOPES="${NODE_SCOPES:-monitoring,logging-write,storage-ro}"
  127. # Extra docker options for nodes.
  128. EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS:-}"
  129. VOLUME_PLUGIN_DIR="${VOLUME_PLUGIN_DIR:-/home/kubernetes/flexvolume}"
  130. SERVICE_CLUSTER_IP_RANGE="${SERVICE_CLUSTER_IP_RANGE:-10.0.0.0/16}" # formerly PORTAL_NET
  131. ALLOCATE_NODE_CIDRS=true
  132. # When set to true, Docker Cache is enabled by default as part of the cluster bring up.
  133. ENABLE_DOCKER_REGISTRY_CACHE=true
  134. # Optional: Deploy a L7 loadbalancer controller to fulfill Ingress requests:
  135. # glbc - CE L7 Load Balancer Controller
  136. ENABLE_L7_LOADBALANCING="${KUBE_ENABLE_L7_LOADBALANCING:-glbc}"
  137. # Optional: Enable Metrics Server. Metrics Server should be enable everywhere,
  138. # since it's a critical component, but in the first release we need a way to disable
  139. # this in case of stability issues.
  140. # TODO(piosz) remove this option once Metrics Server became a stable thing.
  141. ENABLE_METRICS_SERVER="${KUBE_ENABLE_METRICS_SERVER:-true}"
  142. # Optional: Metadata agent to setup as part of the cluster bring up:
  143. # none - No metadata agent
  144. # stackdriver - Stackdriver metadata agent
  145. # Metadata agent is a daemon set that provides metadata of kubernetes objects
  146. # running on the same node for exporting metrics and logs.
  147. ENABLE_METADATA_AGENT="${KUBE_ENABLE_METADATA_AGENT:-none}"
  148. # One special node out of NUM_NODES would be created of this type if specified.
  149. # Useful for scheduling heapster in large clusters with nodes of small size.
  150. HEAPSTER_MACHINE_TYPE="${HEAPSTER_MACHINE_TYPE:-}"
  151. # Optional: Additional nodes would be created if their type and number is specified.
  152. # NUM_NODES would be lowered respectively.
  153. # Useful for running cluster-level addons that needs more resources than would fit
  154. # on small nodes, like network plugins.
  155. NUM_ADDITIONAL_NODES="${NUM_ADDITIONAL_NODES:-}"
  156. ADDITIONAL_MACHINE_TYPE="${ADDITIONAL_MACHINE_TYPE:-}"
  157. MASTER_NODE_LABELS="${KUBE_MASTER_NODE_LABELS:-}"
  158. # NON_MASTER_NODE_LABELS are labels will only be applied on non-master nodes.
  159. NON_MASTER_NODE_LABELS="${KUBE_NON_MASTER_NODE_LABELS:-}"
  160. WINDOWS_NON_MASTER_NODE_LABELS="${WINDOWS_NON_MASTER_NODE_LABELS:-}"
  161. if [[ "${PREEMPTIBLE_MASTER}" == "true" ]]; then
  162. NODE_LABELS="${NODE_LABELS},cloud.google.com/gke-preemptible=true"
  163. WINDOWS_NODE_LABELS="${WINDOWS_NODE_LABELS},cloud.google.com/gke-preemptible=true"
  164. elif [[ "${PREEMPTIBLE_NODE}" == "true" ]]; then
  165. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS},cloud.google.com/gke-preemptible=true"
  166. WINDOWS_NON_MASTER_NODE_LABELS="${WINDOWS_NON_MASTER_NODE_LABELS},cloud.google.com/gke-preemptible=true"
  167. fi
  168. # To avoid running Calico on a node that is not configured appropriately,
  169. # label each Node so that the DaemonSet can run the Pods only on ready Nodes.
  170. # Windows nodes do not support Calico.
  171. if [[ ${NETWORK_POLICY_PROVIDER:-} == "calico" ]]; then
  172. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS:+${NON_MASTER_NODE_LABELS},}projectcalico.org/ds-ready=true"
  173. fi
  174. # Optional: Enable netd.
  175. ENABLE_NETD="${KUBE_ENABLE_NETD:-false}"
  176. CUSTOM_NETD_YAML="${KUBE_CUSTOM_NETD_YAML:-}"
  177. CUSTOM_CALICO_NODE_DAEMONSET_YAML="${KUBE_CUSTOM_CALICO_NODE_DAEMONSET_YAML:-}"
  178. CUSTOM_TYPHA_DEPLOYMENT_YAML="${KUBE_CUSTOM_TYPHA_DEPLOYMENT_YAML:-}"
  179. # To avoid running netd on a node that is not configured appropriately,
  180. # label each Node so that the DaemonSet can run the Pods only on ready Nodes.
  181. # Windows nodes do not support netd.
  182. if [[ ${ENABLE_NETD:-} == "true" ]]; then
  183. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS:+${NON_MASTER_NODE_LABELS},}cloud.google.com/gke-netd-ready=true"
  184. fi
  185. ENABLE_NODELOCAL_DNS="${KUBE_ENABLE_NODELOCAL_DNS:-false}"
  186. LOCAL_DNS_IP="${KUBE_LOCAL_DNS_IP:-169.254.20.10}"
  187. # Enable metadata concealment by firewalling pod traffic to the metadata server
  188. # and run a proxy daemonset on nodes.
  189. #
  190. # TODO(#8867) Enable by default.
  191. ENABLE_METADATA_CONCEALMENT="${ENABLE_METADATA_CONCEALMENT:-false}" # true, false
  192. METADATA_CONCEALMENT_NO_FIREWALL="${METADATA_CONCEALMENT_NO_FIREWALL:-false}" # true, false
  193. if [[ ${ENABLE_METADATA_CONCEALMENT:-} == "true" ]]; then
  194. # Put the necessary label on the node so the daemonset gets scheduled.
  195. NODE_LABELS="${NODE_LABELS},cloud.google.com/metadata-proxy-ready=true"
  196. # Add to the provider custom variables.
  197. PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_METADATA_CONCEALMENT METADATA_CONCEALMENT_NO_FIREWALL"
  198. fi
  199. # Optional: Enable node logging.
  200. ENABLE_NODE_LOGGING="${KUBE_ENABLE_NODE_LOGGING:-true}"
  201. LOGGING_DESTINATION="${KUBE_LOGGING_DESTINATION:-gcp}" # options: elasticsearch, gcp
  202. # Optional: When set to true, Elasticsearch and Kibana will be setup as part of the cluster bring up.
  203. ENABLE_CLUSTER_LOGGING="${KUBE_ENABLE_CLUSTER_LOGGING:-true}"
  204. ELASTICSEARCH_LOGGING_REPLICAS=1
  205. # Optional: Don't require https for registries in our local RFC1918 network
  206. if [[ ${KUBE_ENABLE_INSECURE_REGISTRY:-false} == "true" ]]; then
  207. EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS} --insecure-registry 10.0.0.0/8"
  208. fi
  209. # Optional: customize runtime config
  210. RUNTIME_CONFIG="${KUBE_RUNTIME_CONFIG:-}"
  211. if [[ "${KUBE_FEATURE_GATES:-}" == "AllAlpha=true" ]]; then
  212. RUNTIME_CONFIG="${KUBE_RUNTIME_CONFIG:-api/all=true}"
  213. fi
  214. # If feature gates includes AllAlpha or EndpointSlice, and EndpointSlice has not been disabled, add EndpointSlice controller to list of controllers to run.
  215. if [[ (( "${KUBE_FEATURE_GATES:-}" == *"AllAlpha=true"* ) || ( "${KUBE_FEATURE_GATES:-}" == *"EndpointSlice=true"* )) && "${KUBE_FEATURE_GATES:-}" != *"EndpointSlice=false"* ]]; then
  216. RUN_CONTROLLERS="${RUN_CONTROLLERS:-*,endpointslice}"
  217. fi
  218. # Optional: set feature gates
  219. FEATURE_GATES="${KUBE_FEATURE_GATES:-}"
  220. if [[ ! -z "${NODE_ACCELERATORS}" ]]; then
  221. if [[ -z "${FEATURE_GATES:-}" ]]; then
  222. FEATURE_GATES="DevicePlugins=true"
  223. else
  224. FEATURE_GATES="${FEATURE_GATES},DevicePlugins=true"
  225. fi
  226. if [[ "${NODE_ACCELERATORS}" =~ .*type=([a-zA-Z0-9-]+).* ]]; then
  227. NON_MASTER_NODE_LABELS="${NON_MASTER_NODE_LABELS},cloud.google.com/gke-accelerator=${BASH_REMATCH[1]}"
  228. fi
  229. fi
  230. # Optional: Install cluster DNS.
  231. # Set CLUSTER_DNS_CORE_DNS to 'false' to install kube-dns instead of CoreDNS.
  232. CLUSTER_DNS_CORE_DNS="${CLUSTER_DNS_CORE_DNS:-true}"
  233. ENABLE_CLUSTER_DNS="${KUBE_ENABLE_CLUSTER_DNS:-true}"
  234. DNS_SERVER_IP="${KUBE_DNS_SERVER_IP:-10.0.0.10}"
  235. DNS_DOMAIN="${KUBE_DNS_DOMAIN:-cluster.local}"
  236. DNS_MEMORY_LIMIT="${KUBE_DNS_MEMORY_LIMIT:-170Mi}"
  237. # Optional: Enable DNS horizontal autoscaler
  238. ENABLE_DNS_HORIZONTAL_AUTOSCALER="${KUBE_ENABLE_DNS_HORIZONTAL_AUTOSCALER:-true}"
  239. # Optional: Install Kubernetes UI
  240. ENABLE_CLUSTER_UI="${KUBE_ENABLE_CLUSTER_UI:-true}"
  241. # Optional: Install node problem detector.
  242. # none - Not run node problem detector.
  243. # daemonset - Run node problem detector as daemonset.
  244. # standalone - Run node problem detector as standalone system daemon.
  245. if [[ "${NODE_OS_DISTRIBUTION}" == "gci" ]]; then
  246. # Enable standalone mode by default for gci.
  247. ENABLE_NODE_PROBLEM_DETECTOR="${KUBE_ENABLE_NODE_PROBLEM_DETECTOR:-standalone}"
  248. else
  249. ENABLE_NODE_PROBLEM_DETECTOR="${KUBE_ENABLE_NODE_PROBLEM_DETECTOR:-daemonset}"
  250. fi
  251. NODE_PROBLEM_DETECTOR_VERSION="${NODE_PROBLEM_DETECTOR_VERSION:-}"
  252. NODE_PROBLEM_DETECTOR_TAR_HASH="${NODE_PROBLEM_DETECTOR_TAR_HASH:-}"
  253. NODE_PROBLEM_DETECTOR_RELEASE_PATH="${NODE_PROBLEM_DETECTOR_RELEASE_PATH:-}"
  254. NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS="${NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS:-}"
  255. CNI_SHA1="${CNI_SHA1:-}"
  256. CNI_TAR_PREFIX="${CNI_TAR_PREFIX:-cni-plugins-linux-amd64-}"
  257. CNI_STORAGE_URL_BASE="${CNI_STORAGE_URL_BASE:-https://storage.googleapis.com/k8s-artifacts-cni/release}"
  258. # Optional: Create autoscaler for cluster's nodes.
  259. ENABLE_CLUSTER_AUTOSCALER="${KUBE_ENABLE_CLUSTER_AUTOSCALER:-false}"
  260. if [[ "${ENABLE_CLUSTER_AUTOSCALER}" == "true" ]]; then
  261. AUTOSCALER_MIN_NODES="${KUBE_AUTOSCALER_MIN_NODES:-}"
  262. AUTOSCALER_MAX_NODES="${KUBE_AUTOSCALER_MAX_NODES:-}"
  263. AUTOSCALER_ENABLE_SCALE_DOWN="${KUBE_AUTOSCALER_ENABLE_SCALE_DOWN:-true}"
  264. AUTOSCALER_EXPANDER_CONFIG="${KUBE_AUTOSCALER_EXPANDER_CONFIG:---expander=price}"
  265. fi
  266. # Optional: Enable allocation of pod IPs using IP aliases.
  267. #
  268. # BETA FEATURE.
  269. #
  270. # IP_ALIAS_SIZE is the size of the podCIDR allocated to a node.
  271. # IP_ALIAS_SUBNETWORK is the subnetwork to allocate from. If empty, a
  272. # new subnetwork will be created for the cluster.
  273. ENABLE_IP_ALIASES=${KUBE_GCE_ENABLE_IP_ALIASES:-false}
  274. NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-RangeAllocator}
  275. if [ ${ENABLE_IP_ALIASES} = true ]; then
  276. # Number of Pods that can run on this node.
  277. MAX_PODS_PER_NODE=${MAX_PODS_PER_NODE:-110}
  278. # Size of ranges allocated to each node.
  279. IP_ALIAS_SIZE="/$(get-alias-range-size ${MAX_PODS_PER_NODE})"
  280. IP_ALIAS_SUBNETWORK=${KUBE_GCE_IP_ALIAS_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-default}
  281. # If we're using custom network, use the subnet we already create for it as the one for ip-alias.
  282. # Note that this means SUBNETWORK would override KUBE_GCE_IP_ALIAS_SUBNETWORK in case of custom network.
  283. if [[ "${CREATE_CUSTOM_NETWORK}" == true ]]; then
  284. IP_ALIAS_SUBNETWORK="${SUBNETWORK}"
  285. fi
  286. # Reserve the services IP space to avoid being allocated for other GCP resources.
  287. SERVICE_CLUSTER_IP_SUBNETWORK=${KUBE_GCE_SERVICE_CLUSTER_IP_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-services}
  288. NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-CloudAllocator}
  289. SECONDARY_RANGE_NAME=${SECONDARY_RANGE_NAME:-}
  290. # Add to the provider custom variables.
  291. PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_IP_ALIASES"
  292. PROVIDER_VARS="${PROVIDER_VARS:-} NODE_IPAM_MODE"
  293. PROVIDER_VARS="${PROVIDER_VARS:-} SECONDARY_RANGE_NAME"
  294. elif [[ -n "${MAX_PODS_PER_NODE:-}" ]]; then
  295. # Should not have MAX_PODS_PER_NODE set for route-based clusters.
  296. echo -e "${color_red}Cannot set MAX_PODS_PER_NODE for route-based projects for ${PROJECT}." >&2
  297. exit 1
  298. fi
  299. # Enable GCE Alpha features.
  300. if [[ -n "${GCE_ALPHA_FEATURES:-}" ]]; then
  301. PROVIDER_VARS="${PROVIDER_VARS:-} GCE_ALPHA_FEATURES"
  302. fi
  303. # Disable Docker live-restore.
  304. if [[ -n "${DISABLE_DOCKER_LIVE_RESTORE:-}" ]]; then
  305. PROVIDER_VARS="${PROVIDER_VARS:-} DISABLE_DOCKER_LIVE_RESTORE"
  306. fi
  307. # Override default GLBC image
  308. if [[ -n "${GCE_GLBC_IMAGE:-}" ]]; then
  309. PROVIDER_VARS="${PROVIDER_VARS:-} GCE_GLBC_IMAGE"
  310. fi
  311. CUSTOM_INGRESS_YAML="${CUSTOM_INGRESS_YAML:-}"
  312. # Admission Controllers to invoke prior to persisting objects in cluster
  313. ADMISSION_CONTROL=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,PersistentVolumeClaimResize,DefaultTolerationSeconds,NodeRestriction,Priority,StorageObjectInUseProtection,RuntimeClass
  314. if [[ "${ENABLE_POD_SECURITY_POLICY:-}" == "true" ]]; then
  315. ADMISSION_CONTROL="${ADMISSION_CONTROL},PodSecurityPolicy"
  316. fi
  317. # MutatingAdmissionWebhook should be the last controller that modifies the
  318. # request object, otherwise users will be confused if the mutating webhooks'
  319. # modification is overwritten.
  320. ADMISSION_CONTROL="${ADMISSION_CONTROL},MutatingAdmissionWebhook,ValidatingAdmissionWebhook"
  321. # ResourceQuota must come last, or a creation is recorded, but the pod was forbidden.
  322. ADMISSION_CONTROL="${ADMISSION_CONTROL},ResourceQuota"
  323. # Optional: if set to true kube-up will automatically check for existing resources and clean them up.
  324. KUBE_UP_AUTOMATIC_CLEANUP=${KUBE_UP_AUTOMATIC_CLEANUP:-false}
  325. # Storage backend. 'etcd2' supported, 'etcd3' experimental.
  326. STORAGE_BACKEND=${STORAGE_BACKEND:-}
  327. # Networking plugin specific settings.
  328. NETWORK_PROVIDER="${NETWORK_PROVIDER:-kubenet}" # none, kubenet
  329. # Network Policy plugin specific settings.
  330. NETWORK_POLICY_PROVIDER="${NETWORK_POLICY_PROVIDER:-none}" # calico
  331. NON_MASQUERADE_CIDR="0.0.0.0/0"
  332. # How should the kubelet configure hairpin mode?
  333. HAIRPIN_MODE="${HAIRPIN_MODE:-hairpin-veth}" # promiscuous-bridge, hairpin-veth, none
  334. # Optional: if set to true, kube-up will configure the cluster to run e2e tests.
  335. E2E_STORAGE_TEST_ENVIRONMENT="${KUBE_E2E_STORAGE_TEST_ENVIRONMENT:-false}"
  336. # Evict pods whenever compute resource availability on the nodes gets below a threshold.
  337. EVICTION_HARD="${EVICTION_HARD:-memory.available<250Mi,nodefs.available<10%,nodefs.inodesFree<5%}"
  338. # Optional: custom scheduling algorithm
  339. SCHEDULING_ALGORITHM_PROVIDER="${SCHEDULING_ALGORITHM_PROVIDER:-}"
  340. # Optional: install a default StorageClass
  341. ENABLE_DEFAULT_STORAGE_CLASS="${ENABLE_DEFAULT_STORAGE_CLASS:-true}"
  342. # Optional: install volume snapshot CRDs
  343. ENABLE_VOLUME_SNAPSHOTS="${ENABLE_VOLUME_SNAPSHOTS:-true}"
  344. # Optional: Enable legacy ABAC policy that makes all service accounts superusers.
  345. ENABLE_LEGACY_ABAC="${ENABLE_LEGACY_ABAC:-false}" # true, false
  346. # Indicates if the values (i.e. KUBE_USER and KUBE_PASSWORD for basic
  347. # authentication) in metadata should be treated as canonical, and therefore disk
  348. # copies ought to be recreated/clobbered.
  349. METADATA_CLOBBERS_CONFIG="${METADATA_CLOBBERS_CONFIG:-false}"
  350. ENABLE_BIG_CLUSTER_SUBNETS="${ENABLE_BIG_CLUSTER_SUBNETS:-false}"
  351. if [[ -n "${LOGROTATE_FILES_MAX_COUNT:-}" ]]; then
  352. PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_FILES_MAX_COUNT"
  353. fi
  354. if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then
  355. PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE"
  356. fi
  357. if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then
  358. PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE"
  359. fi
  360. if [[ -n "${POD_LOG_MAX_SIZE:-}" ]]; then
  361. PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_SIZE"
  362. fi
  363. # Fluentd requirements
  364. # YAML exists to trigger a configuration refresh when changes are made.
  365. FLUENTD_GCP_YAML_VERSION="v3.2.0"
  366. FLUENTD_GCP_VERSION="${FLUENTD_GCP_VERSION:-1.6.17}"
  367. FLUENTD_GCP_MEMORY_LIMIT="${FLUENTD_GCP_MEMORY_LIMIT:-}"
  368. FLUENTD_GCP_CPU_REQUEST="${FLUENTD_GCP_CPU_REQUEST:-}"
  369. FLUENTD_GCP_MEMORY_REQUEST="${FLUENTD_GCP_MEMORY_REQUEST:-}"
  370. # Heapster requirements
  371. HEAPSTER_GCP_BASE_MEMORY="${HEAPSTER_GCP_BASE_MEMORY:-140Mi}"
  372. HEAPSTER_GCP_MEMORY_PER_NODE="${HEAPSTER_GCP_MEMORY_PER_NODE:-4}"
  373. HEAPSTER_GCP_BASE_CPU="${HEAPSTER_GCP_BASE_CPU:-80m}"
  374. HEAPSTER_GCP_CPU_PER_NODE="${HEAPSTER_GCP_CPU_PER_NODE:-0.5}"
  375. # Optional: custom system banner for dashboard addon
  376. CUSTOM_KUBE_DASHBOARD_BANNER="${CUSTOM_KUBE_DASHBOARD_BANNER:-}"
  377. # Default Stackdriver resources version exported by Fluentd-gcp addon
  378. LOGGING_STACKDRIVER_RESOURCE_TYPES="${LOGGING_STACKDRIVER_RESOURCE_TYPES:-old}"
  379. # Adding to PROVIDER_VARS, since this is GCP-specific.
  380. 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"
  381. # Fluentd configuration for node-journal
  382. ENABLE_NODE_JOURNAL="${ENABLE_NODE_JOURNAL:-false}"
  383. # prometheus-to-sd configuration
  384. PROMETHEUS_TO_SD_ENDPOINT="${PROMETHEUS_TO_SD_ENDPOINT:-https://monitoring.googleapis.com/}"
  385. PROMETHEUS_TO_SD_PREFIX="${PROMETHEUS_TO_SD_PREFIX:-custom.googleapis.com}"
  386. ENABLE_PROMETHEUS_TO_SD="${ENABLE_PROMETHEUS_TO_SD:-false}"
  387. # TODO(#51292): Make kube-proxy Daemonset default and remove the configuration here.
  388. # Optional: [Experiment Only] Run kube-proxy as a DaemonSet if set to true, run as static pods otherwise.
  389. KUBE_PROXY_DAEMONSET="${KUBE_PROXY_DAEMONSET:-false}" # true, false
  390. # Optional: duration of cluster signed certificates.
  391. CLUSTER_SIGNING_DURATION="${CLUSTER_SIGNING_DURATION:-}"
  392. # Optional: enable certificate rotation of the kubelet certificates.
  393. ROTATE_CERTIFICATES="${ROTATE_CERTIFICATES:-}"
  394. # The number of services that are allowed to sync concurrently. Will be passed
  395. # into kube-controller-manager via `--concurrent-service-syncs`
  396. CONCURRENT_SERVICE_SYNCS="${CONCURRENT_SERVICE_SYNCS:-}"
  397. SERVICEACCOUNT_ISSUER="https://kubernetes.io/${CLUSTER_NAME}"
  398. # Optional: Enable Node termination Handler for Preemptible and GPU VMs.
  399. # https://github.com/GoogleCloudPlatform/k8s-node-termination-handler
  400. ENABLE_NODE_TERMINATION_HANDLER="${ENABLE_NODE_TERMINATION_HANDLER:-false}"
  401. # Override default Node Termination Handler Image
  402. if [[ "${NODE_TERMINATION_HANDLER_IMAGE:-}" ]]; then
  403. PROVIDER_VARS="${PROVIDER_VARS:-} NODE_TERMINATION_HANDLER_IMAGE"
  404. fi
  405. # Taint Windows nodes by default to prevent Linux workloads from being
  406. # scheduled onto them.
  407. WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSchedule}"
  408. # Whether to set up a private GCE cluster, i.e. a cluster where nodes have only private IPs.
  409. GCE_PRIVATE_CLUSTER="${KUBE_GCE_PRIVATE_CLUSTER:-false}"
  410. GCE_PRIVATE_CLUSTER_PORTS_PER_VM="${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-}"
  411. # Optional: Create apiserver konnectivity server and agent.
  412. ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE="${KUBE_ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}"