Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
1b33b1e
feat: add Terraform S3 backend templating system
The0mikkel Dec 8, 2025
01d269c
feat: add CTFp cluster setup
The0mikkel Dec 8, 2025
ec2a8db
Update formatting of variables
The0mikkel Dec 8, 2025
1c72e3f
Update scaling variables for challenge nodes and autoscaler
The0mikkel Dec 8, 2025
d9f4603
feat: add CTFp ops setup
The0mikkel Dec 8, 2025
23248a1
refactor: add kube_hetzner_version variable and update module version…
The0mikkel Dec 8, 2025
0ab7df6
docs: update README with additional services included in Ops
The0mikkel Dec 8, 2025
cb8b8e6
docs: update backend config reference in README for ops setup
The0mikkel Dec 8, 2025
9f6aaba
docs: update README links to refer to CTFp instead of full name
The0mikkel Dec 8, 2025
83b911d
feat: add CTFp platform setup
The0mikkel Dec 8, 2025
f14bf8d
refactor: add Terraform S3 bucket credentials environment file templates
The0mikkel Dec 8, 2025
ed877a8
feat: add CTFp challenges setup
The0mikkel Dec 8, 2025
e44a09a
refactor: update error fallback image version to 1.2.1 in platform an…
The0mikkel Dec 8, 2025
32b6fda
feat: add initial ArgoCD application and project configurations
The0mikkel Dec 8, 2025
70c6aac
feat: add pull-secret Terraform module
The0mikkel Dec 8, 2025
c6ef892
feat: add private-repo Terraform module
The0mikkel Dec 8, 2025
eaa83a8
feat: add ingress Terraform module
The0mikkel Dec 8, 2025
a1f6a8b
feat: add database Terraform module
The0mikkel Dec 8, 2025
4e49a9f
refactor: update database name to match standard naming convention
The0mikkel Dec 8, 2025
cacdf12
feat: add mariadb cluster Terraform module
The0mikkel Dec 8, 2025
1dbfac6
feat: add redis Terraform module
The0mikkel Dec 8, 2025
102c39a
feat: add kubectf Terraform module
The0mikkel Dec 8, 2025
e4a1531
Add initial system (#6)
The0mikkel Dec 8, 2025
85f2605
docs: add warning about system publishing status
The0mikkel Dec 8, 2025
248d0a0
Add template for automated setup configuration in terraform variables
The0mikkel Dec 11, 2025
0b249ca
Renamed CLI to CTFp
The0mikkel Dec 18, 2025
aed4732
chore: add copyright notice to the top of ctfp.py
The0mikkel Dec 18, 2025
c65402f
Add updated tfvars variable list
The0mikkel Dec 18, 2025
5341018
Remove unused DNS variables and add GitHub Container Registry credent…
The0mikkel Dec 18, 2025
dd1133a
Move to correct HCL2 language parsing for TFVARS interactions
The0mikkel Dec 18, 2025
d15371b
Update tfvars templates for improved configuration and resource alloc…
The0mikkel Dec 18, 2025
04b015a
Rename template file to use automated.tfvars extension for clarity
The0mikkel Dec 18, 2025
9db4442
refactor: update backend generator to work with ctfp cli command system
The0mikkel Dec 18, 2025
c7357d9
Integrate backend generator into CLI commands
The0mikkel Dec 18, 2025
04b0514
refactor: correct variable type to not use string based type
The0mikkel Dec 18, 2025
8f2238a
fix: update descheduler chart version and correct Helm chart path
The0mikkel Dec 18, 2025
ae2dbe0
fix: update namespace reference in errors pull secret module
The0mikkel Dec 18, 2025
b0834f5
refactor: change default value of challenge variables from list to map
The0mikkel Dec 19, 2025
539109e
feat: add kubectl setup script for configuring kubectl context for CT…
The0mikkel Dec 19, 2025
78f19ee
refactor: update CTF configuration with platform DNS and GitHub manag…
The0mikkel Dec 19, 2025
284d402
fix: update Elasticsearch configuration for Filebeat integration
The0mikkel Dec 19, 2025
3afd0a8
fix: correct shared_challenges variable assignment in challenges-config
The0mikkel Dec 19, 2025
ce8ff4c
feat: add GitHub user to ctfd-manager secret and deployment environment
The0mikkel Dec 19, 2025
ce08158
refactor: update region settings and add GitHub repository configurat…
The0mikkel Dec 19, 2025
1311cae
refactor: tfvars handling and values
The0mikkel Dec 19, 2025
e39c266
Correct typos and improve descriptions in configuration files
The0mikkel Dec 19, 2025
4bf3715
declare AUTO_APPLY as global in Deploy and Destroy classes
The0mikkel Dec 20, 2025
ed87279
Update path in init_terraform call for cluster destruction
The0mikkel Dec 20, 2025
bf0aac5
refactor: improve subprocess handling in run function for better comp…
The0mikkel Dec 20, 2025
d99ad49
refactor: sanitize script path and handle special characters in commands
The0mikkel Dec 20, 2025
6dbd7f7
Add better error handling for file handling
The0mikkel Dec 20, 2025
6e43464
refactor: rename parameter in extract_tuple_from_list for clarity
The0mikkel Dec 20, 2025
e5a9677
refactor: specify Exception in error handling for clarity
The0mikkel Dec 20, 2025
2c32a61
refactor: simplify command construction for clarity
The0mikkel Dec 20, 2025
c71b92e
refactor: simplify command construction for clarity
The0mikkel Dec 20, 2025
d6ebb08
refactor: standardize boolean values for clarity
The0mikkel Dec 20, 2025
62d903e
refactor: add shebang for script execution compatibility
The0mikkel Dec 20, 2025
6f5419b
refactor: encapsulate deployment logic within Terraform class
The0mikkel Dec 20, 2025
b81f028
refactor: update key generation logic and add create script
The0mikkel Dec 20, 2025
bdd9873
refactor: update insert_keys to insert in place
The0mikkel Dec 20, 2025
37a60b9
refactor: update challenges_branch to default to empty string
The0mikkel Dec 20, 2025
d7df136
fix: update kube-ctf image version to 1.0.2
The0mikkel Dec 20, 2025
d0e0afa
refactor: clarify version variable usage in kube.tf comments
The0mikkel Dec 20, 2025
e64f885
refactor: reorder local category variables and update references in c…
The0mikkel Dec 20, 2025
b481018
fix: rename kube-ctf CRD from isolated to instanced
The0mikkel Dec 20, 2025
ae40e91
refactor: add instancing fallback middleware to Traefik configuration
The0mikkel Dec 20, 2025
b39e62e
Add CTFd configuration files to .gitignore
The0mikkel Dec 20, 2025
a7cf54d
refactor: update Terraform execution process
The0mikkel Dec 20, 2025
83aea9c
Correct comment formatting for kubectf_container_secret in automated.…
The0mikkel Dec 20, 2025
316af2c
refactor: improve placeholder check in Terraform class
The0mikkel Dec 20, 2025
6fd931c
refactor: simplify platform check for Linux and bash requirements
The0mikkel Dec 20, 2025
a65bc43
refactor: remove set -e and set +e from script for improved readability
The0mikkel Dec 21, 2025
5368a64
refactor: correct kind casing for InstancedChallenge in CRD definition
The0mikkel Dec 21, 2025
3b98f97
refactor: enhance PATH validation to reject special characters that m…
The0mikkel Dec 21, 2025
964cbda
refactor: update key generation terminology from RSA to SSH
The0mikkel Dec 21, 2025
336da3e
refactor: replace os.system with shutil.copyfile for file copying and…
The0mikkel Dec 21, 2025
125d488
refactor: change shell execution to use shell=False for improved secu…
The0mikkel Dec 21, 2025
1eb889b
refactor: remove unused Utils class and streamline command execution …
The0mikkel Dec 21, 2025
7916063
feat: add CTFp CLI tool (#10)
The0mikkel Dec 21, 2025
3f67866
Remove notes
The0mikkel Dec 21, 2025
6be538a
fix: update usage comment in kubectl.sh to reflect correct script name
The0mikkel Dec 21, 2025
ee876dd
fix: correct tfvars filename generation for test environment to inclu…
The0mikkel Dec 21, 2025
5d656af
Initial documentation
The0mikkel Dec 21, 2025
e167434
docs: clarify usage of environment flags in initialization commands
The0mikkel Dec 21, 2025
8dbb502
docs: update usage instructions in kubectl.sh to reflect sourcing
The0mikkel Dec 21, 2025
26f8525
Start on architecture section
The0mikkel Dec 21, 2025
ecb98bc
Reorganize structure
The0mikkel Dec 24, 2025
b2e3a88
feat: add loading of S3 backend credentials from automated.tfvars
The0mikkel Dec 26, 2025
49afd8b
refactor: update template.automated.tfvars with S3 backend credentials
The0mikkel Dec 26, 2025
b9cb418
refactor: add error handling for missing S3 backend credentials in au…
The0mikkel Dec 26, 2025
97f6ae6
refactor: correct typo in log message for tool availability check
The0mikkel Dec 26, 2025
0e5f22f
refactor: streamline loading of S3 backend credentials from automated…
The0mikkel Dec 26, 2025
f6b0434
fix: update placeholder check to allow GitHub URLs
The0mikkel Dec 26, 2025
bb08350
feat: add dedicated challenges node type
The0mikkel Dec 26, 2025
456c395
refactor: remove example environment file to enhance security
The0mikkel Dec 26, 2025
8673094
Feat/remove env file (#12)
The0mikkel Dec 26, 2025
c6a0f42
Continued work on documentation
The0mikkel Dec 26, 2025
3c04016
Continued work on documentation
The0mikkel Dec 26, 2025
10f42e1
Continued work on documentation
The0mikkel Dec 26, 2025
436b28d
Add generate-backend command
The0mikkel Dec 26, 2025
a7e2e4f
Continued work on documentation
The0mikkel Dec 26, 2025
ed74bcd
Continued work on documentation
The0mikkel Dec 26, 2025
2570a6d
Continued work on documentation
The0mikkel Dec 26, 2025
118b4e2
Continued work on documentation
The0mikkel Dec 26, 2025
168eacb
Restructure commands list for CLI Tool
The0mikkel Dec 26, 2025
bbc6ff0
Restructure of CLI tool wording
The0mikkel Dec 26, 2025
4b00c0b
Restructure the Commands section to better align with overall hirecki
The0mikkel Dec 26, 2025
cb3d4e8
Fix typos and improve clarity in README documentation
The0mikkel Dec 26, 2025
f12b1fe
Refactor formatting
The0mikkel Dec 26, 2025
7b0089f
Clarify restrictions on commercial use in README
The0mikkel Dec 26, 2025
d11d7d5
Add more guides to how-to-run
The0mikkel Dec 26, 2025
4b230e6
Correct formatting
The0mikkel Dec 27, 2025
b1530d2
Add CLI bypass guide
The0mikkel Dec 27, 2025
9b33cc6
Add initial architecture diagrams
The0mikkel Dec 27, 2025
84b83c6
Update architecture overview
The0mikkel Dec 27, 2025
cf199fb
Update cluster configuration documentation for improved clarity and r…
The0mikkel Dec 27, 2025
aedee8c
Add networking diagrams
The0mikkel Dec 27, 2025
0306576
Change svg diagrams to png
The0mikkel Dec 27, 2025
ce332c7
Revert to svg images
The0mikkel Dec 27, 2025
1a18380
Update architecture diagrams to correct colors
The0mikkel Dec 27, 2025
d8b66a9
Update cluster network diagram to include Cloudflare proxy
The0mikkel Dec 27, 2025
4211682
Add generate-backend to quickstart guide
The0mikkel Dec 27, 2025
1d6755b
Correct formatting
The0mikkel Dec 27, 2025
8767675
Correct heading position
The0mikkel Dec 27, 2025
1ee0a94
Correct formatting
The0mikkel Dec 27, 2025
baab6ae
Started on cluster architecture overview
The0mikkel Dec 27, 2025
54e6e24
Add ops, platform and challenges architecture overview
The0mikkel Dec 27, 2025
50ec6a6
Update formatting of headers:
The0mikkel Dec 27, 2025
2cb5a1a
Clarify challenge instance scheduling requirements in documentation
The0mikkel Dec 27, 2025
5b145a8
Add overview of challenge deployment system and its components
The0mikkel Dec 27, 2025
6064496
Update challenge deployment architecture section
The0mikkel Dec 27, 2025
3febb1d
Add cluster networking documentation
The0mikkel Dec 27, 2025
14a2a33
Update getting help documentation
The0mikkel Dec 27, 2025
51befe3
Correct formatting
The0mikkel Dec 27, 2025
c5c788e
Update cluster network architecture to show traefik as being scaled
The0mikkel Dec 27, 2025
ad46afa
Add challenge networking documentation
The0mikkel Dec 27, 2025
e573c63
Clarify TCP endpoint handling and custom port limitations in document…
The0mikkel Dec 27, 2025
58c4908
Update grammar
The0mikkel Dec 27, 2025
ac50d96
Fix punctuation in networking section of documentation
The0mikkel Dec 27, 2025
2debb38
Fix grammar and punctuation in README documentation
The0mikkel Dec 27, 2025
afb665c
Fix spelling errors in resource descriptions in tfvars templates
The0mikkel Dec 27, 2025
f50e4d8
Add documentation (#13)
The0mikkel Dec 27, 2025
9ce3853
docs: add links to command list tip
The0mikkel Dec 28, 2025
87d5b3d
docs: add restore guides for database and CTFd-manager
The0mikkel Dec 28, 2025
5ea1c58
fix: correct spelling of 'timeout' in mariadb-operator configuration
The0mikkel Jan 7, 2026
6687532
fix: update default server type from 'cx32' to 'cx33' to match curren…
The0mikkel Jan 7, 2026
43ab200
fix: add 'challs_type' to CLUSTER_TFVARS to correctly set variables
The0mikkel Jan 7, 2026
bb5f350
fix: update team instances panel configuration for correct team ID ha…
The0mikkel Jan 7, 2026
7d828ae
fix(monitoring): update node usage dashboard configuration for improv…
The0mikkel Jan 7, 2026
cba216e
refactor: correct spelling of 'Traefik' in ingress.tf comments
The0mikkel Jan 7, 2026
1d531c2
docs: add link to CTF Pilot organization page in README for ecosystem…
The0mikkel Jan 26, 2026
fc7fca7
fix(grafana): update team instances dashboard file name
The0mikkel Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore transient lock info files created by terraform apply
.terraform.tfstate.lock.info

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

# Include example automated tfvars file
!template.automated.tfvars

# Exclude pycache
__pycache__/
**/__pycache__

**/.env
1,059 changes: 1,057 additions & 2 deletions README.md

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Backend Terraform Configuration Generator

This script generates Terraform backend configuration files for different components of CTFp.

## Usage

To generate a backend configuration file, run the script with the required arguments:

```bash
python generate.py <component> <bucket> <region> <endpoint>
```

It will create a backend configuration file in the `generated` directory.

This can be used when initializing Terraform for the respective component:

```bash
tofu init -backend-config=../backend/generated/<component>.hcl
```

### Arguments

- `<component>`: The component for which to generate the backend configuration. Valid options are `cluster`, `ops`, `platform`, and `challenges`.
- `<bucket>`: The S3 bucket name where the Terraform state will be stored.
- `<region>`: The region of the S3 bucket.
- `<endpoint>`: The endpoint URL for the S3-compatible storage.
23 changes: 23 additions & 0 deletions backend/backend.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# BACKEND CONFIGURATION TEMPLATE FOR TERRAFORM
# This file is a template for the backend configurations located in the `generated` directory.

key = "%%KEY%%"

bucket = "%%S3_BUCKET%%"
region = "%%S3_REGION%%"
endpoints = {
s3 = "%%S3_ENDPOINT%%"
}

workspace_key_prefix = "state/%%COMPONENT%%"

# The following settings are to skip various
# aws related checks and validation
# which is not possible when using third party s3 compatible storage
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true

skip_s3_checksum = false
use_path_style = false
125 changes: 125 additions & 0 deletions backend/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import os
import sys
import argparse

class Args:
args = None
subcommand = False

def __init__(self, parent_parser = None):
if parent_parser:
self.subcommand = True
self.parser = parent_parser.add_parser("generate-backend", help="Generate Terraform backend configuration")
else:
self.parser = argparse.ArgumentParser(description="Backend generator for Terraform")

self.parser.add_argument("component", help="Component to generate backend for", choices=["cluster", "ops", "platform", "challenges"])
self.parser.add_argument("bucket", help="S3 bucket name for Terraform state storage")
self.parser.add_argument("region", help="Region for S3 bucket")
self.parser.add_argument("endpoint", help="Endpoint URL for S3-compatible storage")

def parse(self):
if self.subcommand:
self.args = self.parser.parse_args(sys.argv[2:])
else:
self.args = self.parser.parse_args()

def __getattr__(self, name):
return getattr(self.args, name)

class Template:
component = None
bucket = None
region = None
endpoint = None

def __init__(self, component, bucket, region, endpoint):
self.component = component
self.bucket = bucket
self.region = region
self.endpoint = endpoint
pass

def replace(self, template_str, replacements):
for key, value in replacements.items():
template_str = template_str.replace(f"%%{key}%%", value)
return template_str

def get_template_path(self):
base_dir = os.path.dirname(os.path.abspath(__file__))
template_path = os.path.join(base_dir, "backend.hcl")
return template_path

def get_target_path(self):
base_dir = os.path.dirname(os.path.abspath(__file__))
target_dir = os.path.join(base_dir, "generated")
if not os.path.exists(target_dir):
os.makedirs(target_dir)
target_path = os.path.join(target_dir, f"{self.component}.hcl")
return target_path

def get_template(self):
template_path = self.get_template_path()
with open(template_path, "r") as f:
template_str = f.read()
return template_str

def template(self) -> str:
template = self.get_template()
replacements = {
"COMPONENT": self.component,
"KEY": f"{self.component}.tfstate",
"S3_BUCKET": self.bucket,
"S3_REGION": self.region,
"S3_ENDPOINT": self.endpoint
}
output = self.replace(template, replacements)
return output

def run(self):
backend = self.template()
target_path = self.get_target_path()
with open(target_path, "w") as f:
f.write(backend)
print(f"Generated backend file at: {target_path}")


class Generator:
args = None

def __init__(self, subparser = None):
if not subparser:
self.subparser = argparse.ArgumentParser(description="Backend generator for Terraform")
self.subparser.set_defaults(func=self.run)
return

self.subparser = subparser.add_parser("generate-backend", help="Generate Terraform backend configuration", description="Generate Terraform backend configuration for specified component")
self.subparser.set_defaults(func=self.run)

def register_subcommand(self):
self.subparser.add_argument("component", help="Component to generate backend for", choices=["cluster", "ops", "platform", "challenges"])
self.subparser.add_argument("bucket", help="S3 bucket name for Terraform state storage")
self.subparser.add_argument("region", help="Region for S3 bucket")
self.subparser.add_argument("endpoint", help="Endpoint URL for S3-compatible storage")

def run(self, args):
template = Template(
component=args.component,
bucket=args.bucket,
region=args.region,
endpoint=args.endpoint
)
template.run()

if __name__ == "__main__":
args = Args()
if args.parser is None:
print("Failed to initialize argument parser")
exit(1)

generator = Generator()
generator.register_subcommand()

namespace = args.parser.parse_args()

generator.run(namespace)
2 changes: 2 additions & 0 deletions backend/generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions challenges/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AWS_ACCESS_KEY_ID=<access_key_id>
AWS_SECRET_ACCESS_KEY=<secret_access_key>
37 changes: 37 additions & 0 deletions challenges/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore transient lock info files created by terraform apply
.terraform.tfstate.lock.info

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
79 changes: 79 additions & 0 deletions challenges/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading