# Kubernetes Deployment Guide This repository contains a shared Helm chart (`app-chart`) that can be used to deploy multiple applications with the same architecture pattern. ## Repository Structure ``` . ├── app-chart/ # Shared Helm chart template │ ├── Chart.yaml │ ├── values.yaml # Default values │ ├── README.md # Detailed documentation │ └── templates/ # Kubernetes manifests templates ├── tasko/ # Tasko application overrides │ ├── values.yaml # Tasko-specific values │ └── cname.yaml # DNS configuration ├── my-recipes/ # My-Recipes application overrides │ ├── values.yaml # My-Recipes-specific values │ └── cname.yaml # DNS configuration └── my-recipes-chart/ # Old my-recipes chart (deprecated) ``` ## Quick Start ### Deploy Tasko Application ```bash # Install helm install tasko ./app-chart -f tasko/values.yaml -n my-apps --create-namespace # Upgrade helm upgrade tasko ./app-chart -f tasko/values.yaml -n my-apps # Uninstall helm uninstall tasko -n my-apps ``` ### Deploy My-Recipes Application ```bash # Install helm install my-recipes ./app-chart -f my-recipes/values.yaml -n my-apps --create-namespace # Upgrade helm upgrade my-recipes ./app-chart -f my-recipes/values.yaml -n my-apps # Uninstall helm uninstall my-recipes -n my-apps ``` ## Application URLs ### Tasko - Frontend: https://tasko.dvirlabs.com - Backend API: https://api-tasko.dvirlabs.com ### My-Recipes - Frontend: https://my-recipes.dvirlabs.com - Backend API: https://api-my-recipes.dvirlabs.com ## Adding a New Application 1. **Create application directory**: ```bash mkdir ``` 2. **Create `/values.yaml`**: ```yaml global: namespace: my-apps backend: image: repository: harbor.dvirlabs.com/my-apps/-backend tag: "latest" service: port: 8000 targetPort: 8000 ingress: hosts: - host: api-.dvirlabs.com paths: - path: / pathType: Prefix tls: - secretName: api--tls hosts: - api-.dvirlabs.com frontend: image: repository: harbor.dvirlabs.com/my-apps/-frontend tag: "latest" env: VITE_API_URL: "https://api-.dvirlabs.com" ingress: hosts: - host: .dvirlabs.com paths: - path: / pathType: Prefix tls: - secretName: -tls hosts: - .dvirlabs.com postgres: user: _user password: database: _db ``` 3. **Create `/cname.yaml`**: ```yaml apiVersion: v1 kind: ConfigMap metadata: name: -cname namespace: my-apps data: frontend: .dvirlabs.com backend: api-.dvirlabs.com ``` 4. **Deploy**: ```bash helm install ./app-chart -f /values.yaml -n my-apps ``` ## Configuration Each application can override the base configuration by providing custom values in their `values.yaml` file. Common overrides include: - Image repository and tags - Resource limits and requests - Environment variables - Ingress hostnames - Database credentials - Replica counts See `app-chart/README.md` for detailed configuration options. ## Prerequisites - Kubernetes cluster (1.19+) - Helm 3.0+ - Traefik Ingress Controller installed - cert-manager installed (for automatic TLS certificates) - kubectl configured to access your cluster ## DNS Configuration Configure DNS records to point to your ingress controller: ``` .dvirlabs.com CNAME/A api-.dvirlabs.com CNAME/A ``` ## Monitoring Deployments ```bash # Check all deployments kubectl get all -n my-apps # Check specific application kubectl get pods -n my-apps -l app.kubernetes.io/instance=tasko # View logs kubectl logs -n my-apps -l component=backend --tail=100 -f kubectl logs -n my-apps -l component=frontend --tail=100 -f # Check ingress kubectl get ingress -n my-apps ``` ## Database Management ### Access PostgreSQL ```bash # Port forward to access database locally kubectl port-forward -n my-apps svc/tasko-db 5432:5432 # Connect using psql psql postgresql://tasko_user:tasko_password@localhost:5432/tasko_db ``` ### Backup Database ```bash # Backup kubectl exec -n my-apps tasko-db-0 -- pg_dump -U tasko_user tasko_db > backup.sql # Restore kubectl exec -i -n my-apps tasko-db-0 -- psql -U tasko_user tasko_db < backup.sql ``` ## CI/CD Integration The chart works seamlessly with CI/CD pipelines. Example with Woodpecker CI: ```yaml steps: deploy: image: alpine/helm:3.12.0 commands: - helm upgrade --install tasko ./app-chart -f tasko/values.yaml --set backend.image.tag=${CI_COMMIT_SHA} --set frontend.image.tag=${CI_COMMIT_SHA} -n my-apps ``` ## Troubleshooting ### Pod not starting ```bash kubectl describe pod -n my-apps kubectl logs -n my-apps ``` ### Database connection issues ```bash # Check if database is running kubectl get pods -n my-apps -l component=database # Test connection from backend pod kubectl exec -n my-apps -- env | grep DB_ ``` ### Ingress not working ```bash # Check ingress configuration kubectl describe ingress -n my-apps -backend kubectl describe ingress -n my-apps -frontend # Check cert-manager certificates kubectl get certificate -n my-apps kubectl describe certificate -n my-apps -tls ``` ## Migration from Old Chart If migrating from the old `my-recipes-chart`: 1. **Backup your data** 2. **Update DNS** if hostnames changed 3. **Deploy with new chart**: ```bash helm uninstall my-recipes # Old release helm install my-recipes ./app-chart -f my-recipes/values.yaml -n my-apps ``` ## Support For detailed documentation, see: - `app-chart/README.md` - Complete chart documentation - `helm/README.md` - Docker image building and deployment For issues and questions, please open an issue in the repository.