Lab Minikube (based on official tutorial on https://kubernetes.io)
- Launch GitHub Codespace
- Run
minikube start
to start cluster - Run
minikube dashboard --url
to view dashboard in a new terminal - Hover over link and "follow link"
- Create a deployment:
kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080
- View deployment:
kubectl get deployments
- View pods:
kubectl get pods
- Create service and expose it:
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
- View services:
kubectl get services
- Curl the url shown, for example:
curl http://192.168.49.2:31839
or change to your URL. - Cleanup
kubectl delete service hello-node
kubectl delete deployment hello-node
minikube stop
- Push container to DockerHub (Optional): i.e.
docker build -t <hub-user>/<repo-name>[:<tag>]
anddocker push <hub-user>/<repo-name>:<tag>
Example of a pushed FastAPI container here: https://hub.docker.com/repository/docker/noahgift/fastapi-kube minikube start
minikube dashboard --url
- Hover over link and "follow link"
- Create a deployment:
kubectl create deployment hello-fastapi --image=registry.hub.docker.com/noahgift/fastapi-kube
- View deployment:
kubectl get deployments
- Create service and expose it:
kubectl expose deployment hello-fastapi --type=LoadBalancer --port=8080
- View services:
kubectl get service hello-fastapi
minikube service hello-fastapi --url
- Curl web service: i.e.
curl http://192.168.49.2:31224
- Cleanup
- Cleanup
kubectl delete service hello-fastapi
kubectl delete deployment hello-fastapi
minikube stop
A repository to demonstrate FastAPI
/docs get to swagger
docker build .
docker image ls
#find image
docker run -p 127.0.0.1:8080:8080 93fa55efa692
- Clone repo into Cloud9 (pick a machine with decent size CPU and RAM if possible, but students should use micro)
- Add ssh keys to GitHub
- resize to bigger disk
- Create virtualenv and add to bashrc and source
python3 -m venv ~/.venv && echo 'source ~/.venv/bin/activate' >> ~/.bashrc && source ~/.bashrc
- cd into checkout and run
make install
- Preview running FastAPI app after running: python main.py
- Create ECR repository by right-click in Cloud9
-
Navigate to ECR repo created or whatever you named it and follow "push" instructions
-
Navigate to AWS App Runner and Setup Continuous Delivery using ECR
-
Setup AWS Code Build to push container after each build (which triggers auto-deploy)
See following buildspec.yml and Makefile