Skip to content

Commit

Permalink
Makefile: add support for deploying kwok in the kind cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Jul 13, 2023
1 parent ac5ba23 commit 7d27214
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ ovn.yaml
ovn-ic-0.yaml
ovn-ic-1.yaml
kind.yaml
kustomization.yaml
kwok.yaml
kwok-node.yaml
broker-info.subm
broker-info.subm.*
broker-info-internal.subm
Expand Down
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ DEEPFLOW_CHART_REPO = https://deepflow-ce.oss-cn-beijing.aliyuncs.com/chart/stab
DEEPFLOW_IMAGE_REPO = registry.cn-beijing.aliyuncs.com/deepflow-ce
DEEPFLOW_GRAFANA_PORT = 30080

KWOK_VERSION = v0.3.0
KWOK_IMAGE = registry.k8s.io/kwok/kwok:$(KWOK_VERSION)

VPC_NAT_GW_IMG = $(REGISTRY)/vpc-nat-gateway:$(VERSION)

E2E_NETWORK = bridge
Expand Down Expand Up @@ -273,6 +276,10 @@ define kind_load_submariner_images
$(call kind_load_image,$(1),$(SUBMARINER_NETTEST),1)
endef

define kind_load_kwok_image
$(call kind_load_image,$(1),$(KWOK_IMAGE),1)
endef

define kubectl_wait_exist_and_ready
@echo "Waiting for $(2) $(1)/$(3) to exist..."
@n=0; while ! kubectl -n $(1) get $(2) -o name | awk -F / '{print $$2}' | grep -q ^$(3)$$; do \
Expand Down Expand Up @@ -773,6 +780,21 @@ kind-install-deepflow:
-p '[{"op": "replace", "path": "/spec/ports/0/nodePort", "value": $(DEEPFLOW_GRAFANA_PORT)}]'
echo -e "\nGrafana URL: http://127.0.0.1:$(DEEPFLOW_GRAFANA_PORT)\nGrafana auth: admin:deepflow\n"

.PHONY: kind-install-kwok
kind-install-kwok:
kwok_version=$(KWOK_VERSION) j2 yamls/kwok-kustomization.yaml.j2 -o kustomization.yaml
kubectl kustomize ./ > kwok.yaml
$(call kind_load_kwok_image,kube-ovn)
kubectl apply -f kwok.yaml
kubectl -n kube-system rollout status deploy kwok-controller --timeout 60s

.PHONY: kind-add-kwok-node
kind-add-kwok-node:
for i in {1..20}; do \
kwok_node_name=fake-node-$$i j2 yamls/kwok-node.yaml.j2 -o kwok-node.yaml; \
kubectl apply -f kwok-node.yaml; \
done

.PHONY: kind-reload
kind-reload: kind-reload-ovs
kubectl delete pod -n kube-system -l app=kube-ovn-controller
Expand Down Expand Up @@ -837,6 +859,7 @@ clean:
$(RM) yamls/kind.yaml
$(RM) ovn.yaml kube-ovn.yaml kube-ovn-crd.yaml
$(RM) ovn-ic-0.yaml ovn-ic-1.yaml
$(RM) kustomization.yaml kwok.yaml kwok-node.yaml
$(RM) kube-ovn.tar vpc-nat-gateway.tar image-amd64.tar image-arm64.tar

.PHONY: changelog
Expand Down
7 changes: 7 additions & 0 deletions yamls/kwok-kustomization.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: registry.k8s.io/kwok/kwok
newTag: "{{ kwok_version }}"
resources:
- "https://github.com/kubernetes-sigs/kwok/kustomize/kwok?ref={{ kwok_version }}"
42 changes: 42 additions & 0 deletions yamls/kwok-node.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: "{{ kwok_node_name }}"
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: "{{ kwok_node_name }}"
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
allocatable:
cpu: 32
memory: 256Gi
pods: 110
capacity:
cpu: 32
memory: 256Gi
pods: 110
nodeInfo:
architecture: amd64
bootID: ""
containerRuntimeVersion: ""
kernelVersion: ""
kubeProxyVersion: fake
kubeletVersion: fake
machineID: ""
operatingSystem: linux
osImage: ""
systemUUID: ""
phase: Running

0 comments on commit 7d27214

Please sign in to comment.