Skip to content

Commit d653d69

Browse files
committed
feat: support windows host-process deployment
fix fix fix
1 parent 9c7e069 commit d653d69

20 files changed

+910
-10
lines changed

Makefile

+27
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,16 @@ e2e-test:
102102

103103
.PHONY: e2e-bootstrap
104104
e2e-bootstrap: install-helm
105+
ifdef WINDOWS_USE_HOST_PROCESS_CONTAINERS
106+
(docker pull $(IMAGE_TAG) && docker pull $(IMAGE_TAG)-windows-hp) || make container-all push-manifest
107+
else
105108
docker pull $(IMAGE_TAG) || make container-all push-manifest
109+
endif
106110
ifdef TEST_WINDOWS
107111
helm upgrade csi-driver-smb charts/$(VERSION)/csi-driver-smb --namespace kube-system --wait --timeout=15m -v=5 --debug --install \
108112
${E2E_HELM_OPTIONS} \
109113
--set windows.enabled=true \
114+
--set windows.useHostProcessContainers=${WINDOWS_USE_HOST_PROCESS_CONTAINERS} \
110115
--set linux.enabled=false \
111116
--set controller.replicas=1 \
112117
--set controller.logLevel=6 \
@@ -162,6 +167,24 @@ container-windows:
162167
-t $(IMAGE_TAG)-windows-$(OSVERSION)-$(ARCH) --build-arg OSVERSION=$(OSVERSION) \
163168
--provenance=false --sbom=false \
164169
--build-arg ARCH=$(ARCH) -f ./cmd/smbplugin/Dockerfile.Windows .
170+
# workaround: only build hostprocess image once
171+
ifdef WINDOWS_USE_HOST_PROCESS_CONTAINERS
172+
ifeq ($(OSVERSION),ltsc2022)
173+
$(MAKE) container-windows-hostprocess
174+
$(MAKE) container-windows-hostprocess-latest
175+
endif
176+
endif
177+
178+
# Set --provenance=false to not generate the provenance (which is what causes the multi-platform index to be generated, even for a single platform).
179+
.PHONY: container-windows-hostprocess
180+
container-windows-hostprocess:
181+
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" --provenance=false --sbom=false \
182+
-t $(IMAGE_TAG)-windows-hp -f ./cmd/smbplugin/Dockerfile.WindowsHostProcess .
183+
184+
.PHONY: container-windows-hostprocess-latest
185+
container-windows-hostprocess-latest:
186+
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" --provenance=false --sbom=false \
187+
-t $(IMAGE_TAG_LATEST)-windows-hp -f ./cmd/smbplugin/Dockerfile.WindowsHostProcess .
165188

166189
.PHONY: container-all
167190
container-all: smb-windows
@@ -206,14 +229,18 @@ ifdef PUBLISH
206229
done; \
207230
done
208231
docker manifest inspect $(IMAGE_TAG_LATEST)
232+
docker manifest create --amend $(IMAGE_TAG_LATEST)-windows-hp $(IMAGE_TAG_LATEST)-windows-hp
233+
docker manifest inspect $(IMAGE_TAG_LATEST)-windows-hp
209234
endif
210235

211236
.PHONY: push-latest
212237
push-latest:
213238
ifdef CI
214239
docker manifest push --purge $(IMAGE_TAG_LATEST)
240+
docker manifest push --purge $(IMAGE_TAG_LATEST)-windows-hp
215241
else
216242
docker push $(IMAGE_TAG_LATEST)
243+
docker push $(IMAGE_TAG_LATEST)-windows-hp
217244
endif
218245

219246
.PHONY: install-smb-provisioner
388 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{{- if and .Values.windows.enabled .Values.windows.useHostProcessContainers }}
2+
kind: DaemonSet
3+
apiVersion: apps/v1
4+
metadata:
5+
name: {{ .Values.windows.dsName }}
6+
namespace: {{ .Release.Namespace }}
7+
{{ include "smb.labels" . | indent 2 }}
8+
spec:
9+
updateStrategy:
10+
rollingUpdate:
11+
maxUnavailable: {{ .Values.node.maxUnavailable }}
12+
type: RollingUpdate
13+
selector:
14+
matchLabels:
15+
app: {{ .Values.windows.dsName }}
16+
template:
17+
metadata:
18+
{{ include "smb.labels" . | indent 6 }}
19+
app: {{ .Values.windows.dsName }}
20+
spec:
21+
{{- with .Values.windows.tolerations }}
22+
tolerations:
23+
{{ toYaml . | indent 8 }}
24+
{{- end }}
25+
nodeSelector:
26+
kubernetes.io/os: windows
27+
{{- with .Values.node.nodeSelector }}
28+
{{ toYaml . | indent 8 }}
29+
{{- end }}
30+
{{- with .Values.node.affinity }}
31+
affinity:
32+
{{ toYaml . | indent 8 }}
33+
{{- end }}
34+
priorityClassName: {{ .Values.priorityClassName | quote }}
35+
{{- if .Values.securityContext }}
36+
securityContext: {{- toYaml .Values.securityContext | nindent 8 }}
37+
{{- end }}
38+
serviceAccountName: {{ .Values.serviceAccount.node }}
39+
{{- include "smb.pullSecrets" . | indent 6 }}
40+
securityContext:
41+
seccompProfile:
42+
type: RuntimeDefault
43+
windowsOptions:
44+
hostProcess: true
45+
runAsUserName: "NT AUTHORITY\\SYSTEM"
46+
hostNetwork: true
47+
initContainers:
48+
- name: init
49+
{{- if hasPrefix "/" .Values.image.smb.repository }}
50+
image: "{{ .Values.image.baseRepo }}{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp"
51+
{{- else }}
52+
image: "{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp"
53+
{{- end }}
54+
imagePullPolicy: {{ .Values.image.pullPolicy }}
55+
command:
56+
- "powershell.exe"
57+
- "-c"
58+
- "New-Item -ItemType Directory -Path C:\\var\\lib\\kubelet\\plugins\\{{ .Values.driver.name }}\\ -Force"
59+
securityContext:
60+
capabilities:
61+
drop:
62+
- ALL
63+
containers:
64+
- name: node-driver-registrar
65+
{{- if hasPrefix "/" .Values.image.nodeDriverRegistrar.repository }}
66+
image: "{{ .Values.image.baseRepo }}{{ .Values.image.nodeDriverRegistrar.repository }}:{{ .Values.image.nodeDriverRegistrar.tag }}"
67+
{{- else }}
68+
image: "{{ .Values.image.nodeDriverRegistrar.repository }}:{{ .Values.image.nodeDriverRegistrar.tag }}"
69+
{{- end }}
70+
command:
71+
- "csi-node-driver-registrar.exe"
72+
args:
73+
- "--csi-address=$(CSI_ENDPOINT)"
74+
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
75+
- "--plugin-registration-path=$(PLUGIN_REG_DIR)"
76+
- "--v=2"
77+
env:
78+
- name: CSI_ENDPOINT
79+
value: unix://{{ .Values.windows.kubelet }}\plugins\{{ .Values.driver.name }}\csi.sock
80+
- name: DRIVER_REG_SOCK_PATH
81+
value: C:\\var\\lib\\kubelet\\plugins\\{{ .Values.driver.name }}\\csi.sock
82+
- name: PLUGIN_REG_DIR
83+
value: C:\\var\\lib\\kubelet\\plugins_registry\\
84+
- name: KUBE_NODE_NAME
85+
valueFrom:
86+
fieldRef:
87+
fieldPath: spec.nodeName
88+
imagePullPolicy: {{ .Values.image.nodeDriverRegistrar.pullPolicy }}
89+
resources: {{- toYaml .Values.windows.resources.nodeDriverRegistrar | nindent 12 }}
90+
securityContext:
91+
capabilities:
92+
drop:
93+
- ALL
94+
- name: smb
95+
{{- if hasPrefix "/" .Values.image.smb.repository }}
96+
image: "{{ .Values.image.baseRepo }}{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}"
97+
{{- else }}
98+
image: "{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}"
99+
{{- end }}
100+
imagePullPolicy: {{ .Values.image.smb.pullPolicy }}
101+
command:
102+
- "smbplugin.exe"
103+
args:
104+
- "--v={{ .Values.node.logLevel }}"
105+
- "--drivername={{ .Values.driver.name }}"
106+
- --endpoint=$(CSI_ENDPOINT)
107+
- --nodeid=$(KUBE_NODE_NAME)
108+
- "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}"
109+
- "--remove-smb-mapping-during-unmount={{ .Values.windows.removeSMBMappingDuringUnmount }}"
110+
- "--enable-windows-host-process=true"
111+
env:
112+
- name: CSI_ENDPOINT
113+
value: unix://{{ .Values.windows.kubelet }}\plugins\{{ .Values.driver.name }}\csi.sock
114+
- name: KUBE_NODE_NAME
115+
valueFrom:
116+
fieldRef:
117+
apiVersion: v1
118+
fieldPath: spec.nodeName
119+
imagePullPolicy: {{ .Values.image.pullPolicy }}
120+
resources: {{- toYaml .Values.windows.resources.smb | nindent 12 }}
121+
securityContext:
122+
capabilities:
123+
drop:
124+
- ALL
125+
{{- end -}}

charts/latest/csi-driver-smb/templates/csi-smb-node-windows.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.windows.enabled}}
1+
{{- if and .Values.windows.enabled (not .Values.windows.useHostProcessContainers) }}
22
kind: DaemonSet
33
apiVersion: apps/v1
44
metadata:

charts/latest/csi-driver-smb/values.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ linux:
131131

132132
windows:
133133
enabled: false # Unless you already had csi proxy installed, windows.csiproxy.enabled=true is required
134+
useHostProcessContainers: false
134135
dsName: csi-smb-node-win # daemonset name
135136
kubelet: 'C:\var\lib\kubelet'
136137
removeSMBMappingDuringUnmount: true
@@ -153,7 +154,7 @@ windows:
153154
memory: 40Mi
154155
smb:
155156
limits:
156-
memory: 200Mi
157+
memory: 600Mi
157158
requests:
158159
cpu: 10m
159160
memory: 40Mi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2022 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# these arguments come from BUILD_PLATFORMS used in release-tools
16+
FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
17+
LABEL description="CSI SMB plugin"
18+
19+
ARG ARCH=amd64
20+
ARG binary=./_output/${ARCH}/smbplugin.exe
21+
COPY ${binary} /smbplugin.exe
22+
ENV PATH="C:\Windows\system32;C:\Windows;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;"
23+
USER ContainerAdministrator
24+
ENTRYPOINT ["/smbplugin.exe"]

cmd/smbplugin/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ var (
4949
krb5Prefix = flag.String("krb5-prefix", smb.DefaultKrb5CCName, "The prefix for kerberos cache")
5050
defaultOnDeletePolicy = flag.String("default-ondelete-policy", "", "default policy for deleting subdirectory when deleting a volume")
5151
removeArchivedVolumePath = flag.Bool("remove-archived-volume-path", true, "remove archived volume path in DeleteVolume")
52+
enableWindowsHostProcess = flag.Bool("enable-windows-host-process", false, "enable windows host process")
5253
)
5354

5455
// exit is a separate function to handle program termination
@@ -87,6 +88,7 @@ func handle() {
8788
Krb5CacheDirectory: *krb5CacheDirectory,
8889
Krb5Prefix: *krb5Prefix,
8990
DefaultOnDeletePolicy: *defaultOnDeletePolicy,
91+
EnableWindowsHostProcess: *enableWindowsHostProcess,
9092
}
9193
driver := smb.NewDriver(&driverOptions)
9294
driver.Run(*endpoint, *kubeconfig, false)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
kind: DaemonSet
3+
apiVersion: apps/v1
4+
metadata:
5+
name: csi-smb-node-win
6+
namespace: kube-system
7+
spec:
8+
updateStrategy:
9+
rollingUpdate:
10+
maxUnavailable: 1
11+
type: RollingUpdate
12+
selector:
13+
matchLabels:
14+
app: csi-smb-node-win
15+
template:
16+
metadata:
17+
labels:
18+
app: csi-smb-node-win
19+
spec:
20+
serviceAccountName: csi-smb-node-sa
21+
tolerations:
22+
- key: "node.kubernetes.io/os"
23+
operator: "Exists"
24+
effect: "NoSchedule"
25+
nodeSelector:
26+
kubernetes.io/os: windows
27+
priorityClassName: system-node-critical
28+
securityContext:
29+
seccompProfile:
30+
type: RuntimeDefault
31+
windowsOptions:
32+
hostProcess: true
33+
runAsUserName: "NT AUTHORITY\\SYSTEM"
34+
hostNetwork: true
35+
initContainers:
36+
- name: init
37+
image: mcr.microsoft.com/k8s/csi/smb-csi:latest-windows-hp
38+
imagePullPolicy: IfNotPresent
39+
command:
40+
- "powershell.exe"
41+
- "-c"
42+
- "New-Item -ItemType Directory -Path C:\\var\\lib\\kubelet\\plugins\\smb.csi.k8s.io\\ -Force"
43+
containers:
44+
- name: node-driver-registrar
45+
image: mcr.microsoft.com/oss/kubernetes-csi/csi-node-driver-registrar:v2.10.0
46+
imagePullPolicy: IfNotPresent
47+
command:
48+
- "csi-node-driver-registrar.exe"
49+
args:
50+
- "--v=2"
51+
- "--csi-address=$(CSI_ENDPOINT)"
52+
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
53+
- "--plugin-registration-path=$(PLUGIN_REG_DIR)"
54+
env:
55+
- name: CSI_ENDPOINT
56+
value: unix://C:\\var\\lib\\kubelet\\plugins\\smb.csi.k8s.io\\csi.sock
57+
- name: DRIVER_REG_SOCK_PATH
58+
value: C:\\var\\lib\\kubelet\\plugins\\smb.csi.k8s.io\\csi.sock
59+
- name: PLUGIN_REG_DIR
60+
value: C:\\var\\lib\\kubelet\\plugins_registry\\
61+
- name: KUBE_NODE_NAME
62+
valueFrom:
63+
fieldRef:
64+
fieldPath: spec.nodeName
65+
resources:
66+
limits:
67+
memory: 150Mi
68+
requests:
69+
cpu: 30m
70+
memory: 40Mi
71+
- name: smb
72+
image: mcr.microsoft.com/k8s/csi/smb-csi:latest-windows-hp
73+
imagePullPolicy: IfNotPresent
74+
command:
75+
- "smbplugin.exe"
76+
args:
77+
- --v=5
78+
- --endpoint=$(CSI_ENDPOINT)
79+
- --nodeid=$(KUBE_NODE_NAME)
80+
- --enable-windows-host-process=true
81+
- --remove-smb-mapping-during-unmount=true
82+
env:
83+
- name: CSI_ENDPOINT
84+
value: unix://C:\\var\\lib\\kubelet\\plugins\\smb.csi.k8s.io\\csi.sock
85+
- name: KUBE_NODE_NAME
86+
valueFrom:
87+
fieldRef:
88+
apiVersion: v1
89+
fieldPath: spec.nodeName
90+
resources:
91+
limits:
92+
memory: 600Mi
93+
requests:
94+
cpu: 10m
95+
memory: 40Mi

deploy/install-driver.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ if [[ "$#" -gt 0 ]]; then
2222
fi
2323

2424
repo="https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/$ver/deploy"
25+
26+
windowsMode="csi-proxy"
2527
if [[ "$#" -gt 1 ]]; then
2628
if [[ "$2" == *"local"* ]]; then
2729
echo "use local deploy"
2830
repo="./deploy"
2931
fi
32+
if [[ "$2" == *"hostprocess"* ]]; then
33+
windowsMode="hostprocess"
34+
fi
3035
fi
3136

3237
if [ $ver != "master" ]; then
@@ -38,5 +43,11 @@ kubectl apply -f $repo/rbac-csi-smb.yaml
3843
kubectl apply -f $repo/csi-smb-driver.yaml
3944
kubectl apply -f $repo/csi-smb-controller.yaml
4045
kubectl apply -f $repo/csi-smb-node.yaml
41-
kubectl apply -f $repo/csi-smb-node-windows.yaml
46+
if [[ "$windowsMode" == *"hostprocess"* ]]; then
47+
echo "deploy windows driver with hostprocess mode..."
48+
kubectl apply -f $repo/csi-smb-node-windows-hostprocess.yaml
49+
else
50+
echo "deploy windows driver with csi-proxy mode ..."
51+
kubectl apply -f $repo/csi-smb-node-windows.yaml
52+
fi
4253
echo 'SMB CSI driver installed successfully.'

hack/release-image.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ export REGISTRY=$REGISTRY_NAME.azurecr.io
2626
export IMAGENAME=public/k8s/csi/smb-csi
2727
export CI=1
2828
export PUBLISH=1
29+
export WINDOWS_USE_HOST_PROCESS_CONTAINERS=true
2930

3031
az acr login --name $REGISTRY_NAME
31-
make container-all push-manifest push-latest
32+
make container-all container-windows-hostprocess-latest push-manifest push-latest
3233

3334
echo "sleep 60s ..."
3435
sleep 60

0 commit comments

Comments
 (0)