<p>I have an issue on my deployment when I try to share a folder with a kubernetes volume.
The folder will be shared using an Azure File Storage.
If I deploy my image without sharing the folder (/integrations) the app start.
<a href="https://i.stack.imgur.com/a2fBX.png" rel="nofollow noreferrer">as shown in the image below the pod via lens is up and running</a></p>
<p>If I add the relation of the folder to a volume the result is that the pod will stuck in error <a href="https://i.stack.imgur.com/TqUqD.png" rel="nofollow noreferrer">with this messagge</a></p>
<p>Here I put my yaml deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: sandbox-pizzly
  name: sandbox-pizzly-widget
  labels:
    app: sandbox-pizzly-widget
    product: sandbox-pizzly
    app.kubernetes.io/name: &quot;sandbox-pizzly-widget&quot;
    app.kubernetes.io/version: &quot;latest&quot;
    app.kubernetes.io/managed-by: &quot;xxxx&quot;
    app.kubernetes.io/component: &quot;sandbox-pizzly-widget&quot;
    app.kubernetes.io/part-of: &quot;sandbox-pizzly&quot;
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sandbox-pizzly-widget
  template:
    metadata:
      labels:
        app: sandbox-pizzly-widget
    spec:
      containers:
        - name: sandbox-pizzly-widget
          image: davidep931/pizzly-proxy:latest
          ports:
            - containerPort: 8080
          env:
            - name: NODE_ENV
              value: &quot;production&quot;
            - name: DASHBOARD_USERNAME
              value: &quot;admin&quot;
            - name: DASHBOARD_PASSWORD
              value: &quot;admin&quot;
            - name: SECRET_KEY
              value: &quot;devSecretKey&quot;
            - name: PUBLISHABLE_KEY
              value: &quot;devPubKey&quot;
            - name: PROXY_USES_SECRET_KEY_ONLY
              value: &quot;FALSE&quot;
            - name: COOKIE_SECRET
              value: &quot;devCookieSecret&quot;
            - name: AUTH_CALLBACK_URL
              value: &quot;https://pizzly.mydomain/auth/callback&quot;
            - name: DB_HOST
              value: &quot;10.x.x.x&quot;
            - name: DB_PORT
              value: &quot;5432&quot;
            - name: DB_DATABASE
              value: &quot;postgresdb&quot;
            - name: DB_USER
              value: &quot;username&quot;
            - name: DB_PASSWORD
              value: &quot;password&quot;
            - name: PORT
              value: &quot;8080&quot;
          volumeMounts:
            - mountPath: &quot;/home/node/app/integrations&quot;
              name: pizzlystorage
          resources:
            requests:
              memory: &quot;100Mi&quot;
              cpu: &quot;50m&quot;
            limits:
              cpu: &quot;75m&quot;
              memory: &quot;200Mi&quot;
---
apiVersion: v1
kind: Service
metadata:
  namespace: sandbox-pizzly
  name: sandbox-pizzly-widget
spec:
  ports:
    - port: 8080
      targetPort: 8080
  selector:
    app: sandbox-pizzly-widget
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: sandbox-pizzly-pv-volume
  labels:
    type: local
    app: products
spec:
  storageClassName: azurefile
  capacity:
    storage: 1Gi
  azureFile:
    secretName: azure-secret
    shareName: sandbox-pizzly-pv
    readOnly: false
    secretNamespace: sandbox-pizzly
  accessModes:
    - ReadWriteMany
  claimRef:
    namespace: sandbox-pizzly
    name: sandbox-pizzly-pv-claim
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  namespace: sandbox-pizzly
  name: sandbox-pizzly-pv-claim
  labels:
    app: products
spec:
  storageClassName: azurefile
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azurefilestorage
provisioner: kubernetes.io/azure-file
parameters:
  storageAccount: persistentsapizzly
reclaimPolicy: Retain
---
apiVersion: v1
kind: Secret
metadata:
  name: azure-secret
  namespace: sandbox-pizzly
type: Opaque
data:
  azurestorageaccountname: xxxxxxxxxxxxxxxxxxxxx
  azurestorageaccountkey: xxxxxxxxxxxxxxxxxxxxxxxxxxx
</code></pre>
<p>If I try, in the few seconds before the pod stuck, to access to integrations folder and I perform a touch 'test.txt', I will found that file in the Azure File Storage.</p>
<p><a href="https://i.stack.imgur.com/G3FHb.png" rel="nofollow noreferrer">Here what I see few seconds before shell autoclose due to CrashLoopBack</a></p>
<p>I add the Dockerfile:</p>
<pre><code>FROM node:14-slim

WORKDIR /app

# Copy in dependencies for building
COPY *.json ./
COPY yarn.lock ./
# COPY config ./config
COPY integrations ./integrations/
COPY src ./src/
COPY tests ./tests/
COPY views ./views/

RUN yarn install


# Actual image to run from.
FROM node:14-slim

# Make sure we have ca certs for TLS
RUN apt-get update &amp;&amp; apt-get install -y \
    curl \
    wget \
    gnupg2 ca-certificates libnss3  \
    git

# Make a directory for the node user. Not running Pizzly as root.
RUN mkdir /home/node/app &amp;&amp; chown -R node:node /home/node/app
WORKDIR /home/node/app

USER node

# Startup script
COPY --chown=node:node ./startup.sh ./startup.sh
RUN chmod +x ./startup.sh
# COPY from first container
COPY --chown=node:node --from=0 /app/package.json ./package.json
COPY --chown=node:node --from=0 /app/dist/ .
COPY --chown=node:node --from=0 /app/views ./views
COPY --chown=node:node --from=0 /app/node_modules ./node_modules

# Run the startup script
CMD ./startup.sh

</code></pre>
<p>Here the startup.sh script:</p>
<pre><code>#!/bin/sh

# Docker Startup script

# Apply migration
./node_modules/.bin/knex --cwd ./src/lib/database/config migrate:latest

# Start App
node ./src/index.js

</code></pre>
<p>Have you got any idea on what I miss or I'm wrong?</p>
<p>Thank you,
Dave.</p>

DavideP
<p>Well, there are two things I think you need to know when you mount the Azure file to the pods existing folder as the volume:</p>
<ol>
<li>it will cover the existing files</li>
<li>the mount path will set the ownership as the root user</li>
</ol>
<p>So the above means if your application will start depends on the existing files, then it will cause the problem. And if your application uses a non-root use, for example, the user app, then it maybe will also cause the problem. Here I guess the problem may be caused by the first limitation.</p>
