@@ -4,10 +4,14 @@ CLUSTER_NAME = "ns-dev"
44[tasks ."k3d:up" ]
55description = " Spin up k3d cluster with envsubst"
66run = """
7- TMP_FILE=$(mktemp)
8- envsubst < k3d.yaml > "$TMP_FILE"
9- k3d cluster create "$CLUSTER_NAME" -c "$TMP_FILE"
10- rm "$TMP_FILE"
7+ if k3d cluster list "$CLUSTER_NAME" > /dev/null 2>&1; then
8+ echo "Cluster $CLUSTER_NAME already exists, skipping creation."
9+ else
10+ TMP_FILE=$(mktemp)
11+ envsubst < k3d.yaml > "$TMP_FILE"
12+ k3d cluster create "$CLUSTER_NAME" -c "$TMP_FILE"
13+ rm "$TMP_FILE"
14+ fi
1115"""
1216env = { PROJECT_ROOT = " {{ config_root | dirname }}" }
1317
@@ -17,22 +21,19 @@ run = "k3d cluster delete $CLUSTER_NAME"
1721
1822[tasks ."ensure:context" ]
1923description = " Switch kubectl context to k3d"
20- depends = [" k3d:up" ]
2124run = " kubectl config use-context k3d-$CLUSTER_NAME"
2225
2326[tasks .import ]
2427description = " Build and import images into k3d"
25- depends = [" build" , " k3d:up " ]
28+ depends = [" build" ]
2629run = """
2730#!/usr/bin/env bash
2831images=(
2932 ns-dashboard ns-sablier ns-auth-dev ns-builder
3033 ns-controller ns-gateway ns-gitea-integration
3134 ns-migrate ns-ssgen
3235)
33- for img in "${images[@]}"; do
34- k3d image import --cluster "$CLUSTER_NAME" "ghcr.io/traptitech/$img:main"
35- done
36+ k3d image import --cluster "$CLUSTER_NAME" $(printf "ghcr.io/traptitech/%s:main " "${images[@]}")
3637"""
3738
3839[tasks .apply ]
@@ -51,9 +52,9 @@ kubectl rollout restart deployment/coredns -n kube-system
5152# ---- All-in-one commands ----
5253
5354[tasks .up ]
54- description = " Full setup: k3d-up -> import -> apply -> events "
55- depends = [" import" , " apply" ]
55+ description = " Full setup: k3d-up -> import -> apply"
56+ run = [{ task = " k3d:up " }, { task = " import" }, { task = " apply" } ]
5657
5758[tasks .down ]
5859description = " Full teardown"
59- run = " mise run k3d:down"
60+ run = { task = " k3d:down" }
0 commit comments