🗑️ Removed: - Legacy Support section with deprecated targets (k8s-deploy, k8s-undeploy, deploy, undeploy) - 18 lines of deprecated makefile targets and warnings 📚 Documentation Updates: - README.md: Updated Kubernetes deployment commands and project structure - KUSTOMIZE_MIGRATION.md: Replaced deprecated commands with current ones - k8s-kustomize/README.md: Updated deployment command references - APP_NAME_CONFIGURATION.md: Updated deployment example command - config/README.md: Replaced migration script references with config generation - ARCHITECTURE_MIGRATION.md: Updated to reflect completed migration status - PROJECT_STRUCTURE.md: Updated services structure to show unified database service - IMPLEMENTATION_SUMMARY.md: Updated legacy compatibility notes ✨ Improvements: - Clean Makefile with only current, supported targets - Consistent documentation referring to current command structure - Removed all references to deleted CouchDB service files - Updated project structure diagrams to reflect current architecture 🧪 Verification: - All 292 unit tests passing - Integration tests passing - Makefile help command displays cleanly - No deprecated command references remain in documentation
Kustomize Deployment Configuration
This directory contains the Kustomize configuration for deploying the rxminder (Medication Reminder) application to Kubernetes. Kustomize provides a template-free way to customize application configuration that simplifies the use of off-the-shelf applications.
Directory Structure
k8s-kustomize/
├── base/ # Base configuration (shared resources)
│ ├── kustomization.yaml # Base kustomization file
│ ├── config.env # Environment variables for ConfigMap
│ ├── registry-config.json # Docker registry configuration
│ ├── frontend-deployment.yaml # Frontend deployment
│ ├── frontend-service.yaml # Frontend service
│ ├── couchdb-statefulset.yaml # CouchDB database
│ ├── couchdb-service.yaml # CouchDB service
│ ├── couchdb-pvc.yaml # CouchDB persistent volume
│ ├── configmap.yaml # Application configuration
│ ├── ingress.yaml # Ingress configuration
│ ├── network-policy.yaml # Network policies
│ ├── hpa.yaml # Horizontal Pod Autoscaler
│ └── db-seed-job.yaml # Database seeding job
├── overlays/ # Environment-specific overrides
│ ├── dev/ # Development environment
│ │ └── kustomization.yaml # Development customizations
│ └── prod/ # Production environment
│ ├── kustomization.yaml # Production customizations
│ ├── frontend-resources.yaml # Production frontend resources
│ ├── couchdb-resources.yaml # Production database resources
│ └── ingress-prod.yaml # Production ingress config
└── README.md # This file
Quick Start
Prerequisites
- kubectl installed and configured
- Kubernetes cluster access
- Docker images built and pushed to registry
Deploy to Development
# Using Makefile (recommended)
make deploy-dev
# Or directly with kubectl
kubectl apply -k k8s-kustomize/overlays/dev
Deploy to Production
# Using Makefile (recommended)
make deploy-prod
# Or directly with kubectl
kubectl apply -k k8s-kustomize/overlays/prod
Environment Configurations
Development Environment
- Namespace:
rxminder-dev - Replicas: 1 frontend pod
- Resources: Minimal (16Mi-32Mi memory)
- Image Tag:
dev - Domain:
rxminder-dev.local - Storage: 1Gi
- Security: Relaxed for development
Production Environment
- Namespace:
rxminder-prod - Replicas: 3 frontend pods (high availability)
- Resources: Production-grade (256Mi-512Mi memory)
- Image Tag:
v1.0.0(semantic versioning) - Domain:
rxminder.yourdomain.com - Storage: 10Gi SSD
- Security: Hardened with security contexts, network policies
- TLS: Enabled with cert-manager
- Monitoring: Enabled
Makefile Commands
Deployment Commands
# Development
make deploy-dev # Deploy to development
make undeploy-dev # Remove development deployment
make quick-deploy-dev # Build and deploy to development
make status-dev # Show development status
# Production
make deploy-prod # Deploy to production
make undeploy-prod # Remove production deployment
make quick-deploy-prod # Build and deploy to production
make status-prod # Show production status
Validation Commands
make validate-kustomize # Validate all configurations
make kustomize-validate-dev # Validate development config
make kustomize-validate-prod # Validate production config
Debugging Commands
make kustomize-dry-run-dev # Dry run development deployment
make kustomize-dry-run-prod # Dry run production deployment
make kustomize-diff-dev # Show differences for development
make kustomize-diff-prod # Show differences for production
make kustomize-build-dev # Build development manifests
make kustomize-build-prod # Build production manifests
Configuration Management
ConfigMaps
Configuration is managed through:
- Base config.env: Common environment variables
- Overlay literals: Environment-specific overrides
- ConfigMap generation: Automatic from environment files
Secrets
Secrets are managed through:
- Development: Simple literals in kustomization.yaml
- Production: External secret management (recommended)
- Kubernetes External Secrets Operator
- HashiCorp Vault
- AWS Secrets Manager
- Azure Key Vault
Images
Image management uses Kustomize's image transformer:
images:
- name: gitea-http.taildb3494.ts.net/will/rxminder
newTag: v1.0.0 # Override in overlays
Customization
Adding a New Environment
- Create new directory:
overlays/staging/ - Create
kustomization.yamlwith base reference - Add environment-specific patches
- Update Makefile with new targets
Example:
# overlays/staging/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: rxminder-staging
commonLabels:
environment: staging
images:
- name: gitea-http.taildb3494.ts.net/will/rxminder
newTag: staging
Resource Patches
Use strategic merge patches for complex modifications:
# Example: frontend-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: rxminder-frontend
spec:
template:
spec:
containers:
- name: frontend
resources:
requests:
memory: '512Mi'
cpu: '200m'
JSON Patches
Use JSON patches for precise modifications:
patches:
- target:
kind: Deployment
name: rxminder-frontend
patch: |-
- op: replace
path: /spec/replicas
value: 5
Security Considerations
Production Security Features
- Security Contexts: Non-root containers, read-only filesystems
- Network Policies: Restricted pod-to-pod communication
- Resource Limits: Prevent resource exhaustion
- Image Security: Signed images, vulnerability scanning
- Secret Management: External secret stores
- TLS Encryption: HTTPS with cert-manager
- RBAC: Role-based access control
Development Security
- Relaxed for development efficiency
- Still follows basic security practices
- Isolated in separate namespace
Monitoring and Observability
Production Monitoring
- Health Checks: Liveness and readiness probes
- Metrics: Resource usage monitoring
- Logging: Structured logging with appropriate levels
- Alerting: Production-grade alert rules
Development Monitoring
- Debug Logging: Verbose logging for troubleshooting
- Resource Monitoring: Basic resource tracking
- Health Checks: Relaxed timing for development
Troubleshooting
Common Issues
-
Image Pull Errors
# Check image exists and credentials are correct kubectl describe pod <pod-name> -n <namespace> -
ConfigMap Issues
# Check generated ConfigMap kubectl get configmap rxminder-config -n <namespace> -o yaml -
Service Discovery
# Test service connectivity kubectl exec -it <pod-name> -n <namespace> -- curl rxminder-couchdb-service:5984 -
Resource Constraints
# Check resource usage kubectl top pods -n <namespace> kubectl describe node
Debug Commands
# View all resources
kubectl get all -n rxminder-dev -l app=rxminder
# Check events
kubectl get events -n rxminder-dev --sort-by='.lastTimestamp'
# View logs
kubectl logs deployment/rxminder-frontend -n rxminder-dev -f
# Describe problematic resources
kubectl describe deployment rxminder-frontend -n rxminder-dev
Migration from Legacy Deployment
Migration Steps
- Test Kustomize: Deploy to development first
- Validate Configuration: Compare with existing deployment
- Update CI/CD: Switch to Kustomize commands
- Production Migration: Schedule maintenance window
- Cleanup: Remove old template files after validation
Rollback Plan
Legacy deployment scripts are still available:
make deploy-dev # Deploy to development environment
make deploy-prod # Deploy to production environment
make undeploy-dev # Remove development deployment
make undeploy-prod # Remove production deployment
Benefits of Kustomize
- Template-free: No complex templating logic
- Composable: Layer configurations naturally
- Validation: Built-in YAML validation
- GitOps Ready: Works with ArgoCD, Flux
- Standard: Kubernetes-native solution
- Maintainable: Clear separation of concerns
Best Practices
- Base Configuration: Keep base as generic as possible
- Environment Isolation: Use separate namespaces
- Secret Management: Use external secret stores in production
- Image Tags: Use specific tags, avoid
latestin production - Resource Limits: Always set resource requests and limits
- Health Checks: Configure appropriate probes
- Documentation: Keep this README updated
Support
For issues or questions:
- Check troubleshooting section above
- Review Kubernetes events and logs
- Validate Kustomize configuration
- Consult team documentation
Note: This Kustomize configuration replaces the previous shell script-based deployment. The old scripts are still available for backward compatibility but Kustomize is the recommended approach going forward.