tasko/DEPLOYMENT.md
2025-12-10 19:45:05 +02:00

6.2 KiB

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

# 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

# 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

My-Recipes

Adding a New Application

  1. Create application directory:

    mkdir <app-name>
    
  2. Create <app-name>/values.yaml:

    global:
      namespace: my-apps
    
    backend:
      image:
        repository: harbor.dvirlabs.com/my-apps/<app-name>-backend
        tag: "latest"
      service:
        port: 8000
        targetPort: 8000
      ingress:
        hosts:
          - host: api-<app-name>.dvirlabs.com
            paths:
              - path: /
                pathType: Prefix
        tls:
          - secretName: api-<app-name>-tls
            hosts:
              - api-<app-name>.dvirlabs.com
    
    frontend:
      image:
        repository: harbor.dvirlabs.com/my-apps/<app-name>-frontend
        tag: "latest"
      env:
        VITE_API_URL: "https://api-<app-name>.dvirlabs.com"
      ingress:
        hosts:
          - host: <app-name>.dvirlabs.com
            paths:
              - path: /
                pathType: Prefix
        tls:
          - secretName: <app-name>-tls
            hosts:
              - <app-name>.dvirlabs.com
    
    postgres:
      user: <app-name>_user
      password: <secure-password>
      database: <app-name>_db
    
  3. Create <app-name>/cname.yaml:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: <app-name>-cname
      namespace: my-apps
    data:
      frontend: <app-name>.dvirlabs.com
      backend: api-<app-name>.dvirlabs.com
    
  4. Deploy:

    helm install <app-name> ./app-chart -f <app-name>/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:

<app-name>.dvirlabs.com       CNAME/A    <ingress-loadbalancer-ip>
api-<app-name>.dvirlabs.com   CNAME/A    <ingress-loadbalancer-ip>

Monitoring Deployments

# 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

# 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

# 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:

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

kubectl describe pod -n my-apps <pod-name>
kubectl logs -n my-apps <pod-name>

Database connection issues

# Check if database is running
kubectl get pods -n my-apps -l component=database

# Test connection from backend pod
kubectl exec -n my-apps <backend-pod> -- env | grep DB_

Ingress not working

# Check ingress configuration
kubectl describe ingress -n my-apps <app-name>-backend
kubectl describe ingress -n my-apps <app-name>-frontend

# Check cert-manager certificates
kubectl get certificate -n my-apps
kubectl describe certificate -n my-apps <app-name>-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:
    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.