Skip to content

Commit dbf6c45

Browse files
authored
Merge pull request kubernetes#91835 from jingxu97/June/csi
Add csi-proxy installation into node setup script
2 parents 13a4a71 + 57d0dc5 commit dbf6c45

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

cluster/gce/config-common.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,7 @@ export WINDOWS_BOOTSTRAP_KUBECONFIG_FILE="${WINDOWS_K8S_DIR}\kubelet.bootstrap-k
159159
export WINDOWS_KUBEPROXY_KUBECONFIG_FILE="${WINDOWS_K8S_DIR}\kubeproxy.kubeconfig"
160160
# Pause container image for Windows container.
161161
export WINDOWS_INFRA_CONTAINER="gcr.io/gke-release/pause-win:1.2.1"
162+
# Storage Path for csi-proxy. csi-proxy only needs to be installed for Windows.
163+
export CSI_PROXY_STORAGE_PATH="https://storage.googleapis.com/gke-release/csi-proxy"
164+
# Version for csi-proxy
165+
export CSI_PROXY_VERSION="v0.1.0-gke.1"

cluster/gce/util.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ function set-preferred-region() {
280280
# Assumed vars:
281281
# PROJECT
282282
# SERVER_BINARY_TAR
283-
# NODE_BINARY_TAR (optional)
284283
# KUBE_MANIFESTS_TAR
285284
# ZONE
286285
# Vars set:
@@ -1528,6 +1527,8 @@ function build-windows-kube-env {
15281527
WINDOWS_NODE_INSTANCE_PREFIX: $(yaml-quote ${WINDOWS_NODE_INSTANCE_PREFIX})
15291528
NODE_BINARY_TAR_URL: $(yaml-quote ${NODE_BINARY_TAR_URL})
15301529
NODE_BINARY_TAR_HASH: $(yaml-quote ${NODE_BINARY_TAR_HASH})
1530+
CSI_PROXY_STORAGE_PATH: $(yaml-quote ${CSI_PROXY_STORAGE_PATH})
1531+
CSI_PROXY_VERSION: $(yaml-quote ${CSI_PROXY_VERSION})
15311532
K8S_DIR: $(yaml-quote ${WINDOWS_K8S_DIR})
15321533
NODE_DIR: $(yaml-quote ${WINDOWS_NODE_DIR})
15331534
LOGS_DIR: $(yaml-quote ${WINDOWS_LOGS_DIR})

cluster/gce/windows/configure.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ try {
136136
Setup-ContainerRuntime
137137
DownloadAndInstall-AuthPlugin
138138
DownloadAndInstall-KubernetesBinaries
139+
DownloadAndInstall-CSIProxyBinaries
140+
Start-CSIProxy
139141
Create-NodePki
140142
Create-KubeletKubeconfig
141143
Create-KubeproxyKubeconfig

cluster/gce/windows/k8s-node-setup.psm1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ function Set-EnvironmentVars {
261261
"CNI_CONFIG_DIR" = ${kube_env}['CNI_CONFIG_DIR']
262262
"WINDOWS_CNI_STORAGE_PATH" = ${kube_env}['WINDOWS_CNI_STORAGE_PATH']
263263
"WINDOWS_CNI_VERSION" = ${kube_env}['WINDOWS_CNI_VERSION']
264+
"CSI_PROXY_STORAGE_PATH" = ${kube_env}['CSI_PROXY_STORAGE_PATH']
265+
"CSI_PROXY_VERSION" = ${kube_env}['CSI_PROXY_VERSION']
264266
"PKI_DIR" = ${kube_env}['PKI_DIR']
265267
"CA_FILE_PATH" = ${kube_env}['CA_FILE_PATH']
266268
"KUBELET_CONFIG" = ${kube_env}['KUBELET_CONFIG_FILE']
@@ -394,6 +396,33 @@ function DownloadAndInstall-KubernetesBinaries {
394396
Remove-Item -Force -Recurse $tmp_dir
395397
}
396398

399+
# Downloads the csi-proxy binaries from kube-env's CSI_PROXY_STORAGE_PATH and
400+
# CSI_PROXY_VERSION, and then puts them in a subdirectory of $env:NODE_DIR.
401+
# Note: for now the installation is skipped for non-test clusters. Will be
402+
# installed for all cluster after tests pass.
403+
# Required ${kube_env} keys:
404+
# CSI_PROXY_STORAGE_PATH and CSI_PROXY_VERSION
405+
function DownloadAndInstall-CSIProxyBinaries {
406+
if (Test-IsTestCluster $kube_env) {
407+
if (ShouldWrite-File ${env:NODE_DIR}\csi-proxy.exe) {
408+
$tmp_dir = 'C:\k8s_tmp'
409+
New-Item -Force -ItemType 'directory' $tmp_dir | Out-Null
410+
$filename = 'csi-proxy.exe'
411+
$urls = "${env:CSI_PROXY_STORAGE_PATH}/${env:CSI_PROXY_VERSION}/$filename"
412+
MustDownload-File -OutFile $tmp_dir\$filename -URLs $urls
413+
Move-Item -Force $tmp_dir\$filename ${env:NODE_DIR}\$filename
414+
# Clean up the temporary directory
415+
Remove-Item -Force -Recurse $tmp_dir
416+
}
417+
}
418+
}
419+
420+
# TODO(jingxu97): Make csi-proxy.exe as a service similar to kubelet.exe
421+
function Start-CSIProxy {
422+
Log-Output 'Starting CSI Proxy'
423+
Start-Process "${env:NODE_DIR}\csi-proxy.exe"
424+
}
425+
397426
# TODO(pjh): this is copied from
398427
# https://github.com/Microsoft/SDN/blob/master/Kubernetes/windows/start-kubelet.ps1#L98.
399428
# See if there's a way to fetch or construct the "management subnet" so that
@@ -909,7 +938,6 @@ Import-Module -Name $modulePath'.replace('K8S_DIR', ${env:K8S_DIR})
909938
}
910939
Copy-Item ${env:K8S_DIR}\diskutil.exe -Destination "C:\Windows\system32"
911940
}
912-
913941
}
914942

915943
# Setup cni network. This function supports both Docker and containerd.

0 commit comments

Comments
 (0)