Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: Support aznfs EiT #2136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ The following table lists the configurable parameters of the latest Azure File C
| `node.maxUnavailable` | `maxUnavailable` value of driver node daemonset | `1`
| `node.livenessProbe.healthPort ` | health check port for liveness probe | `29613` |
| `node.logLevel` | node driver log level |`5` |
| `node.enableAznfsMount` | enable [AZNFS mount helper](https://github.com/Azure/AZNFS-mount/) for NFS protocol | true
| `snapshot.enabled` | whether enable snapshot feature | `false` |
| `snapshot.image.csiSnapshotter.repository` | csi-snapshotter container image | `/oss/kubernetes-csi/csi-snapshotter` |
| `snapshot.image.csiSnapshotter.tag` | csi-snapshotter container image tag | `v8.1.0` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ spec:
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.node.enableAznfsMount }}
hostPID: true
{{- end }}
hostNetwork: true
dnsPolicy: {{ .Values.linux.dnsPolicy }}
serviceAccountName: {{ .Values.serviceAccount.node }}
Expand Down Expand Up @@ -136,6 +139,7 @@ spec:
- "--mount-permissions={{ .Values.linux.mountPermissions }}"
- "--allow-inline-volume-key-access-with-identity={{ .Values.node.allowInlineVolumeKeyAccessWithIdentity }}"
- "--metrics-address=0.0.0.0:{{ .Values.node.metricsPort }}"
- "--enable-aznfs-mount={{ .Values.node.enableAznfsMount }}"
livenessProbe:
failureThreshold: 5
httpGet:
Expand Down Expand Up @@ -193,7 +197,42 @@ spec:
mountPath: /etc/pki/ca-trust/extracted
readOnly: true
{{- end }}
{{- if .Values.node.enableAznfsMount }}
- mountPath: /opt/microsoft/aznfs/data
name: aznfs-data
- mountPath: /lib/modules
name: lib-modules
readOnly: true
- mountPath: /etc/stunnel/microsoft/aznfs/nfsv4_fileShare
name: stunnel-config
- mountPath: /etc/stunnel/microsoft/aznfs/nfsv4_fileShare/logs
name: stunnel-logs
{{- end }}
resources: {{- toYaml .Values.linux.resources.azurefile | nindent 12 }}
{{- if .Values.node.enableAznfsMount }}
- name: aznfswatchdogv4
{{- if hasPrefix "/" .Values.image.azurefile.repository }}
image: "{{ .Values.image.baseRepo }}{{ .Values.image.azurefile.repository }}:{{ .Values.image.azurefile.tag }}"
{{- else }}
image: "{{ .Values.image.azurefile.repository }}:{{ .Values.image.azurefile.tag }}"
{{- end }}
command:
- "aznfswatchdogv4"
imagePullPolicy: {{ .Values.image.azurefile.pullPolicy }}
securityContext:
privileged: true
resources: {{- toYaml .Values.linux.resources.aznfswatchdog | nindent 12 }}
volumeMounts:
- mountPath: /opt/microsoft/aznfs/data
name: aznfs-data
- mountPath: {{ .Values.linux.kubelet }}/
mountPropagation: Bidirectional
name: mountpoint-dir
- mountPath: /etc/stunnel/microsoft/aznfs/nfsv4_fileShare
name: stunnel-config
- mountPath: /etc/stunnel/microsoft/aznfs/nfsv4_fileShare/logs
name: stunnel-logs
{{- end }}
volumes:
- hostPath:
path: {{ .Values.linux.kubelet }}/plugins/{{ .Values.driver.name }}
Expand Down Expand Up @@ -223,4 +262,22 @@ spec:
hostPath:
path: /etc/pki/ca-trust/extracted
{{- end }}
{{- if .Values.node.enableAznfsMount }}
- hostPath:
path: /opt/microsoft/aznfs-azurefile/data # host path `/opt/microsoft/aznfs-azurefile/data` for azurefile and host path `/opt/microsoft/aznfs/data` for blob
type: DirectoryOrCreate
name: aznfs-data
- name: lib-modules
hostPath:
path: /lib/modules
type: DirectoryOrCreate
- name: stunnel-config
hostPath:
path: /etc/stunnel/microsoft/aznfs/nfsv4_fileShare
type: DirectoryOrCreate
- name: stunnel-logs
hostPath:
path: /etc/stunnel/microsoft/aznfs/nfsv4_fileShare/logs
type: DirectoryOrCreate
{{- end }}
{{- end -}}
7 changes: 7 additions & 0 deletions charts/latest/azurefile-csi-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ node:
livenessProbe:
healthPort: 29613
logLevel: 5
enableAznfsMount: true

snapshot:
enabled: false
Expand Down Expand Up @@ -193,6 +194,12 @@ linux:
requests:
cpu: 10m
memory: 20Mi
aznfswatchdog:
limits:
memory: 100Mi
requests:
cpu: 10m
memory: 20Mi
tolerations:
- operator: "Exists"
nodeSelector: {}
Expand Down
4 changes: 4 additions & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const (
cifs = "cifs"
smb = "smb"
nfs = "nfs"
aznfs = "aznfs"
ext4 = "ext4"
ext3 = "ext3"
ext2 = "ext2"
Expand Down Expand Up @@ -269,6 +270,8 @@ type Driver struct {
waitForAzCopyTimeoutMinutes int
// azcopy for provide exec mock for ut
azcopy *fileutil.Azcopy
// enable aznfs mount
enableAznfsMount bool

kubeconfig string
endpoint string
Expand Down Expand Up @@ -310,6 +313,7 @@ func NewDriver(options *DriverOptions) *Driver {
driver.azcopy = &fileutil.Azcopy{}
driver.kubeconfig = options.KubeConfig
driver.endpoint = options.Endpoint
driver.enableAznfsMount = options.EnableAznfsMount

var err error
getter := func(_ string) (interface{}, error) { return nil, nil }
Expand Down
2 changes: 2 additions & 0 deletions pkg/azurefile/azurefile_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type DriverOptions struct {
WaitForAzCopyTimeoutMinutes int
KubeConfig string
Endpoint string
EnableAznfsMount bool
}

func (o *DriverOptions) AddFlags() *flag.FlagSet {
Expand Down Expand Up @@ -85,6 +86,7 @@ func (o *DriverOptions) AddFlags() *flag.FlagSet {
fs.IntVar(&o.WaitForAzCopyTimeoutMinutes, "wait-for-azcopy-timeout-minutes", 5, "timeout in minutes for waiting for azcopy to finish")
fs.StringVar(&o.KubeConfig, "kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
fs.StringVar(&o.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
fs.BoolVar(&o.EnableAznfsMount, "enable-aznfs-mount", false, "replace nfs mount with aznfs mount")

return fs
}
3 changes: 3 additions & 0 deletions pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
mountFsType := cifs
if protocol == nfs {
mountFsType = nfs
if d.enableAznfsMount {
mountFsType = aznfs
}
}
if err := prepareStagePath(cifsMountPath, d.mounter); err != nil {
return nil, status.Errorf(codes.Internal, "prepare stage path failed for %s with error: %v", cifsMountPath, err)
Expand Down
12 changes: 11 additions & 1 deletion pkg/azurefileplugin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ ARG binary=./_output/${ARCH}/azurefileplugin
COPY ${binary} /azurefileplugin
COPY --from=builder --chown=root:root /usr/local/bin/azcopy /usr/local/bin/azcopy

RUN apt update && apt upgrade -y && apt-mark unhold libcap2 && clean-install ca-certificates cifs-utils util-linux e2fsprogs mount udev xfsprogs nfs-common netbase
# packages that are only needed by aznfs: procps conntrack iptables bind9-host iproute2 bash netcat sysvinit-utils kmod net-tools stunnel4
RUN apt update && apt upgrade -y && apt-mark unhold libcap2 && clean-install ca-certificates cifs-utils util-linux e2fsprogs mount udev xfsprogs nfs-common netbase wget procps conntrack iptables bind9-host iproute2 bash netcat-traditional sysvinit-utils kmod net-tools stunnel4

# install aznfs
# TODO: Dont use wget to download and install aznfs
ARG aznfsVer=0.1.394
RUN if [ "$ARCH" = "amd64" ] ; then \
wget -O aznfs.tar.gz https://github.com/Azure/AZNFS-mount/releases/download/${aznfsVer}/aznfs-${aznfsVer}-1.x86_64.tar.gz; \
else \
wget -O aznfs.tar.gz https://github.com/Azure/AZNFS-mount/releases/download/${aznfsVer}/aznfs-${aznfsVer}-1.arm64.tar.gz;fi
RUN tar xvzf aznfs.tar.gz -C / --keep-directory-symlink && rm aznfs.tar.gz

LABEL maintainers="andyzhangx"
LABEL description="AzureFile CSI Driver"
Expand Down
Loading