diff --git a/Makefile b/Makefile index 8915660..0d439f4 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,32 @@ 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-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 + +.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 + +.PHONY: minikube-restart +minikube-restart: minikube-build minikube-deploy minikube-debug + ##@ Deployment ifndef ignore-not-found @@ -74,3 +100,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/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-test.yaml b/example/quick-start/module-controller-test.yaml index 8f35444..e7ec2cf 100644 --- a/example/quick-start/module-controller-test.yaml +++ b/example/quick-start/module-controller-test.yaml @@ -1,24 +1,32 @@ -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 + # imagePullPolicy: Always # 如果使用远程仓库的镜像,改为 Always + resources: + limits: + cpu: "1000m" + memory: "400Mi" + ports: + - name: httptunnel + containerPort: 7777 + - name: debug + containerPort: 2345 + env: + - name: ENABLE_HTTP_TUNNEL + value: "true" 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"