I have a working Flask app running uwsgi in Docker. I am trying to migrate this application to Kubernetes. I have the following Nginx configmap. I have created the following service and deployment created. I am missing something to make this work and cant seem to figure out that it is. From the logs of Nginx it doesnt seem to find the sock file. This is the exact error message "connect() to unix:/app/api.sock failed (2: No such file or directory) "
. This is what I have checked so far:
- I have done a
chmod 777
(I know this is bad, but it is just for testing, I will put it back) to the app/api.sock file and it still cant find it. - I know that Flask is running correctly and accepting connections. I can see the Flask banner on the POD logs.
- I have verified that the file api.sock is in the /app directory in the Flask POD.
Any other suggestions?
# nginx.conf
server {
listen 80;
charset utf-8;
underscores_in_headers on;
location / {
include uwsgi_params;
uwsgi_pass unix:/app/api.sock;
}
}
# flask-service.yaml
apiVersion: v1
kind: Service
metadata:
name: flask-internal-service
spec:
selector:
app: api-flask
ports:
- protocol: TCP
port: 80
targetPort: 8080
# flask-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-flask
spec:
selector:
matchLabels:
app: api-flask
replicas: 2
template:
metadata:
labels:
app: api-flask
spec:
containers:
- env:
- name: CONTAINER
value: flask
image: my_registry/api_flask:latest
name: flask
stdin: true
ports:
- containerPort: 8080
volumeMounts:
- name: uwsgi-socket-volume
mountPath: /app/api.sock
subPath: api.sock
volumes:
- name: uwsgi-socket-volume
emptyDir: { }
restartPolicy: Always