Add csi-proxy installation into node setup script

This PR follows the same step to install and start csi-proxy as kubelet
binary
This commit is contained in:
Jing Xu 2020-06-05 11:23:58 -07:00
parent 875f31e988
commit 57d0dc540d
4 changed files with 37 additions and 2 deletions

View File

@ -159,3 +159,7 @@ export WINDOWS_BOOTSTRAP_KUBECONFIG_FILE="${WINDOWS_K8S_DIR}\kubelet.bootstrap-k
export WINDOWS_KUBEPROXY_KUBECONFIG_FILE="${WINDOWS_K8S_DIR}\kubeproxy.kubeconfig"
# Pause container image for Windows container.
export WINDOWS_INFRA_CONTAINER="gcr.io/gke-release/pause-win:1.2.1"
# Storage Path for csi-proxy. csi-proxy only needs to be installed for Windows.
export CSI_PROXY_STORAGE_PATH="https://storage.googleapis.com/gke-release/csi-proxy"
# Version for csi-proxy
export CSI_PROXY_VERSION="v0.1.0-gke.1"

View File

@ -280,7 +280,6 @@ function set-preferred-region() {
# Assumed vars:
# PROJECT
# SERVER_BINARY_TAR
# NODE_BINARY_TAR (optional)
# KUBE_MANIFESTS_TAR
# ZONE
# Vars set:
@ -1543,6 +1542,8 @@ function build-windows-kube-env {
WINDOWS_NODE_INSTANCE_PREFIX: $(yaml-quote ${WINDOWS_NODE_INSTANCE_PREFIX})
NODE_BINARY_TAR_URL: $(yaml-quote ${NODE_BINARY_TAR_URL})
NODE_BINARY_TAR_HASH: $(yaml-quote ${NODE_BINARY_TAR_HASH})
CSI_PROXY_STORAGE_PATH: $(yaml-quote ${CSI_PROXY_STORAGE_PATH})
CSI_PROXY_VERSION: $(yaml-quote ${CSI_PROXY_VERSION})
K8S_DIR: $(yaml-quote ${WINDOWS_K8S_DIR})
NODE_DIR: $(yaml-quote ${WINDOWS_NODE_DIR})
LOGS_DIR: $(yaml-quote ${WINDOWS_LOGS_DIR})

View File

@ -136,6 +136,8 @@ try {
Setup-ContainerRuntime
DownloadAndInstall-AuthPlugin
DownloadAndInstall-KubernetesBinaries
DownloadAndInstall-CSIProxyBinaries
Start-CSIProxy
Create-NodePki
Create-KubeletKubeconfig
Create-KubeproxyKubeconfig

View File

@ -253,6 +253,8 @@ function Set-EnvironmentVars {
"CNI_CONFIG_DIR" = ${kube_env}['CNI_CONFIG_DIR']
"WINDOWS_CNI_STORAGE_PATH" = ${kube_env}['WINDOWS_CNI_STORAGE_PATH']
"WINDOWS_CNI_VERSION" = ${kube_env}['WINDOWS_CNI_VERSION']
"CSI_PROXY_STORAGE_PATH" = ${kube_env}['CSI_PROXY_STORAGE_PATH']
"CSI_PROXY_VERSION" = ${kube_env}['CSI_PROXY_VERSION']
"PKI_DIR" = ${kube_env}['PKI_DIR']
"CA_FILE_PATH" = ${kube_env}['CA_FILE_PATH']
"KUBELET_CONFIG" = ${kube_env}['KUBELET_CONFIG_FILE']
@ -386,6 +388,33 @@ function DownloadAndInstall-KubernetesBinaries {
Remove-Item -Force -Recurse $tmp_dir
}
# Downloads the csi-proxy binaries from kube-env's CSI_PROXY_STORAGE_PATH and
# CSI_PROXY_VERSION, and then puts them in a subdirectory of $env:NODE_DIR.
# Note: for now the installation is skipped for non-test clusters. Will be
# installed for all cluster after tests pass.
# Required ${kube_env} keys:
# CSI_PROXY_STORAGE_PATH and CSI_PROXY_VERSION
function DownloadAndInstall-CSIProxyBinaries {
if (Test-IsTestCluster $kube_env) {
if (ShouldWrite-File ${env:NODE_DIR}\csi-proxy.exe) {
$tmp_dir = 'C:\k8s_tmp'
New-Item -Force -ItemType 'directory' $tmp_dir | Out-Null
$filename = 'csi-proxy.exe'
$urls = "${env:CSI_PROXY_STORAGE_PATH}/${env:CSI_PROXY_VERSION}/$filename"
MustDownload-File -OutFile $tmp_dir\$filename -URLs $urls
Move-Item -Force $tmp_dir\$filename ${env:NODE_DIR}\$filename
# Clean up the temporary directory
Remove-Item -Force -Recurse $tmp_dir
}
}
}
# TODO(jingxu97): Make csi-proxy.exe as a service similar to kubelet.exe
function Start-CSIProxy {
Log-Output 'Starting CSI Proxy'
Start-Process "${env:NODE_DIR}\csi-proxy.exe"
}
# TODO(pjh): this is copied from
# https://github.com/Microsoft/SDN/blob/master/Kubernetes/windows/start-kubelet.ps1#L98.
# See if there's a way to fetch or construct the "management subnet" so that
@ -901,7 +930,6 @@ Import-Module -Name $modulePath'.replace('K8S_DIR', ${env:K8S_DIR})
}
Copy-Item ${env:K8S_DIR}\diskutil.exe -Destination "C:\Windows\system32"
}
}
# Setup cni network. This function supports both Docker and containerd.