This document provides a comprehensive overview of the Drunk Charts architecture, explaining how the components work together to provide a powerful, flexible Helm chart solution.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Developer │ │ Application │ │ Kubernetes │
│ │ │ Code │ │ Cluster │
│ - values.yaml │────▶ - Dockerfile │────▶ - Deployments │
│ - helm install │ │ - Config │ │ - Services │
│ │ │ │ │ - Ingress │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ Drunk Charts System │
│ │
│ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ drunk-app │ │ drunk-lib │ │
│ │ │ │ │ │
│ │ Application │ uses │ Library Chart │ │
│ │ Chart │◄──────────│ │ │
│ │ │ │ - Reusable Templates │ │
│ │ - Chart.yaml │ │ - Helper Functions │ │
│ │ - values.yaml │ │ - Best Practices │ │
│ │ - templates/ │ │ - Production Ready │ │
│ └─────────────────┘ └─────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
drunk-app (Application Chart)
├── Chart.yaml
│ └── dependencies:
│ └── drunk-lib: "1.x.x" # Library Chart Dependency
├── values.yaml # Default configuration
├── templates/
│ ├── deployment.yaml #
│ ├── service.yaml #
│ ├── configmap.yaml #
│ └── ... # All templates include drunk-lib templates
└── charts/
└── drunk-lib/ # Downloaded dependency
drunk-lib (Library Chart)
├── Chart.yaml (type: library)
├── values.yaml # Default template values
└── templates/
├── _helpers.tpl # Common helper functions
├── _deployment.tpl # Deployment template logic
├── _service.tpl # Service template logic
├── _configmap.tpl # ConfigMap template logic
└── ... # All Kubernetes resource templates
helm install myapp drunk-appUser Values
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ drunk-app │────▶│ drunk-lib │────▶│ Kubernetes │
│ templates │ │ templates │ │ Resources │
│ │ │ │ │ │
│ deployment.yaml │ │ _deployment.tpl │ │ Deployment │
│ service.yaml │ │ _service.tpl │ │ Service │
│ configmap.yaml │ │ _configmap.tpl │ │ ConfigMap │
└─────────────────┘ └─────────────────┘ └─────────────────┘
The core library providing reusable templates and functions.
Core Resources
_deployment.tpl - Application deployment logic_statefulset.tpl - Stateful application support_service.tpl - Service discovery and networkingConfiguration Management
_configmap.tpl - Application configuration_secrets.tpl - Sensitive data management_secretprovider.tpl - Azure Key Vault integrationStorage & Persistence
_volumes.tpl - Persistent volume claimsBatch Processing
_cronjob.tpl - Scheduled job execution_job.tpl - One-time task executionNetworking & Access
_ingress.tpl - External access routing_service.tpl - Internal service discoveryScaling & Operations
_hpa.tpl - Horizontal pod autoscaling_serviceaccount.tpl - Pod identity management# Standard Kubernetes labels
# Application naming
# Selector labels for pod matching
# Checksum generation for config changes
The user-facing chart that provides a simple interface to the powerful drunk-lib templates.
Each drunk-app template is minimal and delegates to drunk-lib:
# drunk-app/templates/deployment.yaml
# drunk-app/templates/service.yaml
This approach provides:
# Global settings (affect all resources)
global:
image: "myapp/image"
tag: "v1.0.0"
imagePullPolicy: "IfNotPresent"
# Resource-specific settings
deployment:
enabled: true
replicaCount: 2
service:
type: "ClusterIP"
ingress:
enabled: true
hosts: [...]
# Feature toggles
autoscaling:
enabled: false
cronJobs: []
jobs: []
Feature Flags
# Enable/disable entire resource categories
deployment:
enabled: true # Creates Deployment
statefulset:
enabled: false # Skips StatefulSet
ingress:
enabled: true # Creates Ingress
Resource Templates
# Array-based resources
cronJobs:
- name: "backup"
schedule: "0 2 * * *"
- name: "cleanup"
schedule: "0 4 * * 0"
jobs:
- name: "migration"
command: ["/migrate.sh"]
Conditional Logic
# Render deployment
# Render each cronjob
User Input:
global.image: "myapp:v1.0.0"
deployment.replicaCount: 3
↓
Values Processing:
Merges with defaults
Validates configuration
↓
Template Rendering:
- Reads .Values.deployment
- Reads .Values.global
- Generates Kubernetes Deployment YAML
↓
Kubernetes Resources:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
labels: { ... }
spec:
replicas: 3
template:
spec:
containers:
- image: myapp:v1.0.0
Pod Security
# Default security contexts
podSecurityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 1000
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
Secret Management
Network Security
Azure Key Vault
│
│ Secrets Store CSI Driver
│
▼
SecretProviderClass ────▶ Pod Volume Mount
│ │
│ ▼
└────▶ Kubernetes Secret (optional)
# HPA Configuration
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70
# Resource requests (required for HPA)
resources:
requests:
cpu: 100m
memory: 128Mi
# Resource limits and requests
resources:
limits:
cpu: 1000m
memory: 1Gi
requests:
cpu: 100m
memory: 128Mi
volumes:
data:
size: "10Gi"
storageClass: "fast-ssd"
mountPath: "/app/data"
# Creates PVC and mounts to pod
volumes:
tmp:
mountPath: "/tmp"
emptyDir: true
cache:
mountPath: "/cache"
emptyDir: true
size: "1Gi" # Size limit
# Custom chart using drunk-lib
dependencies:
- name: drunk-lib
version: "1.x.x"
repository: "https://baoduy.github.io/drunk.charts/drunk-lib"
# Custom templates can extend drunk-lib
# Prometheus metrics
deployment:
ports:
metrics: 9090
# Custom annotations for monitoring
deployment:
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9090"
This architecture enables drunk-app to provide a simple interface while drunk-lib handles the complexity of production-ready Kubernetes deployments. The separation of concerns allows for easy maintenance, consistent behavior, and flexible customization.