Home > Blockchain >  smb/cifs mountOptions failed to apply in kubernetes
smb/cifs mountOptions failed to apply in kubernetes

Time:10-19

What happened:

Unable to use mountOptions for onprem smb mount

What you expected to happen:

Create manifest with mountOptions

how to reproduce it (as minimally and precisely as possible):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: "test"
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "smbmount.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "smbmount.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          resources:
            limits:
              memory: "16048Mi"
              cpu: "16000m"
          volumeMounts:
          - name: smb01
            mountPath: /smb/01

      volumes:
      - name: smb01
        csi:
          driver: file.csi.azure.com
          volumeAttributes:
            server: 10.10.10.100
            shareName: share01
            secretName: smbcreds
            mountOptions:
            - dir_mode=0777

what error getting:

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec.template.spec.volumes[0].csi.volumeAttributes.mountOptions): invalid type for io.k8s.api.core.v1.CSIVolumeSource.volumeAttributes: got "array", expected "string"

Did I am using right place for mountOptions? or anything did I made mistake in deployment file

values.yaml

# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 2

image:
  repository: prxzzzzjjkkk.azurecr.io/smbtest
  pullPolicy: Always
  # Overrides the image tag whose default is the chart appVersion.
  tag: latest

imagePullSecrets:
  - name: acr-pull-secrets
nameOverride: ""
fullnameOverride: ""

serviceAccount:
  # Specifies whether a service account should be created
  create: true
  # Annotations to add to the service account
  annotations: {}
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name: ""

podAnnotations: {}

podSecurityContext: {}
  # fsGroup: 2000

securityContext: {}
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000

service:
  type: ClusterIP
  port: 80

ingress:
  enabled: false
  className: ""
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: chart-example.local
      paths:
        - path: /
          pathType: ImplementationSpecific
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

resources: {}
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  # limits:
  #   cpu: 100m
  #   memory: 128Mi
  # requests:
  #   cpu: 100m
  #   memory: 128Mi

autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80
  # targetMemoryUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

CodePudding user response:

Please modify the deployment.spec.template.spec.volumes.csi.volumeAttributes.mountOptions to a string of comma separated key value pairs, instead of an array.

So your modified Deployment manifest should have:

...
 volumes:
      - name: smb01
        csi:
          driver: file.csi.azure.com
          volumeAttributes:
            server: 10.10.10.100
            shareName: share01
            secretName: smbcreds
            mountOptions: "dir_mode=0777" #correct format

instead of:

 ...
 volumes:
      - name: smb01
        csi:
          driver: file.csi.azure.com
          volumeAttributes:
            server: 10.10.10.100
            shareName: share01
            secretName: smbcreds
            mountOptions: #incorrect format
            - dir_mode=0777 

Reference: https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/nginx-pod-azurefile-inline-volume.yaml

CodePudding user response:

In error clearly mentioned at a place of CSIVolumeSource.volumeAttributes: got "array", expected "string" it got th Array instead of String

your YAML should be like

volumes:
      - name: smb01
        csi:
          driver: file.csi.azure.com
          volumeAttributes:
            server: 10.10.10.100
            shareName: share01
            secretName: smbcreds
            mountOptions: dir_mode=0777
  • Related