A ctfcli plugin for deploying CTF challenge containers to Kubernetes.
- Install the plugin:
ctf plugins install https://github.com/pl4nty/ctfcli-deploy-kubernetes.git - Install Kompose
- Install
kubectland configure cluster access, eg Google Kubernetes Engine docs - Login to a container registry, eg
docker login ghcr.io
- Add a Compose file like
docker-compose.ymlto your challenge(s) ctf challenge deploy --host "kubernetes://chals.example.com?registry=ghcr.io/username" --skip-login- If your Compose files already have
imagefields, the registry parameter isn't required - If your
.ctf/configfile contains registry credentials, the--skip-loginparameter isn't required
To expose pwn challenges to the internet:
- Ensure challenges have unique ports
- Choose a domain for challenges to be exposed on subdomains, eg
chals.example.com ctf challenge deploy --host "kubernetes://chals.example.com?registry=ghcr.io/username" --skip-login- Configure DNS for
chals.example.comto point to your cloud provider's load balancer external IP address - Visit your challenge eg at
chals.example.com:1234
To expose web challenges to the internet:
- Install an ingress controller
- Set it as the default IngressClass:
kubectl annotate ingressclass your-ingress-class ingressclass.kubernetes.io/is-default-class=true. Alternatively, setkompose.service.expose.ingress-class-namein an override - Choose a domain for challenges to be exposed on subdomains, eg
chals.example.com ctf challenge deploy --host "kubernetes://chals.example.com?registry=ghcr.io/username" --skip-login- Configure DNS for
*.chals.example.comto point to your ingress controller external IP address - Visit your challenge at
http://challenge-name.chals.example.com. This will be the first service in the Compose file, other services will be available with the patternhttp://challenge-name-service-name.chals.example.com - (Optional) Configure TLS termination at the ingress controller. If using the Ingress TLS field, create a Kubernetes secret in the challenge namespace and set
kompose.service.expose.tls-secretin an override. Secret creation can be automated with reflector for wildcard certificates (recommended) or cert-manager.
To use a private container registry with password authentication, create a Kubernetes secret in the challenge namespace. Secret creation can be automated with reflector.
kubectl create secret docker-registry ghcr --namespace=$namespace \
--docker-server=ghcr.io \
--docker-username=username \
--docker-password=passwordThen set kompose.image-pull-secret in an override.
Use the override parameter with a Compose file to merge it into challenges. This can enable certain features. For a full list of supported kompose labels, see the labels section of the Kompose docs.
services:
app:
labels:
kompose.image-pull-secret: 'mypullsecretname'
kompose.service.expose.ingress-class-name: 'myingressclass'
kompose.service.expose.tls-secret: 'mytlssecretname'