Skip to content

About

A utility for converting a Devcontainer setup with caddy to a deployable helmchart with all infrastructure needed

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

dev-kontainers

deploy devcontainer setups to kubernetes

what it does

  • converts docker-compose devcontainer configs to k8s
  • replaces caddy proxy with kubernetes ingress
  • offers traefik, external-dns, and cert-manager as chart dependencies
  • adds external-dns and cert-manager annotations
  • creates deployable helm charts for dev environments
  • smart cert-manager configuration (self-signed for local, Let's Encrypt for remote)
  • builds custom devcontainer images with all features pre-installed

install

git clone <repo>
cd dev-kontainers
chmod +x install.sh
./install.sh

or local install:

INSTALL_DIR=~/.local/bin ./install.sh

usage

basic:

dev-kontainers

custom:

dev-kontainers --name mydev --ingress-class traefik --no-cert-manager

deploy automatically:

dev-kontainers --name mydev --deploy
# or
dev-kontainers --name mydev --dryrun false

options:

  • -n, --name - chart name (also used as namespace and release name)
  • -o, --output - output directory
  • -i, --ingress-class - ingress controller (default: traefik)
  • --deploy - deploy chart after generating (default: false)
  • --dryrun BOOL - set to false to deploy (default: true)
  • --no-external-dns - skip external dns annotations
  • --no-cert-manager - skip cert manager annotations
  • --cert-issuer - cert issuer name
  • -c, --compose-file - additional compose files

devcontainer images

if you have a .devcontainer/devcontainer.json file, the tool can build a custom image with all your devcontainer features pre-installed:

  • automatically detects devcontainer configuration
  • installs devcontainer CLI if missing
  • builds image during chart generation
  • configures chart to use the custom image
  • includes all features: docker, kubectl, helm, terraform, etc.

the tool will prompt you to build the custom image. if you decline, it uses the base image and you'll need to install tools manually in pods.

what you get

  • chart-name/ - helm chart directory
  • chart-name/deploy.sh - deployment script
  • chart-name/CONVERSION_SUMMARY.md - what got converted
  • all your services as k8s manifests
  • ingress with proper annotations
  • no more caddy

prerequisites

you need these in your k8s cluster:

traefik ingress controller (recommended)

helm repo add traefik https://helm.traefik.io/traefik
helm repo update
helm install traefik traefik/traefik --namespace traefik --create-namespace

exposing traefik on local clusters

kind clusters:

# option 1: port-forward (quick testing)
kubectl port-forward -n traefik svc/traefik 8080:80

# option 2: cluster with port mapping (recommended)
# add to kind config:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 80
    hostPort: 8080
  - containerPort: 443
    hostPort: 8443

# create cluster: kind create cluster --config=kind-config.yaml

minikube clusters:

# option 1: tunnel (enables LoadBalancer)
minikube tunnel  # run in separate terminal

# option 2: nodeport service
kubectl patch svc traefik -n traefik -p '{"spec":{"type":"NodePort"}}'
minikube service traefik -n traefik --url

k3d clusters:

# option 1: create cluster with port mapping
k3d cluster create dev --port '8080:80@loadbalancer' --port '8443:443@loadbalancer'

# option 2: port-forward existing cluster
kubectl port-forward -n traefik svc/traefik 8080:80

docker-desktop:

# usually works with LoadBalancer, or use NodePort:
kubectl patch svc traefik -n traefik -p '{"spec":{"type":"NodePort"}}'
kubectl get svc traefik -n traefik  # get the port

cert-manager (for tls)

helm repo add jetstack https://charts.jetstack.io
helm install cert-manager jetstack/cert-manager --set installCRDs=true

# create letsencrypt issuer
kubectl apply -f - <<EOF
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: your-email@domain.com
    privateKeySecretRef:
      name: letsencrypt-prod
    solvers:
    - http01:
        ingress:
          class: traefik
EOF

external-dns (for dns records)

helm repo add external-dns https://kubernetes-sigs.github.io/external-dns

# for aws route53
helm install external-dns external-dns/external-dns --set \
  provider=aws \
  --set aws.zoneType=public \
  --set txtOwnerId=external-dns

# for cloudflare
helm install external-dns external-dns/external-dns --set \
  provider=cloudflare \
  --set cloudflare.apiToken=your-token

deploy

after running the script:

cd your-chart-name
./deploy.sh

or manually:

helm install myapp . --namespace myapp --create-namespace

check status:

kubectl get pods,svc,ingress -n myapp

examples

see charts/ directory for example conversions

troubleshooting

no routes found: check your compose file has caddy: labels ingress pending: wait for ingress controller or check loadbalancer cert issues: verify cert-manager and issuer are working dns not resolving: check external-dns logs and provider config

ports must be defined in compose file ports section or caddy.reverse_proxy labels. no fallbacks.

About

A utility for converting a Devcontainer setup with caddy to a deployable helmchart with all infrastructure needed

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages