From 312a3b74151f933e7b4a6adac39c9ce6373b8c99 Mon Sep 17 00:00:00 2001 From: Aiden Date: Thu, 10 Jul 2025 00:19:37 +0800 Subject: [PATCH 1/5] fix(deployment): module controller quick starter Updated base and module-controller configurations to use Deployment instead of Pod, enhancing scalability and management. Adjusted container images and environment variables for consistency. BREAKING CHANGE: Deployment structure modified, ensure compatibility with existing configurations. --- example/quick-start/base.yaml | 37 ++++++++++-------- example/quick-start/module-controller.yaml | 45 +++++++++++++--------- example/quick-start/module.yaml | 31 +++++++++------ 3 files changed, 68 insertions(+), 45 deletions(-) diff --git a/example/quick-start/base.yaml b/example/quick-start/base.yaml index c6d53b8..828af87 100644 --- a/example/quick-start/base.yaml +++ b/example/quick-start/base.yaml @@ -1,19 +1,26 @@ -apiVersion: v1 -kind: Pod +apiVersion: apps/v1 +kind: Deployment metadata: name: base - labels: - app: base spec: - containers: - - name: base - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/base-web:1.3.3 # 已经打包好的镜像,源码在 https://github.com/koupleless/samples/blob/main/springboot-samples/web/tomcat/Dockerfile - imagePullPolicy: Always - ports: + replicas: 1 + selector: + matchLabels: + app: base + template: + metadata: + labels: + app: base + spec: + containers: - name: base - containerPort: 8080 - - name: arklet - containerPort: 1238 - env: - - name: MODULE_CONTROLLER_ADDRESS - value: { YOUR_MODULE_CONTROLLER_IP } \ No newline at end of file + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/base-web:1.4.0 # 已经打包好的镜像, 镜像来源 https://github.com/koupleless/samples/blob/main/springboot-samples/web/tomcat/Dockerfile + imagePullPolicy: Always + ports: + - name: base + containerPort: 8080 + - name: arklet + containerPort: 1238 + env: + - name: MODULE_CONTROLLER_ADDRESS # 在 base-web 的 koupleless runtime 里是 `koupleless.arklet.http.heartbeat.endpoint` + value: {YOUR_MODULE_CONTROLLER_IP_AND_PORT} # 127.0.0.1:7777 \ No newline at end of file diff --git a/example/quick-start/module-controller.yaml b/example/quick-start/module-controller.yaml index cb187ed..e2762dd 100644 --- a/example/quick-start/module-controller.yaml +++ b/example/quick-start/module-controller.yaml @@ -1,22 +1,29 @@ -apiVersion: v1 -kind: Pod +apiVersion: apps/v1 +kind: Deployment metadata: name: module-controller - labels: - app: module-controller spec: - serviceAccountName: virtual-kubelet # 上一步中配置好的 Service Account - containers: - - name: module-controller - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/release/module-controller-v2:v2.1.2 # 已经打包好的镜像 - imagePullPolicy: Always - resources: - limits: - cpu: "1000m" - memory: "400Mi" - ports: - - name: httptunnel - containerPort: 7777 - env: - - name: ENABLE_HTTP_TUNNEL - value: "true" \ No newline at end of file + replicas: 1 + selector: + matchLabels: + app: module-controller + template: + metadata: + labels: + app: module-controller + spec: + serviceAccountName: virtual-kubelet # 上一步中配置好的 Service Account + containers: + - name: module-controller + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/release/module-controller-v2:v2.1.4 # 已经打包好的镜像 + imagePullPolicy: Always + resources: + limits: + cpu: "1000m" + memory: "400Mi" + ports: + - name: httptunnel + containerPort: 7777 + env: + - name: ENABLE_HTTP_TUNNEL + value: "true" \ No newline at end of file diff --git a/example/quick-start/module.yaml b/example/quick-start/module.yaml index 4a56138..a1efbb8 100644 --- a/example/quick-start/module.yaml +++ b/example/quick-start/module.yaml @@ -1,23 +1,26 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: biz1 + name: biz1-web-single-host labels: virtual-kubelet.koupleless.io/component: module-deployment spec: replicas: 1 selector: matchLabels: - module: biz1 + virtual-kubelet.koupleless.io/component: module + module.koupleless.io/name: biz1-web-single-host + module.koupleless.io/version: 0.0.1-SNAPSHOT template: metadata: labels: - module: biz1 virtual-kubelet.koupleless.io/component: module + module.koupleless.io/name: biz1-web-single-host + module.koupleless.io/version: 0.0.1-SNAPSHOT spec: containers: - - name: biz1 - image: https://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/biz1-web-single-host-0.0.1-SNAPSHOT-ark-biz.jar + - name: biz1-web-single-host # this name must same with the biz name defined in the jar + image: https://koupleless-dosc.oss-cn-hongkong.aliyuncs.com/biz1-web-single-host-0.0.1-SNAPSHOT-ark-biz.jar env: - name: BIZ_VERSION value: 0.0.1-SNAPSHOT @@ -26,18 +29,24 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: + # these labels in vnode generated in base `https://github.com/koupleless/runtime/blob/main/arklet-core/src/main/java/com/alipay/sofa/koupleless/arklet/core/hook/base/BaseMetadataHookImpl.java` + # you can define your own labels by implementing your own BaseMetadataHookImpl - key: base.koupleless.io/name operator: In values: - - base - - key: base.koupleless.io/version - operator: In - values: - - 1.0.0 + - TO_BE_IMPLEMENTED - key: base.koupleless.io/cluster-name operator: In values: - default + podAntiAffinity: # 打散调度核心配置 + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + virtual-kubelet.koupleless.io/component: module + module.koupleless.io/name: biz1-web-single-host + module.koupleless.io/version: 0.0.1-SNAPSHOT + topologyKey: topology.kubernetes.io/zone tolerations: - key: "schedule.koupleless.io/virtual-node" operator: "Equal" @@ -46,4 +55,4 @@ spec: - key: "schedule.koupleless.io/node-env" operator: "Equal" value: "dev" - effect: "NoExecute" \ No newline at end of file + effect: "NoExecute" From 20102358ec049738d4460df859fb7d13dda032df Mon Sep 17 00:00:00 2001 From: Aiden Date: Thu, 10 Jul 2025 14:43:20 +0800 Subject: [PATCH 2/5] feat(minikube): add minikube delete and debug commands Introduce commands to delete the module-controller deployment from minikube and build a debug version using minikube. Update the debug Dockerfile to set the correct ENTRYPOINT. Also, update the module-controller test YAML to use Deployment instead of Pod for better management. --- Makefile | 12 +++++ debug.Dockerfile | 3 +- .../quick-start/module-controller-test.yaml | 49 +++++++++++-------- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 8915660..5b86777 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,17 @@ buildx: fmt vet build: fmt vet docker build -t serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module_controller:latest . +.PHONY: minikube-delete +minikube-delete: ## Delete module-controller deployment from minikube + kubectl delete deployments.apps/module-controller || true + kubectl wait --for=delete pod -l app=module-controller --timeout=90s + +.PHONY: minikube-debug +minikube-debug: fmt vet minikube-delete ## Build and deploy debug version using minikube + minikube image rm serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest + minikube image build -f debug.Dockerfile -t serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest . + kubectl apply -f example/quick-start/module-controller-test.yaml + ##@ Deployment ifndef ignore-not-found @@ -74,3 +85,4 @@ $(CONTROLLER_GEN): $(LOCALBIN) envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + diff --git a/debug.Dockerfile b/debug.Dockerfile index fac03ce..1db6f55 100644 --- a/debug.Dockerfile +++ b/debug.Dockerfile @@ -42,5 +42,4 @@ EXPOSE 8080 EXPOSE 7777 EXPOSE 2345 -#ENTRYPOINT ["dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./module_controller"] -CMD ["/bin/sh", "-c", "tail -f /dev/null"] \ No newline at end of file +ENTRYPOINT ["dlv", "--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./module_controller"] \ No newline at end of file diff --git a/example/quick-start/module-controller-test.yaml b/example/quick-start/module-controller-test.yaml index 8f35444..e7509f7 100644 --- a/example/quick-start/module-controller-test.yaml +++ b/example/quick-start/module-controller-test.yaml @@ -1,24 +1,31 @@ -apiVersion: v1 -kind: Pod +apiVersion: apps/v1 +kind: Deployment metadata: name: module-controller - labels: - app: module-controller spec: - serviceAccountName: virtual-kubelet # 上一步中配置好的 Service Account - containers: - - name: module-controller - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:v2.1.2 # 已经打包好的镜像 - imagePullPolicy: Always - resources: - limits: - cpu: "1000m" - memory: "400Mi" - ports: - - name: httptunnel - containerPort: 7777 - - name: debug - containerPort: 2345 - env: - - name: ENABLE_HTTP_TUNNEL - value: "true" \ No newline at end of file + replicas: 1 + selector: + matchLabels: + app: module-controller + template: + metadata: + labels: + app: module-controller + spec: + serviceAccountName: virtual-kubelet # 上一步中配置好的 Service Account + containers: + - name: module-controller + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest # 自己构建打包好的镜像 + imagePullPolicy: Never + resources: + limits: + cpu: "1000m" + memory: "400Mi" + ports: + - name: httptunnel + containerPort: 7777 + - name: debug + containerPort: 2345 + env: + - name: ENABLE_HTTP_TUNNEL + value: "true" From cb471ed593e48cd2e252f2c667792b8b8aa90cbc Mon Sep 17 00:00:00 2001 From: Aiden Date: Thu, 10 Jul 2025 15:48:38 +0800 Subject: [PATCH 3/5] feat(minikube): add minikube debug commands and update delete process --- Makefile | 13 +++++++++++-- debug.Dockerfile | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5b86777..a58e557 100644 --- a/Makefile +++ b/Makefile @@ -37,11 +37,20 @@ minikube-delete: ## Delete module-controller deployment from minikube kubectl delete deployments.apps/module-controller || true kubectl wait --for=delete pod -l app=module-controller --timeout=90s -.PHONY: minikube-debug -minikube-debug: fmt vet minikube-delete ## Build and deploy debug version using minikube +.PHONY: minikube-debug-build +minikube-debug-build: fmt vet minikube-delete ## Build and deploy debug version using minikube minikube image rm serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest minikube image build -f debug.Dockerfile -t serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest . kubectl apply -f example/quick-start/module-controller-test.yaml + kubectl wait --for=condition=available --timeout=90s deployments/module-controller + +.PHONY: minikube-debug +minikube-debug: + kubectl exec deployments/module-controller -it -- dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./module_controller + +.PHONY: minikube-port-forward +minikube-port-forward: + kubectl port-forward deployments/module-controller 2345:2345 ##@ Deployment diff --git a/debug.Dockerfile b/debug.Dockerfile index 1db6f55..fac03ce 100644 --- a/debug.Dockerfile +++ b/debug.Dockerfile @@ -42,4 +42,5 @@ EXPOSE 8080 EXPOSE 7777 EXPOSE 2345 -ENTRYPOINT ["dlv", "--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./module_controller"] \ No newline at end of file +#ENTRYPOINT ["dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./module_controller"] +CMD ["/bin/sh", "-c", "tail -f /dev/null"] \ No newline at end of file From 95a955f87c6f519bd4a4ecfe990f62c0977bab47 Mon Sep 17 00:00:00 2001 From: Aiden Date: Thu, 10 Jul 2025 16:42:55 +0800 Subject: [PATCH 4/5] feat(minikube): update minikube build and deploy process for module-controller --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a58e557..0d439f4 100644 --- a/Makefile +++ b/Makefile @@ -37,10 +37,13 @@ minikube-delete: ## Delete module-controller deployment from minikube kubectl delete deployments.apps/module-controller || true kubectl wait --for=delete pod -l app=module-controller --timeout=90s -.PHONY: minikube-debug-build -minikube-debug-build: fmt vet minikube-delete ## Build and deploy debug version using minikube +.PHONY: minikube-build +minikube-build: fmt vet minikube-delete ## Build debug version using minikube minikube image rm serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest minikube image build -f debug.Dockerfile -t serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest . + +.PHONY: minikube-deploy +minikube-deploy: ## Deploy module-controller to minikube kubectl apply -f example/quick-start/module-controller-test.yaml kubectl wait --for=condition=available --timeout=90s deployments/module-controller @@ -52,6 +55,9 @@ minikube-debug: minikube-port-forward: kubectl port-forward deployments/module-controller 2345:2345 +.PHONY: minikube-restart +minikube-restart: minikube-build minikube-deploy minikube-debug + ##@ Deployment ifndef ignore-not-found From ea98ef81f85b5767a3f403a91fade1bd38b7df72 Mon Sep 17 00:00:00 2001 From: Aiden Date: Thu, 10 Jul 2025 16:50:08 +0800 Subject: [PATCH 5/5] fix(module-controller): update imagePullPolicy comment for clarity --- example/quick-start/module-controller-test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/example/quick-start/module-controller-test.yaml b/example/quick-start/module-controller-test.yaml index e7509f7..e7ec2cf 100644 --- a/example/quick-start/module-controller-test.yaml +++ b/example/quick-start/module-controller-test.yaml @@ -17,6 +17,7 @@ spec: - name: module-controller image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest # 自己构建打包好的镜像 imagePullPolicy: Never + # imagePullPolicy: Always # 如果使用远程仓库的镜像,改为 Always resources: limits: cpu: "1000m"