Skip to content

Commit

Permalink
feat: support windows host-process deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Dec 27, 2024
1 parent 9c7e069 commit 87cfa2d
Show file tree
Hide file tree
Showing 16 changed files with 793 additions and 6 deletions.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ e2e-test:

.PHONY: e2e-bootstrap
e2e-bootstrap: install-helm
ifdef WINDOWS_USE_HOST_PROCESS_CONTAINERS
(docker pull $(IMAGE_TAG) && docker pull $(IMAGE_TAG)-windows-hp) || make container-all push-manifest
else
docker pull $(IMAGE_TAG) || make container-all push-manifest
endif
ifdef TEST_WINDOWS
helm upgrade csi-driver-smb charts/$(VERSION)/csi-driver-smb --namespace kube-system --wait --timeout=15m -v=5 --debug --install \
${E2E_HELM_OPTIONS} \
--set windows.enabled=true \
--set windows.useHostProcessContainers=${WINDOWS_USE_HOST_PROCESS_CONTAINERS} \
--set linux.enabled=false \
--set controller.replicas=1 \
--set controller.logLevel=6 \
Expand Down Expand Up @@ -162,6 +167,24 @@ container-windows:
-t $(IMAGE_TAG)-windows-$(OSVERSION)-$(ARCH) --build-arg OSVERSION=$(OSVERSION) \
--provenance=false --sbom=false \
--build-arg ARCH=$(ARCH) -f ./cmd/smbplugin/Dockerfile.Windows .
# workaround: only build hostprocess image once
ifdef WINDOWS_USE_HOST_PROCESS_CONTAINERS
ifeq ($(OSVERSION),ltsc2022)
$(MAKE) container-windows-hostprocess
$(MAKE) container-windows-hostprocess-latest
endif
endif

# Set --provenance=false to not generate the provenance (which is what causes the multi-platform index to be generated, even for a single platform).
.PHONY: container-windows-hostprocess
container-windows-hostprocess:
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" --provenance=false --sbom=false \
-t $(IMAGE_TAG)-windows-hp -f ./cmd/smbplugin/Dockerfile.WindowsHostProcess .

.PHONY: container-windows-hostprocess-latest
container-windows-hostprocess-latest:
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" --provenance=false --sbom=false \
-t $(IMAGE_TAG_LATEST)-windows-hp -f ./cmd/smbplugin/Dockerfile.WindowsHostProcess .

.PHONY: container-all
container-all: smb-windows
Expand Down
Binary file modified charts/latest/csi-driver-smb-v0.0.0.tgz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{{- if and .Values.windows.enabled .Values.windows.useHostProcessContainers }}
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: {{ .Values.windows.dsName }}
namespace: {{ .Release.Namespace }}
{{ include "smb.labels" . | indent 2 }}
spec:
updateStrategy:
rollingUpdate:
maxUnavailable: {{ .Values.node.maxUnavailable }}
type: RollingUpdate
selector:
matchLabels:
app: {{ .Values.windows.dsName }}
template:
metadata:
{{ include "smb.labels" . | indent 6 }}
app: {{ .Values.windows.dsName }}
spec:
{{- with .Values.windows.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
nodeSelector:
kubernetes.io/os: windows
{{- with .Values.node.nodeSelector }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.node.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- if .Values.securityContext }}
securityContext: {{- toYaml .Values.securityContext | nindent 8 }}
{{- end }}
serviceAccountName: {{ .Values.serviceAccount.node }}
{{- include "smb.pullSecrets" . | indent 6 }}
securityContext:
seccompProfile:
type: RuntimeDefault
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
hostNetwork: true
initContainers:
- name: init
{{- if hasPrefix "/" .Values.image.smb.repository }}
image: "{{ .Values.image.baseRepo }}{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp"
{{- else }}
image: "{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp"
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- "powershell.exe"
- "-c"
- "New-Item -ItemType Directory -Path C:\\var\\lib\\kubelet\\plugins\\{{ .Values.driver.name }}\\ -Force"
securityContext:
capabilities:
drop:
- ALL
containers:
- name: node-driver-registrar
{{- if hasPrefix "/" .Values.image.nodeDriverRegistrar.repository }}
image: "{{ .Values.image.baseRepo }}{{ .Values.image.nodeDriverRegistrar.repository }}:{{ .Values.image.nodeDriverRegistrar.tag }}"
{{- else }}
image: "{{ .Values.image.nodeDriverRegistrar.repository }}:{{ .Values.image.nodeDriverRegistrar.tag }}"
{{- end }}
command:
- "csi-node-driver-registrar.exe"
args:
- "--csi-address=$(CSI_ENDPOINT)"
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
- "--plugin-registration-path=$(PLUGIN_REG_DIR)"
- "--v=2"
env:
- name: CSI_ENDPOINT
value: unix://{{ .Values.windows.kubelet }}\plugins\{{ .Values.driver.name }}\csi.sock
- name: DRIVER_REG_SOCK_PATH
value: C:\\var\\lib\\kubelet\\plugins\\{{ .Values.driver.name }}\\csi.sock
- name: PLUGIN_REG_DIR
value: C:\\var\\lib\\kubelet\\plugins_registry\\
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
imagePullPolicy: {{ .Values.image.nodeDriverRegistrar.pullPolicy }}
resources: {{- toYaml .Values.windows.resources.nodeDriverRegistrar | nindent 12 }}
securityContext:
capabilities:
drop:
- ALL
- name: smb
{{- if hasPrefix "/" .Values.image.smb.repository }}
image: "{{ .Values.image.baseRepo }}{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}"
{{- else }}
image: "{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}"
{{- end }}
imagePullPolicy: {{ .Values.image.smb.pullPolicy }}
command:
- "azurefileplugin.exe"
args:
- "--v={{ .Values.node.logLevel }}"
- "--drivername={{ .Values.driver.name }}"
- --endpoint=$(CSI_ENDPOINT)
- --nodeid=$(KUBE_NODE_NAME)
- "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}"
- "--remove-smb-mapping-during-unmount={{ .Values.windows.removeSMBMappingDuringUnmount }}"
env:
- name: CSI_ENDPOINT
value: unix://{{ .Values.windows.kubelet }}\plugins\{{ .Values.driver.name }}\csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources: {{- toYaml .Values.windows.resources.smb | nindent 12 }}
securityContext:
capabilities:
drop:
- ALL
{{- end -}}
1 change: 1 addition & 0 deletions charts/latest/csi-driver-smb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ linux:

windows:
enabled: false # Unless you already had csi proxy installed, windows.csiproxy.enabled=true is required
useHostProcessContainers: false
dsName: csi-smb-node-win # daemonset name
kubelet: 'C:\var\lib\kubelet'
removeSMBMappingDuringUnmount: true
Expand Down
24 changes: 24 additions & 0 deletions cmd/smbplugin/Dockerfile.WindowsHostProcess
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# these arguments come from BUILD_PLATFORMS used in release-tools
FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
LABEL description="CSI SMB plugin"

ARG ARCH=amd64
ARG binary=./_output/${ARCH}/smbplugin.exe
COPY ${binary} /smbplugin.exe
ENV PATH="C:\Windows\system32;C:\Windows;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;"
USER ContainerAdministrator
ENTRYPOINT ["/smbplugin.exe"]
1 change: 1 addition & 0 deletions cmd/smbplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var (
krb5Prefix = flag.String("krb5-prefix", smb.DefaultKrb5CCName, "The prefix for kerberos cache")
defaultOnDeletePolicy = flag.String("default-ondelete-policy", "", "default policy for deleting subdirectory when deleting a volume")
removeArchivedVolumePath = flag.Bool("remove-archived-volume-path", true, "remove archived volume path in DeleteVolume")
enableWindowsHostProcess = flag.Bool("enable-windows-host-process", false, "enable windows host process")

Check failure on line 52 in cmd/smbplugin/main.go

View workflow job for this annotation

GitHub Actions / Go Lint

var `enableWindowsHostProcess` is unused (unused)
)

// exit is a separate function to handle program termination
Expand Down
Loading

0 comments on commit 87cfa2d

Please sign in to comment.