<p>I am new to Kubernetes. By reading some blogs and documentation I have successfully created the EKS cluster. I am using ALB(layer 7 load balancing) for my Django app. For controlling the routes/paths I am using the ALB ingress controller. But I am unable to serve my static contents for Django admin. I know that I need a webserver(Nginx) to serve my static files. I'm not sure how to configure to serve static files.
<strong>note</strong>: (I don't want to use whitenoise)</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: &quot;backend-ingress&quot;
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/subnets: subnet-1, subnet-2, subnet-3
    alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:ap-southeast-1:***:certificate/*
    alb.ingress.kubernetes.io/listen-ports: '[{&quot;HTTP&quot;: 80}, {&quot;HTTPS&quot;:443}]'
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{&quot;Type&quot;: &quot;redirect&quot;, &quot;RedirectConfig&quot;: { &quot;Protocol&quot;: &quot;HTTPS&quot;, &quot;Port&quot;: &quot;443&quot;, &quot;StatusCode&quot;: &quot;HTTP_301&quot;}}'
  labels:
    app: stage
spec:
  rules:
    - host: *.somedomain.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: backend-service
              servicePort: 8000
</code></pre>
<p>this is the ingress yaml i am using. But whenever i am trying to visit my Django admin  it's not loading  the css and js files.</p>
<p>Deployment file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: server-dashboard-backend
  labels:
    app: backend
spec:
  replicas: 2
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      volumes:
        - name: staticfiles
          emptyDir: {}
      containers:
       - name: server-dashboard 
         image: *.dkr.ecr.ap-southeast-1.amazonaws.com/*:4
      volumeMounts:
            - name: staticfiles
              mountPath: /data  
         lifecycle:
            postStart:
              exec:
                command: [&quot;/bin/sh&quot;, &quot;-c&quot; , &quot;cp -r /static /data/&quot;]

       - name: nginx
         image: nginx:stable
         ports:
            - containerPort: 80
         volumeMounts:
            - name: staticfiles
              mountPath: /data  
</code></pre>

Raisul
<p>I have solved the problem.
i removed the command <code>[&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;cp -r /path/to/staticfiles /data/&quot;]</code></p>
<p>I was mounting in the wrong path. So the new deployment file is:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: server-dashboard-backend
  labels:
    app: backend
spec:
  replicas: 2
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      volumes:
        - name: staticfiles
          emptyDir: {}

      containers:
       - name: server-dashboard 
         image: *.dkr.ecr.ap-southeast-1.amazonaws.com/*:4
         volumeMounts:
            - name: staticfiles
              mountPath: /usr/src/code/static
          

       - name: nginx
         image: nginx:stable
         ports:
            - containerPort: 80
         volumeMounts:
            - name: staticfiles
              mountPath: /usr/share/nginx/html/static/
</code></pre>
