https://github.com/graphtylove/kubernetes-demo
Small Demo to show how to deploy on Kubernetes
https://github.com/graphtylove/kubernetes-demo
api becode course deploy docker fastapi kubernetes python
Last synced: 2 months ago
JSON representation
Small Demo to show how to deploy on Kubernetes
- Host: GitHub
- URL: https://github.com/graphtylove/kubernetes-demo
- Owner: GraphtyLove
- Created: 2024-11-27T16:19:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-29T10:20:55.000Z (over 1 year ago)
- Last Synced: 2025-03-03T19:40:39.597Z (over 1 year ago)
- Topics: api, becode, course, deploy, docker, fastapi, kubernetes, python
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# kubernetes-demo
Small Demo to show how to deploy on Kubernetes.
**[Slides here](https://docs.google.com/presentation/d/175mXUK2vpoTbcjPfJcrHBIe9KFPQFT_7/)**
## API
The API is a simple FastAPI application.
### Build & push the image
Create an account on [Docker Hub](hub.docker.com/).
```bash
# Login to Docker Hub
docker login
# Build the image
docker build -t /api-demo:latest .
# Push the image
docker push inoopa/api-demo:latest
```
If you are on a Mac with M1, M2, M3,... you can use the following command to build & push the image:
*[More information](https://stackoverflow.com/questions/74942945/how-to-build-a-docker-image-for-m1-mac-silicon-or-amd-conditionally-from-dockerf)*
```bash
docker buildx build --platform linux/amd64 --push -t /api-demo:latest .
```
### Run locally
```bash
docker run -p 80:80 /api-demo:latest
```
## Kubernetes
The Kubernetes manifests are in the `kubernetes` folder.
```bash
kubectl apply -f kubernetes/manifest.yaml
```
Then you need to forward the port to your local machine:
```bash
kubectl port-forward -n api-demo-namespace service/api-demo-service 8080:80
```