app
Generic Helm chart for deploying Docker containers
About this chart
Generic App Chart
Generic Helm chart for deploying any Docker container to Kubernetes.
Usage
helm install myapp . \
--set image.repository=myregistry/myapp \
--set image.tag=1.0.0 \
--set container.port=8080
Or with a values file:
image:
repository: myregistry/myapp
tag: '1.0.0'
container:
port: 8080
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: db-creds
key: url
- name: NODE_ENV
value: production
service:
type: ClusterIP
port: 80
httpRoute:
enabled: true
hostnames:
- myapp.example.com
# Rules are optional - defaults to routing all traffic to service
resources:
limits:
cpu: 1000m
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
Key Features
- Any Docker container deployment
- Service types: ClusterIP, NodePort, LoadBalancer
- Gateway API (HTTPRoute) support
- Cloudflare Tunnels integration
- Configurable health checks (HTTP, TCP, exec)
- HPA support
- Persistent volumes
- Init containers & sidecars
- Security contexts
Gateway API
The HTTPRoute can use useDefaultGateways: All (default) to automatically bind to all default Gateways in the cluster, or use parentRefs to reference specific Gateways.
Basic HTTPRoute with default gateways:
httpRoute:
enabled: true
useDefaultGateways: All # Default - binds to all Gateways with defaultScope: All
hostnames:
- myapp.example.com
# Rules are optional - defaults to routing all traffic to service
Using specific parent gateways:
httpRoute:
enabled: true
# useDefaultGateways: null # Leave empty to use parentRefs instead
parentRefs:
- name: gateway
namespace: gateway-system
sectionName: http
hostnames:
- myapp.example.com
Multiple paths:
httpRoute:
enabled: true
hostnames:
- myapp.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /api
- matches:
- path:
type: Exact
value: /health
Header-based routing:
httpRoute:
enabled: true
rules:
- matches:
- path:
type: PathPrefix
value: /
headers:
- name: x-version
value: v2
Cloudflare Tunnels
To use Cloudflare Tunnels:
- Install Gateway API CRDs:
kubectl apply -k github.com/kubernetes-sigs/gateway-api//config/crd?ref=v1.0.0
- Install Cloudflare Gateway controller:
kubectl apply -k github.com/pl4nty/cloudflare-kubernetes-gateway//config/default?ref=v0.8.1
- Create Cloudflare credentials secret:
kubectl create secret generic cloudflare \
--from-literal=ACCOUNT_ID=your-account-id \
--from-literal=TOKEN=your-api-token \
-n cloudflare-gateway
- Create GatewayClass:
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: cloudflare
spec:
controllerName: github.com/pl4nty/cloudflare-kubernetes-gateway
parametersRef:
group: ''
kind: Secret
namespace: cloudflare-gateway
name: cloudflare
- Create Gateway:
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: shared-gateway
namespace: gateway-system
spec:
gatewayClassName: cloudflare
listeners:
- protocol: HTTP
port: 80
name: http
- Deploy your app with HTTPRoute enabled:
httpRoute:
enabled: true
hostnames:
- myapp.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
Health Checks
HTTP:
healthChecks:
liveness:
type: httpGet
httpGet:
path: /health
port: http
TCP:
healthChecks:
liveness:
type: tcpSocket
tcpSocket:
port: http
Disable:
healthChecks:
liveness:
enabled: false
readiness:
enabled: false
Storage
volumes:
- name: data
persistentVolumeClaim:
claimName: myapp-data
volumeMounts:
- name: data
mountPath: /app/data
Advanced
Init containers:
initContainers:
- name: migrations
image: myapp:1.0.0
command: ['python', 'manage.py', 'migrate']
Sidecars:
sidecars:
- name: logs
image: fluent/fluent-bit:2.0
volumeMounts:
- name: logs
mountPath: /var/log
Private Registry
kubectl create secret docker-registry regcred \
--docker-server=myregistry.io \
--docker-username=user \
--docker-password=pass
# Then:
imagePullSecrets:
- name: regcred
Deploy app with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has app on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartapp is pinned at v1.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply