- Sign into GCP:
gcloud auth login
- Create a GCP project:
export PROJECT="ctf-$RANDOM"
gcloud projects create $PROJECT
gcloud config set project $PROJECT
NOTE: After you finish the CTF, you can delete the project, removing all resources associated with the project.
- Make sure that billing is enabled for your Cloud project.
- Learn how to check if billing is enabled on a project.
- Run this command to get a URL in your terminal to enable billing with:
echo "https://console.cloud.google.com/billing/linkedaccount\?project\=$PROJECT"
- Enable the GKE service API
gcloud services enable container.googleapis.com
NOTE: If you have an error regarding billing, please review the previous step
- Create a GKE cluster:
export NAME="$(whoami)-$RANDOM"
gcloud container clusters create "${NAME}" \
--labels "usage=dev,owner=$(whoami)" \
--zone us-west2-a \
--num-nodes 1
- Setup
/etc/hosts
file:
NOTE: Updating the /etc/hosts
file allows you to use a URL on your machines browser to view GitLab and access the bucket.
sudo -- sh -c -e "echo '127.0.0.1 gitlab.foobar.com' >> /etc/hosts";
sudo -- sh -c -e "echo '127.0.0.1 bucket.foobar.com' >> /etc/hosts";
- Unzip the GitLab data:
unzip gitlab.zip
- Run Docker Compose to create the local environment:
docker-compose up -d
NOTE: When running this for the first time, it can take 10 minutes to get GitLab up and running
- Wait for it to return healthy:
docker ps
You currently have cluster-admin access to your cluster. This means we can setup the cluster for the CTF.
- Setup cluster applications:
./setup.sh
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e4a54c804338 gitlab/gitlab-ce:latest "/assets/wrapper" 12 minutes ago Up 12 minutes (healthy) 0.0.0.0:80->80/tcp, 22/tcp, 0.0.0.0:443->443/tcp foobar-git
722027c82471 localstack/localstack "docker-entrypoint.sh" 12 minutes ago Up 12 minutes (healthy) 127.0.0.1:4510-4559->4510-4559/tcp, 127.0.0.1:4566->4566/tcp, 5678/tcp foobar-saas
Use the following checks to give you confidence that everything is setup correctly to deliver your CTF!
[ ] Check <gitlab.foobar.com> and <bucket.foobar.com> are added to /etc/hosts
- Open the
/etc/hosts
file with your preferred editor:
sudo nano /etc/hosts
- Amend
/etc/hosts/
accordingly:
127.0.0.1 gitlab.foobar.com
127.0.0.1 bucket.foobar.com
- Check config has been set
- Reset
boombox
kubectl delete pods -A --selector app=musicbox
When you've finished the CTF you can delete your cluster.
- Delete the GCP Project:
gcloud project delete $PROJECT
NOTE: If all else fails, delete the project from the Google Cloud Console UI