Generic Helm chart for deploying any Docker container to Kubernetes.
helm install myapp . \
--set image.repository=myregistry/myapp \
--set image.tag=1.0.0 \
--set container.port=8080Or 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- 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
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 serviceUsing 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.comMultiple paths:
httpRoute:
enabled: true
hostnames:
- myapp.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /api
- matches:
- path:
type: Exact
value: /healthHeader-based routing:
httpRoute:
enabled: true
rules:
- matches:
- path:
type: PathPrefix
value: /
headers:
- name: x-version
value: v2To 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: /HTTP:
healthChecks:
liveness:
type: httpGet
httpGet:
path: /health
port: httpTCP:
healthChecks:
liveness:
type: tcpSocket
tcpSocket:
port: httpDisable:
healthChecks:
liveness:
enabled: false
readiness:
enabled: falsevolumes:
- name: data
persistentVolumeClaim:
claimName: myapp-data
volumeMounts:
- name: data
mountPath: /app/dataInit 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/logkubectl create secret docker-registry regcred \
--docker-server=myregistry.io \
--docker-username=user \
--docker-password=pass
# Then:
imagePullSecrets:
- name: regcred