diff --git a/.vscode/launch.json b/.vscode/launch.json index 6ae3651e..467fe979 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,9 +25,10 @@ "--secure-port=9443", "--v=7", "--standalone-debug-mode", - "--kubeconfig=${workspaceFolder}/deployments/local/kubeconfig", + "--kubeconfig=${env:KUBECONFIG}", "--cache-directory=${workspaceFolder}/.cache", - "--function-runner=192.168.8.202:9445" + "--function-runner=localhost:30001", + "--repo-sync-frequency=60s" ], "cwd": "${workspaceFolder}" }, diff --git a/docs/tutorials/porch-development-environment/bin/kind_porch_test_cluster.yaml b/docs/tutorials/porch-development-environment/bin/kind_porch_test_cluster.yaml new file mode 100644 index 00000000..ed96f6ee --- /dev/null +++ b/docs/tutorials/porch-development-environment/bin/kind_porch_test_cluster.yaml @@ -0,0 +1,15 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +name: management +networking: + apiServerAddress: 127.0.0.1 + apiServerPort: 31000 + podSubnet: 10.97.0.0/16 + serviceSubnet: 10.197.0.0/16 +nodes: +- role: control-plane + extraPortMappings: + - containerPort: 30000 # Gitea NodePort + hostPort: 3000 + - containerPort: 30001 # function-runner NodePort + hostPort: 30001 diff --git a/docs/tutorials/porch-development-environment/bin/setup.sh b/docs/tutorials/porch-development-environment/bin/setup.sh index a018aaa8..195a90f3 100755 --- a/docs/tutorials/porch-development-environment/bin/setup.sh +++ b/docs/tutorials/porch-development-environment/bin/setup.sh @@ -14,10 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -porch_cluster_name=porch-test +porch_cluster_name=${PORCH_TEST_CLUSTER:-porch-test} git_repo_name="$porch_cluster_name" -gitea_ip=172.18.255.200 # should be from the address range specified here: https://github.com/nephio-project/porch/blob/main/docs/tutorials/starting-with-porch/metallb-conf.yaml +gitea_ip=172.18.255.200 # should be from the address range specified here: docs/tutorials/starting-with-porch/metallb-conf.yaml self_dir="$(dirname "$(readlink -f "$0")")" +git_root="$(readlink -f "${self_dir}/../../../..")" +cd "${git_root}" function h1() { echo @@ -40,8 +42,9 @@ fi ############################################## h1 "Install kind cluster: $porch_cluster_name" if ! kind get clusters | grep -q "^$porch_cluster_name\$" ; then - curl -s https://raw.githubusercontent.com/nephio-project/porch/main/docs/tutorials/starting-with-porch/kind_management_cluster.yaml | \ - kind create cluster --config=- --name "$porch_cluster_name" || true + kind create cluster \ + --config="${git_root}/docs/tutorials/porch-development-environment/bin/kind_porch_test_cluster.yaml" \ + --name "$porch_cluster_name" || true mkdir -p ~/.kube kind get kubeconfig --name="$porch_cluster_name" > ~/.kube/"kind-$porch_cluster_name" @@ -58,49 +61,56 @@ echo "Waiting for controller to become ready..." kubectl wait --namespace metallb-system deploy controller \ --for=condition=available \ --timeout=90s -kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/docs/tutorials/starting-with-porch/metallb-conf.yaml - -############################################ -h1 Prepare tmp dir -TMP_DIR=$(mktemp -d) -echo "$TMP_DIR" +kubectl apply -f "${git_root}/docs/tutorials/starting-with-porch/metallb-conf.yaml" ############################################ h1 Install Gitea -mkdir "$TMP_DIR/kpt_packages" -cd "$TMP_DIR/kpt_packages" -kpt pkg get https://github.com/nephio-project/catalog/tree/main/distros/sandbox/gitea +mkdir -p "${git_root}/.build" +cd "${git_root}/.build" +if [ -d gitea ]; then + kpt pkg update gitea +else + kpt pkg get https://github.com/nephio-project/catalog/tree/main/distros/sandbox/gitea +fi + kpt fn eval gitea \ --image gcr.io/kpt-fn/set-annotations:v0.1.4 \ --match-kind Service \ --match-name gitea \ --match-namespace gitea \ -- "metallb.universe.tf/loadBalancerIPs=${gitea_ip}" -curl -o gitea/cluster-config.yaml https://raw.githubusercontent.com/nephio-project/porch/main/docs/tutorials/starting-with-porch/kind_management_cluster.yaml -echo "metadata: { name: "porch-test" }" >> gitea/cluster-config.yaml -kpt fn eval gitea \ - --image gcr.io/kpt-fn/set-annotations:v0.1.4 \ - --match-kind Cluster \ - --match-api-version kind.x-k8s.io/v1alpha4 \ - -- "config.kubernetes.io/local-config=true" + +cp -f "${git_root}/docs/tutorials/porch-development-environment/bin/kind_porch_test_cluster.yaml" gitea/cluster-config.yaml +# turn kind's cluster-config into a valid KRM +cat >> gitea/cluster-config.yaml </dev/null; then + echo "Add main branch to git repo:" git switch -c main touch README.md git add README.md @@ -110,15 +120,14 @@ if ! git rev-parse -q --verify refs/remotes/origin/main >/dev/null; then else echo "main branch already exists in git repo." fi +cd "${git_root}" +rm -fr "$TMP_DIR" ############################################ h1 Generate certs and keys -cd "${self_dir}/../../../../" +cd "${git_root}" deployments/local/makekeys.sh ############################################ -h1 "Clean up" -cd "$self_dir" -rm -fr "$TMP_DIR" echo echo Done. diff --git a/porch.code-workspace b/porch.code-workspace index f90fdd25..d50229ad 100644 --- a/porch.code-workspace +++ b/porch.code-workspace @@ -11,17 +11,9 @@ "name": "porch", "path": "." }, - { - "name": "kpt", - "path": ".." - }, { "name": "controllers", "path": "controllers" - }, - { - "name": "rollouts", - "path": "../rollouts" } ] }