Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMagic committed Jan 30, 2023
1 parent e4e6f09 commit 8ae7ba9
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 85 deletions.
26 changes: 25 additions & 1 deletion Makefile
Expand Up @@ -91,17 +91,31 @@ e2e-test:

.PHONY: e2e-bootstrap
e2e-bootstrap: install-helm
docker pull $(IMAGE_TAG) || make container-all push-manifest
docker pull $(IMAGE_TAG) || make container-all push-manifest push-hostprocess
ifdef TEST_WINDOWS
ifdef WINDOWS_USE_HOST_PROCESS_CONTAINERS
helm install azurefile-csi-driver charts/latest/azurefile-csi-driver --namespace kube-system --wait --timeout=15m -v=5 --debug \
${E2E_HELM_OPTIONS} \
--set windows.enabled=true \
--set windows.hostprocess=true \
--set linux.enabled=false \
--set driver.azureGoSDKLogLevel=INFO \
--set controller.replicas=1 \
--set controller.logLevel=6 \
--set node.logLevel=6 \
--disable-openapi-validation
else
helm install azurefile-csi-driver charts/latest/azurefile-csi-driver --namespace kube-system --wait --timeout=15m -v=5 --debug \
${E2E_HELM_OPTIONS} \
--set windows.enabled=true \
--set windows.hostprocess=false \
--set linux.enabled=false \
--set driver.azureGoSDKLogLevel=INFO \
--set controller.replicas=1 \
--set controller.logLevel=6 \
--set node.logLevel=6 \
--disable-openapi-validation
endif
else
helm install azurefile-csi-driver charts/latest/azurefile-csi-driver --namespace kube-system --wait --timeout=15m -v=5 --debug \
${E2E_HELM_OPTIONS} \
Expand Down Expand Up @@ -144,6 +158,11 @@ container-windows:
-t $(IMAGE_TAG)-windows-$(OSVERSION)-$(ARCH) --build-arg OSVERSION=$(OSVERSION) \
--build-arg ARCH=${ARCH} -f ./pkg/azurefileplugin/Windows.Dockerfile .

.PHONY: container-windows-hostprocess
container-windows-hostprocess:
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" \
-t $(IMAGE_TAG)-windows-hp -f ./pkg/azurefileplugin/WindowsHostProcess.Dockerfile .

.PHONY: container-all
container-all: azurefile-windows
docker buildx rm container-builder || true
Expand All @@ -159,6 +178,7 @@ container-all: azurefile-windows
for osversion in $(ALL_OSVERSIONS.windows); do \
OSVERSION=$${osversion} $(MAKE) container-windows; \
done
$(MAKE) container-windows-hostprocess

.PHONY: push-manifest
push-manifest:
Expand Down Expand Up @@ -186,6 +206,10 @@ ifdef PUBLISH
docker manifest inspect $(IMAGE_TAG_LATEST)
endif

.PHONY: push-hostprocess
push-hostprocess:
docker push $(IMAGE_TAG)-windows-hp

.PHONY: push-latest
push-latest:
ifdef CI
Expand Down
Binary file modified charts/latest/azurefile-csi-driver-v0.0.0.tgz
Binary file not shown.
Expand Up @@ -63,29 +63,18 @@ spec:
runAsUserName: "NT AUTHORITY\\SYSTEM"
hostNetwork: true
initContainers:
- name: init
{{- if hasPrefix "/" .Values.image.livenessProbe.repository }}
image: "{{ .Values.image.baseRepo }}{{ .Values.image.livenessProbe.repository }}:{{ .Values.image.livenessProbe.tag }}"
{{- else }}
image: "{{ .Values.image.livenessProbe.repository }}:{{ .Values.image.livenessProbe.tag }}"
{{- end }}
imagePullPolicy: {{ .Values.image.livenessProbe.pullPolicy }}
command:
- "powershell.exe"
- "-c"
- "New-Item"
- "-ItemType"
- "Directory"
- "-Path"
- "C:\\var\\lib\\kubelet\\plugins\\{{ .Values.driver.name }}\\"
- "-Force"
containers:
- name: liveness-probe
volumeMounts:
- mountPath: C:\csi
name: plugin-dir
{{- if hasPrefix "/" .Values.image.livenessProbe.repository }}
image: "{{ .Values.image.baseRepo }}{{ .Values.image.livenessProbe.repository }}:{{ .Values.image.livenessProbe.tag }}"
{{- else }}
image: "{{ .Values.image.livenessProbe.repository }}:{{ .Values.image.livenessProbe.tag }}"
{{- end }}
command:
- "livenessprobe.exe"
args:
- "--csi-address=$(CSI_ENDPOINT)"
- "--probe-timeout=3s"
Expand Down Expand Up @@ -129,10 +118,13 @@ spec:
fieldRef:
fieldPath: spec.nodeName
imagePullPolicy: {{ .Values.image.nodeDriverRegistrar.pullPolicy }}
volumeMounts:
- name: plugin-dir
mountPath: C:\csi
resources: {{- toYaml .Values.windows.resources.nodeDriverRegistrar | nindent 12 }}
- name: azurefile
{{- if hasPrefix "/" .Values.image.azurefile.repository }}
image: "{{ .Values.image.baseRepo }}{{ .Values.image.azurefile.repository }}:{{ .Values.image.azurefile.tag }}"
image: "{{ .Values.image.baseRepo }}{{ .Values.image.azurefile.repository }}:{{ .Values.image.azurefile.tag }}"-windows-hp
{{- else }}
image: "{{ .Values.image.azurefile.repository }}:{{ .Values.image.azurefile.tag }}"
{{- end }}
Expand All @@ -151,7 +143,7 @@ spec:
- "--user-agent-suffix={{ .Values.driver.userAgentSuffix }}"
- "--allow-empty-cloud-config={{ .Values.node.allowEmptyCloudConfig }}"
- "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}"
- "--enableWindowsHostProcess=true"
- "--enable-windows-host-process=true"
ports:
- containerPort: {{ .Values.node.livenessProbe.healthPort }}
name: healthz
Expand Down Expand Up @@ -188,11 +180,11 @@ spec:
fieldPath: spec.nodeName
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: pwsh
mountPath: "C:\\WindowsPowerShell"
- name: plugin-dir
mountPath: C:\csi
volumes:
- name: pwsh
hostPath:
path: C:\Windows\System32\WindowsPowerShell\v1.0
type: DirectoryOrCreate
- name: plugin-dir
hostPath:
path: {{ .Values.windows.kubelet }}\plugins\{{ .Values.driver.name }}\
type: DirectoryOrCreate
{{- end -}}
@@ -1,4 +1,4 @@
{{- if .Values.windows.enabled}}
{{- if and .Values.windows.enabled (not .Values.windows.hostprocess) }}
kind: DaemonSet
apiVersion: apps/v1
metadata:
Expand Down
27 changes: 7 additions & 20 deletions deploy/csi-azurefile-node-windows-hostprocess.yaml
Expand Up @@ -39,19 +39,6 @@ spec:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
hostNetwork: true
initContainers:
- name: init
image: mcr.microsoft.com/k8s/csi/azurefile-csi:latest
imagePullPolicy: Always
command:
- "powershell.exe"
- "-c"
- "New-Item"
- "-ItemType"
- "Directory"
- "-Path"
- "C:\\var\\lib\\kubelet\\plugins\\file.csi.azure.com\\"
- "-Force"
containers:
- name: liveness-probe
image: mcr.microsoft.com/oss/kubernetes-csi/livenessprobe:v2.7.0
Expand Down Expand Up @@ -94,7 +81,7 @@ spec:
fieldRef:
fieldPath: spec.nodeName
- name: azurefile
image: mcr.microsoft.com/k8s/csi/azurefile-csi:latest
image: mcr.microsoft.com/k8s/csi/azurefile-csi:latest-windows-hp
imagePullPolicy: Always
command:
- "azurefileplugin.exe"
Expand All @@ -104,7 +91,7 @@ spec:
- --nodeid=$(KUBE_NODE_NAME)
- --kubeconfig=C:\\k\\config
- --metrics-address=0.0.0.0:29615
- --enableWindowsHostProcess=true
- --enable-windows-host-process=true
ports:
- containerPort: 29613
name: healthz
Expand All @@ -125,17 +112,17 @@ spec:
key: path-windows
optional: true
- name: CSI_ENDPOINT
value: unix://C:\\var\\lib\\kubelet\\plugins\\file.csi.azure.com\\csi.sock
value: unix://C:\\csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
volumeMounts:
- name: pwsh
mountPath: "C:\\WindowsPowerShell"
- name: plugin-dir
mountPath: C:\csi
volumes:
- name: pwsh
- name: plugin-dir
hostPath:
path: C:\Windows\System32\WindowsPowerShell\v1.0
path: C:\var\lib\kubelet\plugins\file.csi.azure.com\
type: DirectoryOrCreate
1 change: 0 additions & 1 deletion deploy/install-driver.sh
Expand Up @@ -39,7 +39,6 @@ kubectl apply -f $repo/rbac-csi-azurefile-node.yaml
kubectl apply -f $repo/csi-azurefile-controller.yaml
kubectl apply -f $repo/csi-azurefile-driver.yaml
kubectl apply -f $repo/csi-azurefile-node.yaml
kubectl apply -f $repo/csi-azurefile-node-windows.yaml

if [[ "$#" -gt 1 ]]; then
if [[ "$2" == *"hostprocess"* ]]; then
Expand Down
3 changes: 0 additions & 3 deletions pkg/azurefile/azurefile.go
Expand Up @@ -177,8 +177,6 @@ var (
supportedFSGroupChangePolicyList = []string{FSGroupChangeNone, string(v1.FSGroupChangeAlways), string(v1.FSGroupChangeOnRootMismatch)}

retriableErrors = []string{accountNotProvisioned, tooManyRequests, shareBeingDeleted, clientThrottled}

enableWindowsHostProcess = false
)

// DriverOptions defines driver parameters specified in driver deployment
Expand Down Expand Up @@ -315,7 +313,6 @@ func (d *Driver) Run(endpoint, kubeconfig string, testBool bool) {
if err != nil {
klog.Fatalf("Failed to get safe mounter. Error: %v", err)
}
enableWindowsHostProcess = d.enableWindowsHostProcess

// Initialize default library driver
d.AddControllerServiceCapabilities(
Expand Down
13 changes: 13 additions & 0 deletions pkg/azurefileplugin/WindowsHostProcess.Dockerfile
@@ -0,0 +1,13 @@
ARG ARCH=amd64
FROM --platform=linux/${ARCH} gcr.io/k8s-staging-e2e-test-images/windows-servercore-cache:1.0-linux-${ARCH}-1809 as core

FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
LABEL description="CSI Azure file plugin"

ARG ARCH=amd64
ARG binary=./_output/${ARCH}/azurefileplugin.exe
COPY ${binary} /azurefileplugin.exe
COPY --from=core /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll
ENV PATH="C:\Windows\system32;C:\Windows;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;"
USER ContainerAdministrator
ENTRYPOINT ["/azurefileplugin.exe"]
2 changes: 1 addition & 1 deletion pkg/azurefileplugin/main.go
Expand Up @@ -54,7 +54,7 @@ var (
enableVHDDiskFeature = flag.Bool("enable-vhd", true, "enable VHD disk feature (experimental)")
kubeAPIQPS = flag.Float64("kube-api-qps", 25.0, "QPS to use while communicating with the kubernetes apiserver.")
kubeAPIBurst = flag.Int("kube-api-burst", 50, "Burst to use while communicating with the kubernetes apiserver.")
enableWindowsHostProcess = flag.Bool("enableWindowsHostProcess", false, "enable windows host process")
enableWindowsHostProcess = flag.Bool("enable-windows-host-process", false, "enable windows host process")
)

func main() {
Expand Down

0 comments on commit 8ae7ba9

Please sign in to comment.