<p>Trying to assign persistent volume to an uWSGI application, but I'm getting following error: <code>bind(): Operation not permitted [core/socket.c line 230]</code>.
Works when I assign none-persistent "empty dir" volume.</p>

<p>Here are the yaml files of the persistent volume I'm trying to assign:</p>

<pre><code>#volume claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: api-storage
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: api-storage
  resources:
    requests:
      storage: 100Gi
</code></pre>

<pre><code>#storage class
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: api-storage
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=root
  - gid=root
parameters:
  skuName: Standard_LRS
</code></pre>

<p>The manifest of the application looks like this :</p>

<pre><code>
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: api-app
  template:
    metadata:
      labels:
        app: api-app
    spec:
      containers:
      - name: nginx
        image: nginx
        lifecycle:
          preStop:
            exec:
              command: ["/usr/sbin/nginx","-s","quit"]
        ports:
          - containerPort: 80
            protocol: TCP
        resources:
          limits:
            cpu: 50m
            memory: 100Mi
          requests:
            cpu: 10m
            memory: 50Mi
        volumeMounts:
          - name: storage
            mountPath: /var/run/api
          - name: nginx-conf
            mountPath: /etc/nginx/conf.d
      - name: api-app
        image: azurecr.io/api_api_se:opencv
        workingDir: /app
        command: ["/usr/local/bin/uwsgi"]
        args:
          - "--die-on-term"
          - "--manage-script-name"
          - "--mount=/=api:app_dispatch"
          - "--socket=/var/run/api/uwsgi.sock"
          - "--chmod-socket=777"
          - "--pyargv=se"
          # - "--metrics-dir=/storage"
          # - "--metrics-dir-restore"
        resources:
          requests:
            cpu: 150m
            memory: 1Gi
        volumeMounts:
          - name: storage
            mountPath: /var/run/api
          # - name: storage
          #   mountPath: /storage
      volumes:
        - name: storage  
# work's if following two lines are substituted with "emptyDir: {}"
          persistentVolumeClaim:
            claimName: api-storage
        - name: nginx-conf
          configMap:
            name: api
      tolerations:
      - key: "sku"
        operator: "Equal"
        value: "test"
        effect: "NoSchedule"
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: api-app
  name: api-app
spec:
  ports:
    - port: 80
      protocol: TCP
      targetPort: 80
  selector:
    app: api-app

</code></pre>

<p>The final goal is to collect metrics from the uWSGI, at this moment, the metrics get delete if the pod gets deleted by scale down </p>

user1334557
<p>To solve this problem I had to create the actual folder first, in my case <code>/storage</code>, in the <em>Dockerfile</em> while building the application image, so I added <code>RUN mkdir /storage</code> to the <em>Dockerfile</em></p>
