A full stack web application for my personal website containing:
- AI Chat
- Markdown Blogs
- Editable Bookmark
- Password Generator
- Image Generator
Front End
- Node.JS
- React.JS
- Next.JS
- Tailwind CSS
- MUI
Back End
- Node.JS
- Nest.JS
- Python
- FastAPI
Storage
- MySQL
- MinIO
Infrastructure
- Linux (Debian 12)
- Kubernetes (K3S)
DevOps
- GitHub Actions
- Copy
./app-secret.example.yaml
to./app-secret.example.yaml
, modify value for each key. - Copy
./dashboard/dashboard-secret.copy.yaml
to./dashboard/dashboard-secret.yaml
.
Log in as root user
- Compress
./kubernetes
to./kubernetes.zip
- Run
mkdir /root/kubernetes
- Upload
./kubernetes.zip
to/root/kubernetes/
- Run
apt update apt install unzip
cd /root/kubernetes unzip kubernetes.zip rm kubernetes.zip mv kubernetes UniWebPlatform
-
Prerequisites (WSL2)
apt install curl iptables
sudo swapoff -a
/usr/local/bin/k3s-uninstall.sh
-
Install K3S
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--service-node-port-range=30000-39001 --disable=traefik" sh -
-
Verify Installation
sudo k3s kubectl get node
-
Copy Kubernetes Config
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
-
Install Dependencies
apt install gpg
-
Debian Install Helm
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null sudo apt-get install apt-transport-https --yes echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list sudo apt-get update sudo apt-get install helm
-
Deploy Dashboard
# Add kubernetes-dashboard repository helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/ # Deploy a Helm Release named "kubernetes-dashboard" using the kubernetes-dashboard chart helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
-
Remote Access (NodePort)
kubectl apply -f ./dashboard/dashboard-service.yaml
Test:
curl -k https://localhost:38443
-
Create admin-user
kubectl apply -f ./dashboard/dashboard-serviceaccount.yaml kubectl apply -f ./dashboard/dashboard-clusterrolebinding.yaml kubectl apply -f ./dashboard/dashboard-secret.yaml
-
Get a long-lived Bearer Token
kubectl get secret admin-user -n kubernetes-dashboard -o jsonpath={".data.token"} | base64 -d
See ./app-command.md
HTTP Block:
server {
server_name <domain_name>;
client_max_body_size 100M;
location / {
proxy_pass http://localhost:30080/;
proxy_buffering off;
proxy_request_buffering off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /kubernetes/ {
proxy_pass https://localhost:38443/;
proxy_ssl_verify off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
}
}
Stream Block:
stream {
server {
listen 3306;
proxy_pass localhost:33306;
}
}
- Main:
http://localhost:30080/
- MinIO:
http://localhost:30080/minio/ui/
- Kubernetes Dashboard:
https://localhost:38443/
- Setup and run MySQL and MinIO natively / by Docker / by K3S.
- Setup and run Next, Nest, FastAPI separately by JetBrains IDE according to their documentations.
- Install WSL2 Debian
- Enable systemd
- Edit config
vi /etc/wsl.conf
- Add
[boot] systemd=true
- Restart WSL2
wsl --shutdown
- Check WSL2 IP
ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'
- Edit config
- Follow the Debian Production steps
GitHub >> Repository >> Settings >> Security >> Secrets and variables >> Actions >> Repository secrets: add
- DOCKERHUB_TOKEN
- DOCKERHUB_USERNAME
Step 1,2,3 should be done by contributors; Step 4,5 should be done by repo owner.
- Create a new branch based on
main
- Commit to the new branch
- Open a pull request from the new branch
- Merge the pull request, wait for automatic test to pass and docker push to finish
- Dispatch workflow for automatic deployment