From 211fc935fb7c43ee1f843f458c1c298d7613651b Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 26 Jul 2024 15:56:52 +0100 Subject: [PATCH 1/5] Add Makefile and vscode launcher for in-sandbox debugging --- .vscode/launch.json | 21 +++++++++++++++++-- Makefile | 50 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 2be72fd5..bc619bcd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,6 @@ "program": "${workspaceFolder}/cmd/porch/main.go", "args": [ "--secure-port=4443", - // "--v=7", - // "--standalone-debug-mode", "--kubeconfig=${env:KUBECONFIG}", "--cache-directory=${workspaceFolder}/.cache", "--function-runner=172.18.255.201:9445", @@ -25,6 +23,25 @@ "WEBHOOK_HOST": "localhost" } }, + { + "name": "Launch Override Server", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}/cmd/porch/main.go", + "args": [ + "--secure-port=4443", + "--kubeconfig=${userHome}/.kube/config", + "--cache-directory=${workspaceFolder}/.cache", + "--function-runner=172.18.0.202:9445", + "--repo-sync-frequency=60s" + ], + "cwd": "${workspaceFolder}", + "env": { + "CERT_STORAGE_DIR": "${workspaceFolder}/.build/pki/tmp", + "WEBHOOK_HOST": "localhost" + } + }, { "name": "Launch Controllers", "type": "go", diff --git a/Makefile b/Makefile index dc3e4e76..4456d851 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ MYGOBIN := $(shell go env GOPATH)/bin BUILDDIR=$(CURDIR)/.build CACHEDIR=$(CURDIR)/.cache +export DEFAULTPORCHCONFIGDIR ?= /tmp/kpt-pkg/nephio/core/porch export DEPLOYPORCHCONFIGDIR ?= $(BUILDDIR)/deploy DEPLOYKPTCONFIGDIR=$(BUILDDIR)/kpt_pkgs PORCHDIR=$(abspath $(CURDIR)) @@ -28,9 +29,9 @@ include default-go.mk # This includes the 'help' target that prints out all targets with their descriptions organized by categories include default-help.mk -KIND_CONTEXT_NAME ?= porch-test +KIND_CONTEXT_NAME ?= kind export IMAGE_REPO ?= docker.io/nephio -export USER ?= nephio +export USER ?= ubuntu export IMAGE_TAG ifndef IMAGE_TAG @@ -239,6 +240,26 @@ deploy: deployment-config .PHONY: push-and-deploy push-and-deploy: push-images deploy +.PHONY: run-default +run-default: undeploy-config deploy-default-config ## Run the default deployment in $(DEFAULTPORCHCONFIGDIR) in kind + +.PHONY: run-override-in-kind +run-override-in-kind: IMAGE_REPO=porch-kind +run-override-in-kind: IMAGE_TAG=test +run-override-in-kind: undeploy-config load-images-to-kind deployment-config deploy-override-config ## Run the override deployment in $(DEPLOYPORCHCONFIGDIR) in kind + +.PHONY: run-override-in-kind-no-server +run-override-in-kind-no-server: IMAGE_REPO=porch-kind +run-override-in-kind-no-server: IMAGE_TAG=test +run-override-in-kind-no-server: SKIP_PORCHSERVER_BUILD=true +run-override-in-kind-no-server: undeploy-config load-images-to-kind deployment-config-no-server deploy-override-config ## Run the override deployment in $(DEPLOYPORCHCONFIGDIR) in kind without the porch server + +.PHONY: run-override-in-kind-no-controller +run-override-in-kind-no-controller: IMAGE_REPO=porch-kind +run-override-in-kind-no-controller: IMAGE_TAG=test +run-override-in-kind-no-controller: SKIP_CONTROLLER_BUILD=true +run-override-in-kind-no-controller: undeploy-config load-images-to-kind deployment-config-no-controller deploy-override-config ## Run the override deployment in $(DEPLOYPORCHCONFIGDIR) in kind without the porch controller + .PHONY: run-in-kind run-in-kind: IMAGE_REPO=porch-kind run-in-kind: IMAGE_TAG=test @@ -329,6 +350,31 @@ deploy-current-config: ## Deploy the configuration that is currently in $(DEPLOY @kubectl rollout status deployment porch-server --namespace porch-system 2>/dev/null || true @echo "Done." +.PHONY: deploy-default-config +deploy-default-config: ## Deploy or redeploy the default Porch deployments in $(DEFAULTPORCHCONFIGDIR) + kubectl apply -f $(DEFAULTPORCHCONFIGDIR)/2-function-runner.yaml + kubectl apply -f $(DEFAULTPORCHCONFIGDIR)/3-porch-server.yaml + kubectl apply -f $(DEFAULTPORCHCONFIGDIR)/9-controllers.yaml + +.PHONY: deploy-override-config +deploy-override-config: ## Deploy the override Porch deployments in $(DEPLOYPORCHCONFIGDIR) + kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/9-controllers.yaml + kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server.yaml + kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server-endpoints.yaml || true + kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/2-function-runner.yaml + kubectl expose svc -n porch-system function-runner --name=xfunction-runner --type=LoadBalancer --load-balancer-ip='172.18.0.202' + +.PHONY: undeploy-config +undeploy-config: ## Undeploy the default Porch deployments in $(DEFAULTPORCHCONFIGDIR) and $(DEPLOYPORCHCONFIGDIR) + kubectl delete -f $(DEFAULTPORCHCONFIGDIR)/9-controllers.yaml || true + kubectl delete -f $(DEFAULTPORCHCONFIGDIR)/3-porch-server.yaml || true + kubectl delete -f $(DEFAULTPORCHCONFIGDIR)/2-function-runner.yaml || true + kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/9-controllers.yaml || true + kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server-endpoints.yaml || true + kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server.yaml || true + kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/2-function-runner.yaml || true + kubectl delete svc -n porch-system xfunction-runner || true + PKG=gitea-dev .PHONY: deploy-gitea-dev-pkg deploy-gitea-dev-pkg: From 857490088938dc5e61712ffe67ea32c667baa942 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 26 Jul 2024 16:01:30 +0100 Subject: [PATCH 2/5] Revert changes to context name and user --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4456d851..97c6c4f3 100644 --- a/Makefile +++ b/Makefile @@ -29,9 +29,9 @@ include default-go.mk # This includes the 'help' target that prints out all targets with their descriptions organized by categories include default-help.mk -KIND_CONTEXT_NAME ?= kind +KIND_CONTEXT_NAME ?= porch-test export IMAGE_REPO ?= docker.io/nephio -export USER ?= ubuntu +export USER ?= nephio export IMAGE_TAG ifndef IMAGE_TAG From 16ebb1da498f1badd11c6c8310f948fe41e44d67 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 26 Jul 2024 17:22:54 +0100 Subject: [PATCH 3/5] Reformat Makefile --- Makefile | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 97c6c4f3..fe4cd42a 100644 --- a/Makefile +++ b/Makefile @@ -240,6 +240,23 @@ deploy: deployment-config .PHONY: push-and-deploy push-and-deploy: push-images deploy +.PHONY: run-in-kind +run-in-kind: IMAGE_REPO=porch-kind +run-in-kind: IMAGE_TAG=test +run-in-kind: load-images-to-kind deployment-config deploy-current-config ## Build and deploy porch into a kind cluster + +.PHONY: run-in-kind-no-server +run-in-kind-no-server: IMAGE_REPO=porch-kind +run-in-kind-no-server: IMAGE_TAG=test +run-in-kind-no-server: SKIP_PORCHSERVER_BUILD=true +run-in-kind-no-server: load-images-to-kind deployment-config-no-server deploy-current-config ## Build and deploy porch without the porch-server into a kind cluster + +.PHONY: run-in-kind-no-controller +run-in-kind-no-controller: IMAGE_REPO=porch-kind +run-in-kind-no-controller: IMAGE_TAG=test +run-in-kind-no-controller: SKIP_CONTROLLER_BUILD=true +run-in-kind-no-controller: load-images-to-kind deployment-config-no-controller deploy-current-config ## Build and deploy porch without the controllers into a kind cluster + .PHONY: run-default run-default: undeploy-config deploy-default-config ## Run the default deployment in $(DEFAULTPORCHCONFIGDIR) in kind @@ -260,23 +277,6 @@ run-override-in-kind-no-controller: IMAGE_TAG=test run-override-in-kind-no-controller: SKIP_CONTROLLER_BUILD=true run-override-in-kind-no-controller: undeploy-config load-images-to-kind deployment-config-no-controller deploy-override-config ## Run the override deployment in $(DEPLOYPORCHCONFIGDIR) in kind without the porch controller -.PHONY: run-in-kind -run-in-kind: IMAGE_REPO=porch-kind -run-in-kind: IMAGE_TAG=test -run-in-kind: load-images-to-kind deployment-config deploy-current-config ## Build and deploy porch into a kind cluster - -.PHONY: run-in-kind-no-server -run-in-kind-no-server: IMAGE_REPO=porch-kind -run-in-kind-no-server: IMAGE_TAG=test -run-in-kind-no-server: SKIP_PORCHSERVER_BUILD=true -run-in-kind-no-server: load-images-to-kind deployment-config-no-server deploy-current-config ## Build and deploy porch without the porch-server into a kind cluster - -.PHONY: run-in-kind-no-controller -run-in-kind-no-controller: IMAGE_REPO=porch-kind -run-in-kind-no-controller: IMAGE_TAG=test -run-in-kind-no-controller: SKIP_CONTROLLER_BUILD=true -run-in-kind-no-controller: load-images-to-kind deployment-config-no-controller deploy-current-config ## Build and deploy porch without the controllers into a kind cluster - .PHONY: destroy destroy: ## Deletes all porch resources installed by the last run-in-kind-* command kpt live destroy $(DEPLOYPORCHCONFIGDIR) From 8ebcd6057cf41ed59bae4cf0857710d0d01d8e04 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 2 Aug 2024 14:44:20 +0100 Subject: [PATCH 4/5] Use same resource group and default build --- .vscode/launch.json | 23 ++------------------- Makefile | 50 ++------------------------------------------- 2 files changed, 4 insertions(+), 69 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index bc619bcd..af69815a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,32 +14,13 @@ "--secure-port=4443", "--kubeconfig=${env:KUBECONFIG}", "--cache-directory=${workspaceFolder}/.cache", - "--function-runner=172.18.255.201:9445", + "--function-runner=${env:FUNCTION_RUNNER_IP}:9445", "--repo-sync-frequency=60s" ], "cwd": "${workspaceFolder}", "env": { "CERT_STORAGE_DIR": "${workspaceFolder}/.build/pki/tmp", - "WEBHOOK_HOST": "localhost" - } - }, - { - "name": "Launch Override Server", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${workspaceFolder}/cmd/porch/main.go", - "args": [ - "--secure-port=4443", - "--kubeconfig=${userHome}/.kube/config", - "--cache-directory=${workspaceFolder}/.cache", - "--function-runner=172.18.0.202:9445", - "--repo-sync-frequency=60s" - ], - "cwd": "${workspaceFolder}", - "env": { - "CERT_STORAGE_DIR": "${workspaceFolder}/.build/pki/tmp", - "WEBHOOK_HOST": "localhost" + "WEBHOOK_HOST": "localhost" } }, { diff --git a/Makefile b/Makefile index fe4cd42a..26aea2a7 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,6 @@ MYGOBIN := $(shell go env GOPATH)/bin BUILDDIR=$(CURDIR)/.build CACHEDIR=$(CURDIR)/.cache -export DEFAULTPORCHCONFIGDIR ?= /tmp/kpt-pkg/nephio/core/porch export DEPLOYPORCHCONFIGDIR ?= $(BUILDDIR)/deploy DEPLOYKPTCONFIGDIR=$(BUILDDIR)/kpt_pkgs PORCHDIR=$(abspath $(CURDIR)) @@ -29,7 +28,7 @@ include default-go.mk # This includes the 'help' target that prints out all targets with their descriptions organized by categories include default-help.mk -KIND_CONTEXT_NAME ?= porch-test +KIND_CONTEXT_NAME ?= kind export IMAGE_REPO ?= docker.io/nephio export USER ?= nephio @@ -257,26 +256,6 @@ run-in-kind-no-controller: IMAGE_TAG=test run-in-kind-no-controller: SKIP_CONTROLLER_BUILD=true run-in-kind-no-controller: load-images-to-kind deployment-config-no-controller deploy-current-config ## Build and deploy porch without the controllers into a kind cluster -.PHONY: run-default -run-default: undeploy-config deploy-default-config ## Run the default deployment in $(DEFAULTPORCHCONFIGDIR) in kind - -.PHONY: run-override-in-kind -run-override-in-kind: IMAGE_REPO=porch-kind -run-override-in-kind: IMAGE_TAG=test -run-override-in-kind: undeploy-config load-images-to-kind deployment-config deploy-override-config ## Run the override deployment in $(DEPLOYPORCHCONFIGDIR) in kind - -.PHONY: run-override-in-kind-no-server -run-override-in-kind-no-server: IMAGE_REPO=porch-kind -run-override-in-kind-no-server: IMAGE_TAG=test -run-override-in-kind-no-server: SKIP_PORCHSERVER_BUILD=true -run-override-in-kind-no-server: undeploy-config load-images-to-kind deployment-config-no-server deploy-override-config ## Run the override deployment in $(DEPLOYPORCHCONFIGDIR) in kind without the porch server - -.PHONY: run-override-in-kind-no-controller -run-override-in-kind-no-controller: IMAGE_REPO=porch-kind -run-override-in-kind-no-controller: IMAGE_TAG=test -run-override-in-kind-no-controller: SKIP_CONTROLLER_BUILD=true -run-override-in-kind-no-controller: undeploy-config load-images-to-kind deployment-config-no-controller deploy-override-config ## Run the override deployment in $(DEPLOYPORCHCONFIGDIR) in kind without the porch controller - .PHONY: destroy destroy: ## Deletes all porch resources installed by the last run-in-kind-* command kpt live destroy $(DEPLOYPORCHCONFIGDIR) @@ -343,38 +322,13 @@ load-images-to-kind: ## Build porch images and load them into a kind cluster .PHONY: deploy-current-config deploy-current-config: ## Deploy the configuration that is currently in $(DEPLOYPORCHCONFIGDIR) kpt fn render $(DEPLOYPORCHCONFIGDIR) - kpt live init $(DEPLOYPORCHCONFIGDIR) --name porch --namespace porch-system --inventory-id porch-test || true + kpt live init $(DEPLOYPORCHCONFIGDIR) --name porch --namespace porch-system --inventory-id nephio || true kpt live apply --inventory-policy=adopt --server-side --force-conflicts $(DEPLOYPORCHCONFIGDIR) @kubectl rollout status deployment function-runner --namespace porch-system 2>/dev/null || true @kubectl rollout status deployment porch-controllers --namespace porch-system 2>/dev/null || true @kubectl rollout status deployment porch-server --namespace porch-system 2>/dev/null || true @echo "Done." -.PHONY: deploy-default-config -deploy-default-config: ## Deploy or redeploy the default Porch deployments in $(DEFAULTPORCHCONFIGDIR) - kubectl apply -f $(DEFAULTPORCHCONFIGDIR)/2-function-runner.yaml - kubectl apply -f $(DEFAULTPORCHCONFIGDIR)/3-porch-server.yaml - kubectl apply -f $(DEFAULTPORCHCONFIGDIR)/9-controllers.yaml - -.PHONY: deploy-override-config -deploy-override-config: ## Deploy the override Porch deployments in $(DEPLOYPORCHCONFIGDIR) - kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/9-controllers.yaml - kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server.yaml - kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server-endpoints.yaml || true - kubectl apply -f $(DEPLOYPORCHCONFIGDIR)/2-function-runner.yaml - kubectl expose svc -n porch-system function-runner --name=xfunction-runner --type=LoadBalancer --load-balancer-ip='172.18.0.202' - -.PHONY: undeploy-config -undeploy-config: ## Undeploy the default Porch deployments in $(DEFAULTPORCHCONFIGDIR) and $(DEPLOYPORCHCONFIGDIR) - kubectl delete -f $(DEFAULTPORCHCONFIGDIR)/9-controllers.yaml || true - kubectl delete -f $(DEFAULTPORCHCONFIGDIR)/3-porch-server.yaml || true - kubectl delete -f $(DEFAULTPORCHCONFIGDIR)/2-function-runner.yaml || true - kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/9-controllers.yaml || true - kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server-endpoints.yaml || true - kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/3-porch-server.yaml || true - kubectl delete -f $(DEPLOYPORCHCONFIGDIR)/2-function-runner.yaml || true - kubectl delete svc -n porch-system xfunction-runner || true - PKG=gitea-dev .PHONY: deploy-gitea-dev-pkg deploy-gitea-dev-pkg: From 1307457fd651344f762223e7853c0354a023b081 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 2 Aug 2024 14:47:56 +0100 Subject: [PATCH 5/5] Revert KIND_CONTEXT_NAME value --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 26aea2a7..eb0d0fa3 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ include default-go.mk # This includes the 'help' target that prints out all targets with their descriptions organized by categories include default-help.mk -KIND_CONTEXT_NAME ?= kind +KIND_CONTEXT_NAME ?= porch-test export IMAGE_REPO ?= docker.io/nephio export USER ?= nephio