Skip to main content

Kubernetes Deployment

This guide covers deploying Posthoot on Kubernetes for production environments. Kubernetes provides excellent scalability, reliability, and management capabilities for your Posthoot instance.

Prerequisites

Before you begin, ensure you have:
  • Kubernetes cluster (v1.20 or later)
  • kubectl configured and connected to your cluster
  • Docker registry access for pushing images
  • NGINX Ingress Controller installed
  • cert-manager installed for SSL certificates
  • Storage class configured for persistent volumes

Quick Start

1. Clone and Navigate

2. Configure Secrets

Edit secret.yaml and replace the base64-encoded values:
Update these values in secret.yaml:
  • POSTGRES_PASSWORD
  • POSTGRES_USER
  • POSTGRES_DB
  • JWT_SECRET
  • AWS_ACCESS_KEY_ID (if using S3)
  • AWS_SECRET_ACCESS_KEY (if using S3)
  • SMTP_* credentials (if using SMTP)

3. Update Configuration

Edit configmap.yaml for non-sensitive settings:
  • Update domain names in ingress.yaml
  • Adjust resource limits if needed
  • Configure environment-specific settings

4. Deploy

Architecture

The Kubernetes setup includes:

Core Components

  • Namespace: posthoot-server for resource isolation
  • PostgreSQL: Database with persistent storage (10Gi)
  • Redis: Cache with persistent storage (5Gi)
  • Server: Application replicas with load balancing
  • Asynqmon: Background job monitoring dashboard

Networking

  • Services: Internal communication between components
  • Ingress: External access with SSL termination
  • Network Policies: Security rules for pod communication

Storage

  • Persistent Volumes: Data persistence for database and cache
  • ConfigMaps: Non-sensitive configuration
  • Secrets: Sensitive data management

Configuration

Environment Variables

Configuration is split between ConfigMaps and Secrets:

Resource Allocation

Default resource limits:

Scaling Configuration

The setup includes Horizontal Pod Autoscaler:

Management

Monitoring Deployment

Logs and Debugging

Scaling Operations

Updates and Rollouts

Backup and Recovery

Database Backup

Persistent Volume Backup

For production environments, consider:
  • Velero: For comprehensive backup and disaster recovery
  • Storage snapshots: Using your cloud provider’s snapshot features
  • Manual backups: Regular database dumps and file exports

Security

Network Policies

The setup includes network policies that:
  • Restrict pod-to-pod communication
  • Allow only necessary ports
  • Control ingress and egress traffic

Secrets Management

For production, consider:
  • External Secrets Operator: For cloud-native secrets
  • HashiCorp Vault: For advanced secrets management
  • Cloud provider secrets: AWS Secrets Manager, Azure Key Vault

RBAC

Consider creating specific ServiceAccounts and Roles:

Troubleshooting

Common Issues

1. Image Pull Errors

2. Database Connection Issues

3. Ingress Issues

4. Resource Issues

Debugging Commands

Production Considerations

Monitoring Setup

Install monitoring stack:

High Availability

For multi-zone deployments:
  • Deploy across multiple availability zones
  • Use anti-affinity rules for pod distribution
  • Configure proper resource requests and limits
  • Set up monitoring and alerting

Performance Tuning

Disaster Recovery

  1. Regular backups of database and persistent volumes
  2. Cross-region replication for critical data
  3. Documented recovery procedures
  4. Regular disaster recovery testing

Support

For Kubernetes-specific issues:
  1. Check the Kubernetes README
  2. Review Kubernetes documentation
  3. Check cluster events: kubectl get events -n posthoot-server
  4. Verify resource availability and quotas

Next Steps

After successful deployment:
  1. Configure monitoring and alerting
  2. Set up backups and test recovery
  3. Implement security best practices
  4. Plan scaling strategies
  5. Document procedures for your team