- Github
Ci-CDworking fine withEC2 - Kubernets API working with
FastAPI + MondoDB + Mongo-express
minikube start+minikube addons enable ingress(for routing)- Create and apply
secrets.yaml - Create and apply
config.yaml - Create and apply
mongo-depl-serv.yamlwhich run aMongoDBas a pod inside cluster - Create and apply
mongo-express-dep-serv.yamlwhich will run a nMongo-expressdashboard interactiong withMongoDB. Create a new DB, New Collection and add documents using that Dashboard. It can be accessed athttp://192.168.49.2:30001as it is running at Port 30001 (defined inmongo_express.yamlfile) - Create your
FastApiapp insidemain.pyreferencing the db and collection above - Create a
Dockerimage of your app and push to Hub - Lastly create and apply
fastapideployment and service files - Now you can hit
FastAPIapp athttp://192.168.49.2:30000as it is running at Port 30000 (defined infastapi-service.yamlfile) - Edit
/etc/hoststo mapmy-deployed-app.comto where yourFastAPIia running by using:echo '192.168.49.2 my-deployed-app.com' | sudo tee -a /etc/orecho "$(minikube ip) service.express.mongo" | sudo tee -a /etc/hostshosts (For Local system only) - Apply
ingress.yamlto reroute the traffic
- Tag Docker images before pushing
kubectl get deployment fastapi-app-deployment -o yaml > fastapi-etcd-cluster-status.yamlGives you the status of cluster for the Deployment (which has replicas or pods) namedfastapi-app-deploymentin a file namedfastapi-etcd-cluster-status.yamlwhere you can cross check yourdeployment.yamlandservice.yamlto know how the clusters are managed according to the specifications (specfield in files). This info is stored inetcdwhich supervises all the failures and auto creation of pods cross checking with this file- Create and apply the
ConfigMapandSecretsfiles first and then apply the Service and Deployment else it'll result in the error if any of the service uses those secrets and configurations - If there is a
Servicerunning inside cluster, it is allocated INTERNAL IP ADDRESS so the system knows that at which particular address the service is running. So in case we want to access the data from that service, we use THAT internal address to communicate. So in other terms, How and where to connect with an app is defined in it'sservice.yamlfile and whenever we want to know the address likeMongoDBurl, we refer to that service instead of static url.