Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated kCTF from Google Container Registry to Artifact Registry #406

Open
wants to merge 5 commits into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion dist/bin/kctf-challenge
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function push_image {

case "${CLUSTER_TYPE}" in
gce)
IMAGE_URL="${REGISTRY}/${PROJECT}/${CHALLENGE_NAME}-${IMAGE_NAME}:${IMAGE_ID}"
IMAGE_URL="${REGISTRY}/${PROJECT}/${CLUSTER_NAME}-${CHALLENGE_NAME}/${IMAGE_NAME}:${IMAGE_ID}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference between slashes here? Maybe just add slashes too, for consistency.

Copy link
Author

@HlynurOskar HlynurOskar Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a significance to the slashes, it's a path that gets parsed.
Although, some want the path to be more like:
IMAGE_URL="${REGISTRY}/${PROJECT}/challenges/${CLUSTER_NAME}-${CHALLENGE_NAME}-${IMAGE_NAME}:${IMAGE_ID}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we have a dash in the cluster? Wouldn't that cause a collision?

Copy link

@pl4nty pl4nty Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the registry should be shared by all challenges, so we can create it in kctf cluster create rather than managing several in kctf challenge. I used IMAGE_URL="${REGISTRY}/${PROJECT}/${CLUSTER_NAME}/${CHALLENGE_NAME}-${IMAGE_NAME}:${IMAGE_ID}"

should registry creation be part of this PR? Container Registry is shutting down very soon

docker tag "${IMAGE_ID}" "${IMAGE_URL}" || return
docker push "${IMAGE_URL}" || return
;;
Expand Down
5 changes: 2 additions & 3 deletions dist/bin/kctf-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ function kctf_cluster_create_usage {
echo " --zone GCP Zone (default: europe-west4-b)" >&2
echo " For a list of zones run:" >&2
echo " gcloud compute machine-types list --filter=\"name=( n2-standard-4 )\" --format 'value(zone)'" >&2
echo " --registry Container Registry (default: eu.gcr.io)" >&2
echo " Possible values are us.gcr.io, asia.gcr.io, and eu.gcr.io" >&2
echo " --registry Container Registry (default: europe-west4-docker.pkg.dev)" >&2
echo " --cluster-name Name of the kubernetes cluster (default: kctf-cluster)" >&2
echo " --domain-name Required (gce): domain name to host challenges under" >&2
echo " Please make sure not to put anything secret in the challenge name." >&2
Expand All @@ -143,7 +142,7 @@ function kctf_cluster_create_usage {
function kctf_cluster_create {
# Default Configuration
CLUSTER_TYPE="gce"
REGISTRY="eu.gcr.io"
REGISTRY="europe-west4-docker.pkg.dev"
PROJECT=""
ZONE="europe-west4-b"
CLUSTER_NAME="kctf-cluster"
Expand Down
2 changes: 1 addition & 1 deletion dist/bin/kctf-completion
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function _kctf_complete_chal() {
# This will be out of date at some point, but still useful so worth it?
# We can't fetch it easily with gcloud unfortunately since it requires a project
GCP_REGIONS="us-east1-b us-east1-c us-east1-d us-east4-c us-east4-b us-east4-a us-central1-c us-central1-a us-central1-f us-central1-b us-west1-b us-west1-c us-west1-a europe-west4-a europe-west4-b europe-west4-c europe-west1-b europe-west1-d europe-west1-c europe-west3-c europe-west3-a europe-west3-b europe-west2-c europe-west2-b europe-west2-a asia-east1-b asia-east1-a asia-east1-c asia-southeast1-b asia-southeast1-a asia-southeast1-c asia-northeast1-b asia-northeast1-c asia-northeast1-a asia-south1-c asia-south1-b asia-south1-a australia-southeast1-b australia-southeast1-c australia-southeast1-a southamerica-east1-b southamerica-east1-c southamerica-east1-a asia-east2-a asia-east2-b asia-east2-c asia-northeast2-a asia-northeast2-b asia-northeast2-c asia-northeast3-a asia-northeast3-b asia-northeast3-c asia-southeast2-a asia-southeast2-b asia-southeast2-c europe-north1-a europe-north1-b europe-north1-c europe-west6-a europe-west6-b europe-west6-c northamerica-northeast1-a northamerica-northeast1-b northamerica-northeast1-c us-west2-a us-west2-b us-west2-c us-west3-a us-west3-b us-west3-c us-west4-a us-west4-b us-west4-c"
GCP_REGISTRIES="gcr.io asia.gcr.io eu.gcr.io us.gcr.io"
GCP_REGISTRIES="pkg.dev docker.pkg.dev"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should include the zones I think


function _kctf_complete_cluster() {
if [ "$COMP_CWORD" == "2" ]; then
Expand Down