Usage with Kubernetes
Requirements
- kubectl
- helm
- Configure kubectl to use a DEV instance
How it works in devbox?
For each stack supporting K8S deployment, a k8s-deploy.sh
helper script is provided to :
- Create a namespace for the stack
- Deploy the stack either with Kustomize (
kubectl apply -k ...
) or helm (helm upgrade --install ...
) - Create Ingress resource(s) using “bash templating” to ease customization using environment variables (ex :
DEVBOX_HOSTNAME=dev.my-domain.com
)
Load Balancing
Stacks are created assuming the :
- traefik or nginx-ingress-controller is deployed
- cert-manager is deployed with a ClusterIssuer (see helper scripts to create “mkcert”, “letsencrypt-http” or “letsencrypt-dns”)
The following environment variables provides some option for Ingress resources creation :
Name | Description | Default value |
---|---|---|
DEVBOX_HOSTNAME |
The base domain use to expose applications (ex : https://whoami.${DEVBOX_HOSTNAME} ) |
dev.localhost |
DEVBOX_INGRESS |
The ingressClassName to select an ingress controller |
traefik |
DEVBOX_ISSUER |
The name of the ClusterIssuer for cert-manager | mkcert |
The principle is illustrated bellow for https://whoami.dev.localhost :
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami
annotations:
cert-manager.io/cluster-issuer: "${DEVBOX_ISSUER}"
spec:
ingressClassName: ${DEVBOX_INGRESS}
rules:
- host: whoami.$DEVBOX_HOSTNAME
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: whoami
port:
number: 80
tls:
- hosts:
- whoami.$DEVBOX_HOSTNAME
secretName: whoami-cert
Moving to production?
Note that :