diff --git a/README.md b/README.md index 4cb660b..ceadff3 100644 --- a/README.md +++ b/README.md @@ -10,44 +10,9 @@ A full-stack application boilerplate with a React frontend and Node.js backend - [๐Ÿ“š Table of Contents](#-table-of-contents) - [๐Ÿ“ Project Structure](#-project-structure) - [โš™๏ธ Prerequisites](#๏ธ-prerequisites) - - [๐Ÿ’ป Development Setup](#-development-setup) -- [To create a new migration:](#to-create-a-new-migration) -- [npm run migration:create](#npm-run-migrationcreate) -- [To apply migrations:](#to-apply-migrations) -- [To seed the database:](#to-seed-the-database) - - [Alternate: Running Services in Separate Terminals](#alternate-running-services-in-separate-terminals) - - [๐Ÿ› ๏ธ Environment Setup](#๏ธ-environment-setup) -- [For Kubernetes, these are set in chart/values.yaml:](#for-kubernetes-these-are-set-in-chartvaluesyaml) -- [POSTGRES\_NAME=fusero-boilerplate-db](#postgres_namefusero-boilerplate-db) -- [POSTGRES\_HOSTNAME=postgres-service](#postgres_hostnamepostgres-service) -- [POSTGRES\_PORT=19095](#postgres_port19095) -- [POSTGRES\_USER=root](#postgres_userroot) -- [POSTGRES\_PASSWORD=root123](#postgres_passwordroot123) - - [๐Ÿณ Docker Development](#-docker-development) -- [To create a new migration:](#to-create-a-new-migration-1) -- [npm run migration:create](#npm-run-migrationcreate-1) -- [To apply migrations:](#to-apply-migrations-1) -- [To seed the database:](#to-seed-the-database-1) - - [๐Ÿš€ Kubernetes Deployment](#-kubernetes-deployment) - - [๐ŸŒ Frontend Routing in Production](#-frontend-routing-in-production) - - [๐Ÿ” HTTPS with Self-Signed Certificates](#-https-with-self-signed-certificates) - - [๐Ÿง  Development Best Practices](#-development-best-practices) - - [๐Ÿ“˜ API Documentation](#-api-documentation) - - [๐Ÿงฉ ChatGPT-Powered Endpoint Creation](#-chatgpt-powered-endpoint-creation) - - [๐Ÿงช Troubleshooting](#-troubleshooting) - - [๐Ÿค Contributing](#-contributing) - - [๐Ÿ“„ License](#-license) - - [Kubernetes Troubleshooting \& Redeployment Commands](#kubernetes-troubleshooting--redeployment-commands) - - [1. Rebuild the backend Docker image (after code/config changes)](#1-rebuild-the-backend-docker-image-after-codeconfig-changes) + - [Development Setup](#development-setup) + - [Important Note: Database Must Run in Docker](#important-note-database-must-run-in-docker) - [2. (If using a remote registry) Push the image](#2-if-using-a-remote-registry-push-the-image) - - [3. Upgrade the Helm release with the latest values](#3-upgrade-the-helm-release-with-the-latest-values) - - [4. Restart the backend deployment to pick up new images and env vars](#4-restart-the-backend-deployment-to-pick-up-new-images-and-env-vars) - - [5. Check backend pod environment variables](#5-check-backend-pod-environment-variables) - - [6. Check backend pod logs for errors](#6-check-backend-pod-logs-for-errors) - - [7. If you change DB env vars or code, repeat steps 1-6](#7-if-you-change-db-env-vars-or-code-repeat-steps-1-6) - - [Frontend Rebuild \& Redeploy (Kubernetes)](#frontend-rebuild--redeploy-kubernetes) - - [1. Rebuild the frontend Docker image](#1-rebuild-the-frontend-docker-image) - - [2. (If using a remote registry) Push the image](#2-if-using-a-remote-registry-push-the-image-1) - [3. Upgrade the Helm release](#3-upgrade-the-helm-release) - [4. Restart the frontend deployment](#4-restart-the-frontend-deployment) - [Port-Forwarding for Local Access](#port-forwarding-for-local-access) @@ -82,6 +47,7 @@ A full-stack application boilerplate with a React frontend and Node.js backend - [Troubleshooting Production](#troubleshooting-production) - [๐Ÿ†• Recent Improvements \& Troubleshooting](#-recent-improvements--troubleshooting) - [๐Ÿš€ Production Deployment Pipeline (CI/CD)](#-production-deployment-pipeline-cicd) + - [CI/CD Kubernetes Deployment Setup](#cicd-kubernetes-deployment-setup) --- @@ -557,3 +523,39 @@ The application uses a secure secrets management approach: - This ensures your database is always migrated and seeded with every deploy, and you'll know immediately if something goes wrong. - To trigger a production deployment, just push or merge to `main`. + +## CI/CD Kubernetes Deployment Setup + +To enable automated deployment to your Kubernetes cluster from CI/CD (Gitea Actions): + +1. **Get your kubeconfig file from your Kubernetes master node or provider.** + - For self-hosted clusters, it's usually at `~/.kube/config` on the master node. + - For managed clusters, download it from your provider's dashboard. + +2. **Edit the kubeconfig file:** + - Change the `server:` field to use your cluster's public IP or DNS, e.g.: + ```yaml + server: https://[YOUR_PUBLIC_IP_OR_DNS]:6443 + ``` + (For IPv6, use square brackets around the address.) + +3. **Base64-encode the kubeconfig file as a single line:** + - On Linux: + ```bash + base64 -w 0 /path/to/your/kubeconfig + ``` + - On Mac: + ```bash + base64 /path/to/your/kubeconfig | tr -d '\n' + ``` + +4. **Add the base64 string as a secret in your Gitea repository:** + - Go to **Settings โ†’ Secrets** + - Name: `KUBE_CONFIG` + - Value: (paste the base64 string) + +5. **Make sure port 6443 is open to your CI/CD runner's IP in your VPS firewall/security group.** + +6. **Your pipeline will now be able to deploy to your Kubernetes cluster.** + +---