A simple Student Management System deployed locally on a Kind-based Kubernetes cluster. This project demonstrates how to combine a backend (Golang + MongoDB), a frontend (Nginx), and Kubernetes manifests to set up a microservice application for local development and testing.
- 🛠 Backend: Developed in Golang with RESTful APIs.
- 🌐 Frontend: Static files served via Nginx.
- 🐳 Containerized: Dockerized application services.
- 🚀 Kubernetes Deployment: Using Kind to run a local K8s cluster.
- 📦 Database: MongoDB as the backend database.
Before running the project, ensure you have the following tools installed:
- Docker: To build and run the application containers.
- Kind: To set up a local Kubernetes cluster.
- kubectl: To interact with the Kubernetes cluster.
Create a local Kubernetes cluster using Kind:
kind create cluster --name student-cluster --config kind-cluster-config.yaml
Build the backend and frontend Docker images:
# Build backend
docker build -t student-backend:latest ./backend
将 Docker 镜像加载到 Kind 集群中:
kind load docker-image student-backend:latest -n student-cluster
在 Kind 集群中安装 Ingress-NGINX 控制器:
kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml
验证 Ingress 控制器是否正常运行:
kubectl get pods -n ingress-nginx
Apply the Kubernetes manifests to deploy the services:
kubectl apply -f k8s
检查 Pod 和服务的状态:
kubectl get pods
kubectl get svc
一旦所有服务运行正常,通过浏览器访问应用:
-
Frontend:
http://localhost
-
Backend API
: 测试 API 路径,例如:
curl http://localhost/api/v1/students
Method | Endpoint | Description |
---|---|---|
GET | /api/v1/students |
Get all students |
POST | /api/v1/students |
Add a new student |
删除 Kind 集群并释放资源:
kind delete cluster --name student-cluster