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.imagekey inflask.deployment.ymlfile - the
pathkey forpostgres-initvolume in thepostgresql.deployment.ymlfile to the init script (it should be tosrc/database/db_create.sqlfile) - the
pathkey forpostgrespvin thepostgres.pv.ymlfile 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.ymlfile at the root of the charts (k8shlmchartsfolder) - 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 (
k8shelmchartsfolder) 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