I am trying to run my django app in kubernetes.I use docker-compose to build application and nginx.I am able to run the application using proxy server nginx in docker compose.
docker-compose build - successful
docker-compose up - successful
http://aggre.mabh.io - successful(able to load the application)
when i try to deploy the image of application and nginx, I am getting error in kubernetes dashboard saying
Error in kubernetes
pod has unbound PersistentVolumeClaims (repeated 2 times) (for both nginx and application)
I am using kompose up to build and deploy the application.
How to deploy the the application in kubernetes and access the application through nginx kubernetes external end-point?
docker-compose.yml
version: '3'
services:
djangoapp:
build: .
image: sigmaaggregator/djangoapp
labels:
- kompose.service.type=NodePort
volumes:
- .:/djangoapp
- static_volume:/djangoapp/static
ports:
- 4000:4000
networks:
- nginx_network
nginx:
image: nginx:1.13
ports:
- 80:80
volumes:
- ./config/nginx/conf.d:/etc/nginx/conf.d
- static_volume:/djangoapp/static
depends_on:
- djangoapp
networks:
- nginx_network
networks:
nginx_network:
driver: bridge
volumes:
static_volume:
Dockerfile
FROM python:3.6
RUN mkdir -p /djangoapp
WORKDIR /djangoapp
COPY . /djangoapp
RUN pip install -r requirements.txt
# copy our project code
RUN python manage.py collectstatic --no-input
CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"
# expose the port 4000
EXPOSE 4000
# define the default command to run when starting the container
CMD ["gunicorn", "--bind", ":4000", "aggre.wsgi:application"]
config/nginx/conf.d/local.conf
upstream hello_server {
server djangoapp:4000;
}
server {
listen 80;
server_name aggre.mabh.io;
location /static/ {
alias /djangoapp/static/;
}
location / {
proxy_pass http://hello_server;
proxy_set_header Host $host;
#proxy_ssl_server_name on;
#proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}