k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cluster/gce/windows/node-helper.sh (about) 1 #!/usr/bin/env bash 2 3 # Copyright 2019 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 # A library of helper functions and constants for Windows nodes. 18 19 function get-windows-node-instance-metadata-from-file { 20 local metadata="" 21 metadata+="cluster-name=${KUBE_TEMP}/cluster-name.txt," 22 metadata+="cluster-location=${KUBE_TEMP}/cluster-location.txt," 23 metadata+="kube-env=${KUBE_TEMP}/windows-node-kube-env.yaml," 24 metadata+="kubelet-config=${KUBE_TEMP}/windows-node-kubelet-config.yaml," 25 # To get startup script output run "gcloud compute instances 26 # get-serial-port-output <instance>" from the location where you're running 27 # kube-up. 28 metadata+="windows-startup-script-ps1=${KUBE_ROOT}/cluster/gce/windows/configure.ps1," 29 metadata+="common-psm1=${KUBE_ROOT}/cluster/gce/windows/common.psm1," 30 metadata+="k8s-node-setup-psm1=${KUBE_ROOT}/cluster/gce/windows/k8s-node-setup.psm1," 31 metadata+="install-ssh-psm1=${KUBE_ROOT}/cluster/gce/windows/testonly/install-ssh.psm1," 32 metadata+="user-profile-psm1=${KUBE_ROOT}/cluster/gce/windows/testonly/user-profile.psm1," 33 metadata+="${NODE_EXTRA_METADATA}" 34 echo "${metadata}" 35 } 36 37 function get-windows-node-instance-metadata { 38 local metadata="" 39 metadata+="k8s-version=${KUBE_VERSION:-v1.13.2}," 40 # Prevent the GCE Windows agent from managing IP addresses, since kube-proxy 41 # and these cluster setup scripts should take care of everything. See 42 # https://github.com/kubernetes/kubernetes/issues/75561. 43 metadata+="disable-address-manager=true," 44 metadata+="serial-port-enable=1," 45 # This enables logging the serial port output. 46 # https://cloud.google.com/compute/docs/instances/viewing-serial-port-output 47 metadata+="serial-port-logging-enable=true," 48 metadata+="win-version=${WINDOWS_NODE_OS_DISTRIBUTION}" 49 echo "${metadata}" 50 } 51 52 # $1: template name (required). 53 # $2: scopes flag. 54 function create-windows-node-instance-template { 55 local template_name="$1" 56 local scopes_flag="$2" 57 create-node-template "${template_name}" "${scopes_flag}" "$(get-windows-node-instance-metadata-from-file)" "$(get-windows-node-instance-metadata)" "windows" "${NODE_SIZE}" 58 }