docker-compose up --build
- connect to cluster
kubectl apply -f k8s/db/postgres-pvc.yml
kubectl create configmap fastapi-config --from-env-file=k8s/fastapi/fastapi.env
kubectl apply -f k8s/db/postgres-deployment.yml
kubectl apply -f k8s/fastapi/fastapi-deployment.yml
kubectl apply -f k8s/db/postgres-clip.yml
kubectl apply -f k8s/fastapi/fastapi-clip.yml
- pg secret
kubectl create secret generic pg-user \
--from-literal=PGUSER=<put user name here> \
--from-literal=PGPASSWORD=<put password here>
- tls secret
cd nginx/certs
kubectl create secret generic tls-secret \
--from-file=tls.crt=server.crt \
--from-file=tls.key=server.key\
--from-file=ca.crt=ca_bundle.crt
- allow routing. Get the name of your network interface, e.g. eth0 and run
sudo ufw allow in on eth0 && sudo ufw allow out on eth0
sudo ufw default allow routed
- apply ingress yml file(s)
kaf k8s/ingress/fastapi-ingress-.yml # for http only
kaf k8s/ingress/fastapi-ingress-ssl.yml # for https
- enable improved container support
- create personal access token
- tag an image
docker build -t ghcr.io/tsadimas/myfastapi:latest -f fastapi.Dockerfile .
- login to docker registry
cat ~/github-image-repo.txt | docker login ghcr.io -u tsadimas --password-stdin
- push image
docker push ghcr.io/tsadimas/myfastapi:latest
- create from the command
echo <USER>:<TOKEN> | base64
- create kubernetes secret
echo '{"auths":{"ghcr.io":{"auth":"<AUTH>"}}}' | kubectl create secret generic dockerconfigjson-github-com --type=kubernetes.io/dockerconfigjson --from-file=.dockerconfigjson=/dev/stdin
a test.db file is generated inside app directory
cp .env.example .env
cd app
pytest