Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

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:

  1. Install Gateway API CRDs:
kubectl apply -k github.com/kubernetes-sigs/gateway-api//config/crd?ref=v1.0.0
  1. Install Cloudflare Gateway controller:
kubectl apply -k github.com/pl4nty/cloudflare-kubernetes-gateway//config/default?ref=v0.8.1
  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
  1. 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
  1. 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
  1. 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