node-helper.sh 2.6 KB

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