a simple flask app with a postgres backend. We have used kubernetes and helm apis to deploy the application on a local kubernetes installation (kubernetes on docker desktop)
to run the app using kubernetes APIs (commands):
-
create secret for postgres admin password
kubectl create secret generic postgres-secrets --from-literal=password=postgres-admin-password
-
create secret for Azure Container Registry login
kubectl create secret docker-registry acrregistrykey --docker-server=link-to-registry --docker-username=username --docker-password=access-key
-
update:
- container image location at
containers.image
key inflask.deployment.yml
file - the
path
key forpostgres-init
volume in thepostgresql.deployment.yml
file to the init script (it should be tosrc/database/db_create.sql
file) - the
path
key forpostgrespv
in thepostgres.pv.yml
file and point to a folder to save the postgres database dumps/backups. This location can be used to restore the postgres db in case the container crashes.
- container image location at
-
Apply the k8s config files
kubectl apply -f k8s/
- create a
secretvalues.yml
file at the root of the charts (k8shlmcharts
folder) - populate the secretvalues in the file as :
postgresdb: password: postgres-password init_script_pth: "/Complete/path/to/file/src/database/db_create.sql" postgres_db_backup: "/Complete/path/to/folder/postgresdbvolume" flask-app: acrloginkey: "credentials to login to the docker registry where the images is loaded (dockerhub, acr etc.)" registryname: registry+image-name:tag
- run command from the root (
k8shelmcharts
folder) of the helm charts directoryhelm install flaskapp . -f secretvalues.yml
- setup on actual kubernetes cluster
- setup ingress services
- setup a cloud storage as a volume
- setup deployment pipelines to push to kubernetes cluster