Closed mellotron closed 6 years ago
This guy has the right idea: https://hub.docker.com/r/shoonoise/cabot-docker/~/dockerfile/
And now I can use environment variables in my config instead of hardcoding a file in a configmap:
...
env:
- name: CELERY_BROKER_URL
value: redis://redis:6379/1
- name: DATABASE_URL
value: postgres://cabot:passwordhere@postgresql:5432/cabot
- name: DB_HOST
value: postgresql
- name: DB_USER
value: cabot
- name: DB_PASS
value: ....
- name: DJANGO_SECRET_KEY
value: Gern0flivPecwaQuolqwrjklqjklqwjklgdfhnsertfadoowonnOck7
- name: WWW_HTTP_HOST
value: cabot.example.com
The reason it doesn't have a default command is that the same container runs both the webserver and the celery workers.
I'm not sure how kubernetes works exactly, but can you not manually set the command for each service? cc @MrSaints
@frankh @mellotron Yes. You'll need to pass in the command, and spin up multiple containers for the service.
Example:
- name: web
command: ["sh", "-c", "cabot migrate && gunicorn cabot.wsgi:application -b 0.0.0.0:5000 --workers=5"]
image: cabotapp/cabot:0.10.8
ports:
- containerPort: 5000
protocol: TCP
livenessProbe:
tcpSocket:
port: 5000
readinessProbe:
tcpSocket:
port: 5000
volumeMounts:
- name: cabot-configmap
mountPath: /
readOnly: true
- name: worker
command: ["celery", "worker", "-A", "cabot"]
image: cabotapp/cabot:0.10.8
ports:
- containerPort: 5000
protocol: TCP
livenessProbe:
tcpSocket:
port: 5000
readinessProbe:
tcpSocket:
port: 5000
volumeMounts:
- name: cabot-configmap
mountPath: /
readOnly: true
I've not included Celery beat in the deployment as it is not something that should be replicated (otherwise you may have checks running multiple times).
@mellotron Did you come right? Can you please share your deployment and service file/
There are now kubernetes files included in the repo, please let me know if those aren't working for you
Can you please change things so that the webapp is ready to go from the get go on port 5000?
I was trying to deploy cabot with the following on Kubernetes:
Apart from the image, and labels such as names and TCP ports - this is pretty much how I deploy every application to my kubernetes cluster. I was confused as to why the image kept falling to boot - I wasn't expecting a webserver to do a "CMD ["/bin/sh"]"!
If no valid configuration is provided, it should be like wordpress where it brings up a web wizard asking where the database is, etc.