-
Notifications
You must be signed in to change notification settings - Fork 5
feat(minikube): add minikube delete and debug commands #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
312a3b7
2010235
cb471ed
95a955f
ea98ef8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 | ||||||||||||||
Comment on lines
+50
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Resource name should be singular for exec -kubectl exec deployments/module-controller -it -- dlv ...
+kubectl exec deployment/module-controller -it -- dlv ... 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
|
||||||||||||||
.PHONY: minikube-port-forward | ||||||||||||||
minikube-port-forward: | ||||||||||||||
kubectl port-forward deployments/module-controller 2345:2345 | ||||||||||||||
Comment on lines
+54
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Same plural-resource issue for port-forward -kubectl port-forward deployments/module-controller 2345:2345
+kubectl port-forward deployment/module-controller 2345:2345 🤖 Prompt for AI Agents
|
||||||||||||||
|
||||||||||||||
.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 | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } | ||
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 |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -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" | ||||||||||||||||||||||||
replicas: 1 | ||||||||||||||||||||||||
selector: | ||||||||||||||||||||||||
matchLabels: | ||||||||||||||||||||||||
app: module-controller | ||||||||||||||||||||||||
template: | ||||||||||||||||||||||||
metadata: | ||||||||||||||||||||||||
labels: | ||||||||||||||||||||||||
app: module-controller | ||||||||||||||||||||||||
spec: | ||||||||||||||||||||||||
serviceAccountName: virtual-kubelet # 上一步中配置好的 Service Account | ||||||||||||||||||||||||
containers: | ||||||||||||||||||||||||
- name: module-controller | ||||||||||||||||||||||||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add By default the container will run as UID 0 with - name: module-controller
+ securityContext:
+ runAsNonRoot: true
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop: [ "ALL" ] This single change neutralises both Checkov findings and narrows the blast-radius if the process is compromised. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest # 自己构建打包好的镜像 | ||||||||||||||||||||||||
imagePullPolicy: Never | ||||||||||||||||||||||||
# imagePullPolicy: Always # 如果使用远程仓库的镜像,改为 Always | ||||||||||||||||||||||||
Comment on lines
+18
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusivePin the image tag and reconsider Using Consider: - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest
- imagePullPolicy: Never
+ image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:v2.1.4 # or a digest
+ imagePullPolicy: IfNotPresent Aligning the tag with an immutable version (or SHA digest) ensures the exact binary you tested is the one you run everywhere. Pin the image to an immutable tag and adjust The current setup uses
File: example/quick-start/module-controller-test.yaml Lines: 18–20 - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:latest
- imagePullPolicy: Never
+ image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/module-controller-v2:v2.1.4 # pin to a specific release or use a digest
+ imagePullPolicy: IfNotPresent Aligning on a fixed tag (or SHA digest) guarantees you deploy exactly what you’ve tested, and using 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
resources: | ||||||||||||||||||||||||
limits: | ||||||||||||||||||||||||
cpu: "1000m" | ||||||||||||||||||||||||
memory: "400Mi" | ||||||||||||||||||||||||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add resource requests alongside limits for reliable scheduling Only limits are specified; without requests the scheduler will assume 0 CPU / 0 Mi, leading to noisy-neighbor issues and unpredictable QoS. resources:
- limits:
- cpu: "1000m"
- memory: "400Mi"
+ requests:
+ cpu: "200m"
+ memory: "200Mi"
+ limits:
+ cpu: "1000m"
+ memory: "400Mi" Tune the numbers to your actual baseline consumption. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
ports: | ||||||||||||||||||||||||
- name: httptunnel | ||||||||||||||||||||||||
containerPort: 7777 | ||||||||||||||||||||||||
- name: debug | ||||||||||||||||||||||||
containerPort: 2345 | ||||||||||||||||||||||||
env: | ||||||||||||||||||||||||
- name: ENABLE_HTTP_TUNNEL | ||||||||||||||||||||||||
value: "true" |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -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" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+20
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Specify Only limits are declared; requests default to resources:
+ requests:
+ cpu: 200m
+ memory: 200Mi
limits:
cpu: "1000m"
memory: "400Mi" 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Comment on lines
+16
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Checkov flags ( - name: module-controller
image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/release/module-controller-v2:v2.1.4 # 已经打包好的镜像
imagePullPolicy: Always
+ securityContext:
+ allowPrivilegeEscalation: false
+ runAsNonRoot: true
+ capabilities:
+ drop:
+ - "ALL"
resources:
limits:
cpu: "1000m"
memory: "400Mi" 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: httptunnel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
containerPort: 7777 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: ENABLE_HTTP_TUNNEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value: "true" |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -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: | ||||||||||||||
Comment on lines
+22
to
24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Kubernetes expects an image reference like - image: https://koupleless-dosc.oss-cn-hongkong.aliyuncs.com/biz1-web-single-host-0.0.1-SNAPSHOT-ark-biz.jar
+ image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/biz1-web-single-host:0.0.1-SNAPSHOT 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
- 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" | ||||||||||||||
effect: "NoExecute" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
kubectl wait
will error when no pods remainIf
kubectl delete
finds nothing, the subsequentkubectl wait --for=delete
aborts withNotFound
, breaking the target. Swallow the error or use--ignore-not-found
.🤖 Prompt for AI Agents