Development - Kubernetes ======================= This guide covers deploying Watcher to Kubernetes using Helm charts for local development. Prerequisites ------------- Before deploying Watcher to Kubernetes for local development, ensure you have the following installed: 1. **Docker Desktop** with Kubernetes enabled 2. **kubectl** - Kubernetes command-line tool 3. **Helm** - Kubernetes package manager .. note:: **Kubernetes Cluster Required**: Make sure Docker Desktop's Kubernetes cluster is running. You can enable it in Docker Desktop settings under "Kubernetes" and ensure the cluster is started. Installation Steps ------------------ Install kubectl ~~~~~~~~~~~~~~~ .. tabs:: .. tab:: macOS (Homebrew) .. code-block:: bash brew install kubectl .. tab:: Linux .. code-block:: bash curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl .. tab:: Windows (Chocolatey) .. code-block:: bash choco install kubernetes-cli Install Helm ~~~~~~~~~~~~ .. tabs:: .. tab:: macOS/Linux .. code-block:: bash curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash .. tab:: Windows (Chocolatey) .. code-block:: bash choco install kubernetes-helm Verify Installation ~~~~~~~~~~~~~~~~~~~ .. code-block:: bash kubectl version --client helm version Deploy to Kubernetes -------------------- Quick Start with Make Commands (Recommended) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The easiest way to deploy is using the provided Make commands: .. code-block:: bash # Complete development deployment with one command make dev-kube This single command will: - Build the Docker image - Start PostgreSQL and Redis dependencies from Docker Compose - Deploy to Kubernetes with Helm using NodePort service - Expose the service on port 8000 Access Your Application ~~~~~~~~~~~~~~~~~~~~~~~ After running ``make dev-kube``, you can access: - **Main Application**: http://localhost:8000 - **API Documentation**: http://localhost:8000/scalar .. note:: **NodePort Service**: The service is exposed directly on port 8000, so no port forwarding or external IP needed! Stop the Development Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To stop the development environment: .. code-block:: bash # In a new terminal window make dev-kube-stop This will: - Remove the Helm deployment - Stop all dependencies - Clean up resources Manual Development Setup - Alternative -------------------------------------- If you prefer to run commands manually for development: Start Dependencies ~~~~~~~~~~~~~~~~~~ Start PostgreSQL and Redis using docker-compose: .. code-block:: bash docker-compose up -d postgres redis Verify services are running: .. code-block:: bash docker-compose ps Build Docker Image ^^^^^^^^^^^^^^^^^^ Build the Watcher Docker image: .. code-block:: bash docker build -t watcher:latest . Deploy with Helm ^^^^^^^^^^^^^^^^^ Deploy using Helm: .. code-block:: bash helm install watcher ./watcher Check deployment status: .. code-block:: bash kubectl get pods kubectl get services Access the Application ^^^^^^^^^^^^^^^^^^^^^^ With NodePort service configured, access the application via: - **Health Check**: http://localhost:8000 - **API Documentation**: http://localhost:8000/scalar .. note:: **NodePort Service**: The service is exposed directly on port 8000, making it simple to access for development. Cleanup ------- Remove the Deployment ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash helm uninstall watcher docker-compose down .. note:: Don't forget to stop the Kubernetes cluster in Docker Desktop!