Use K8s Only
This guide is intended for users who are familiar with Kubernetes. It does not cover how to set up a Kubernetes cluster or provide tutorials on using kubectl. Additionally, this guide may include some advanced Kubernetes terminology, so a certain level of familiarity is required for reading.
This article focuses on deploying GZCTF in a Kubernetes cluster. For configuration instructions specific to GZCTF itself, please refer to the Quick Start guide.
Deployment Notes
- GZCTF supports multi-instance deployment, but based on testing, currently the most stable deployment method is a single-instance deployment with the database on the same node. Therefore, this article will focus on single-instance deployment as an example.
- For multi-instance deployment, all instances need to use S3/Object Storage to ensure file consistency and write concurenncy (See #365). Additionally, Redis needs to be deployed to ensure cache consistency among multiple instances. Refer to appsettings documentation to configure both. Multiple providers are supported such as Azure/AWS/Minio.
- For multi-instance deployment, the load balancer needs to be configured with sticky sessions to enable real-time data retrieval using websockets.
- If you prefer a simpler deployment, go for a single-instance deployment!
- Since you have chosen to deploy with Kubernetes, it implies that you need a larger number of Pods. Please pay attention to the following configuration:
-
Specify
--kube-controller-manager-arg=node-cidr-mask-size=16during installation. The default CIDR is/24, supporting a maximum of 255 Pods. This cannot be changed after installation. -
Adjust the value of
maxPodsaccordingly, otherwise you may reach the Pod limit and be unable to schedule more Pods.
-
Deploying GZCTF
-
Create namespaces and configuration files. See appsettings
-
Create local PV (if you need to share storage among multiple instances, please change the configuration yourself)
-
Create the Deployment manifest of GZCTF
-
Create Service and Ingress
-
Additional Configuration for Traefik
In order to make GZCTF able to obtain the real IP address of users through XFF, Traefik needs to be able to add the XFF header correctly. Please note that the following content may not always be up-to-date and applicable to all versions of Traefik. This is an example of helm values, please search for the latest configuration method yourself.
Deployment Tips
- If you want GZCTF to automatically create an admin account during initialization, make sure to pass the
GZCTF_ADMIN_PASSWORDenvironment variable. Otherwise, you will need to manually create the admin account. - Please debug and verify if GZCTF can correctly retrieve the real IP address of users on the system log page. If not, check if the Traefik configuration is correct.
- If you want to monitor the resource usage, please deploy Prometheus and Grafana on your own, enable Prometheus support in Traefik, and monitor the resource usage of the challenge containers using node exporter.
- If you need to automatically update the deployment of GZCTF based on the configuration file, please refer to Reloader.
- Inside the cluster, you can use
https://kubernetes.default.svc.cluster.local:443as theserverfield in the cluster configuration file.