Skip to content

Commit

Permalink
Makefile: fix kwok installation (#3561)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
  • Loading branch information
zhangzujian committed Dec 22, 2023
1 parent db2aeeb commit acb9e97
Show file tree
Hide file tree
Showing 5 changed files with 2,188 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -17,7 +17,6 @@ ovn-ic-0.yaml
ovn-ic-1.yaml
kind.yaml
kustomization.yaml
kwok.yaml
kwok-node.yaml
broker-info.subm
broker-info.subm.*
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Expand Up @@ -798,11 +798,14 @@ kind-install-deepflow: kind-install
echo -e "\nGrafana URL: http://127.0.0.1:$(DEEPFLOW_GRAFANA_PORT)\nGrafana auth: admin:deepflow\n"

.PHONY: kind-install-kwok
kind-install-kwok: kind-install-underlay
kwok_version=$(KWOK_VERSION) j2 yamls/kwok-kustomization.yaml.j2 -o kustomization.yaml
kubectl kustomize ./ > kwok.yaml
kind-install-kwok:
kubectl label node --overwrite -l type!=kwok type=kind
kubectl -n kube-system patch ds kube-proxy -p '{"spec":{"template":{"spec":{"nodeSelector":{"type":"kind"}}}}}'
kubectl -n kube-system patch ds ovs-ovn -p '{"spec":{"template":{"spec":{"nodeSelector":{"type":"kind"}}}}}'
kubectl -n kube-system patch ds kube-ovn-cni -p '{"spec":{"template":{"spec":{"nodeSelector":{"type":"kind"}}}}}'
$(call kind_load_kwok_image,kube-ovn)
kubectl apply -f kwok.yaml
kubectl apply -f yamls/kwok.yaml
kubectl apply -f yamls/kwok-stage.yaml
kubectl -n kube-system rollout status deploy kwok-controller --timeout 60s
for i in {1..20}; do \
kwok_node_name=fake-node-$$i j2 yamls/kwok-node.yaml.j2 -o kwok-node.yaml; \
Expand Down Expand Up @@ -877,7 +880,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) kwok-node.yaml
$(RM) kube-ovn.tar kube-ovn-dpdk.tar vpc-nat-gateway.tar image-amd64.tar image-amd64-dpdk.tar image-arm64.tar

.PHONY: changelog
Expand Down
7 changes: 0 additions & 7 deletions yamls/kwok-kustomization.yaml.j2

This file was deleted.

259 changes: 259 additions & 0 deletions yamls/kwok-stage.yaml
@@ -0,0 +1,259 @@
apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
name: node-heartbeat-with-lease
spec:
delay:
durationMilliseconds: 600000
jitterDurationMilliseconds: 610000
next:
statusTemplate: |
{{ $now := Now }}
{{ $lastTransitionTime := or .metadata.creationTimestamp $now }}
conditions:
{{ range NodeConditions }}
- lastHeartbeatTime: {{ $now | Quote }}
lastTransitionTime: {{ $lastTransitionTime | Quote }}
message: {{ .message | Quote }}
reason: {{ .reason | Quote }}
status: {{ .status | Quote }}
type: {{ .type | Quote }}
{{ end }}
addresses:
{{ with .status.addresses }}
{{ YAML . 1 }}
{{ else }}
{{ with NodeIP }}
- address: {{ . | Quote }}
type: InternalIP
{{ end }}
{{ with NodeName }}
- address: {{ . | Quote }}
type: Hostname
{{ end }}
{{ end }}
{{ with NodePort }}
daemonEndpoints:
kubeletEndpoint:
Port: {{ . }}
{{ end }}
resourceRef:
apiGroup: v1
kind: Node
selector:
matchExpressions:
- key: .status.phase
operator: In
values:
- Running
- key: .status.conditions.[] | select( .type == "Ready" ) | .status
operator: In
values:
- "True"
---
apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
name: node-initialize
spec:
next:
statusTemplate: |
{{ $now := Now }}
{{ $lastTransitionTime := or .metadata.creationTimestamp $now }}
conditions:
{{ range NodeConditions }}
- lastHeartbeatTime: {{ $now | Quote }}
lastTransitionTime: {{ $lastTransitionTime | Quote }}
message: {{ .message | Quote }}
reason: {{ .reason | Quote }}
status: {{ .status | Quote }}
type: {{ .type | Quote}}
{{ end }}
addresses:
{{ with .status.addresses }}
{{ YAML . 1 }}
{{ else }}
{{ with NodeIP }}
- address: {{ . | Quote }}
type: InternalIP
{{ end }}
{{ with NodeName }}
- address: {{ . | Quote }}
type: Hostname
{{ end }}
{{ end }}
{{ with NodePort }}
daemonEndpoints:
kubeletEndpoint:
Port: {{ . }}
{{ end }}
allocatable:
{{ with .status.allocatable }}
{{ YAML . 1 }}
{{ else }}
cpu: 1k
memory: 1Ti
pods: 1M
{{ end }}
capacity:
{{ with .status.capacity }}
{{ YAML . 1 }}
{{ else }}
cpu: 1k
memory: 1Ti
pods: 1M
{{ end }}
{{ with .status.nodeInfo }}
nodeInfo:
architecture: {{ with .architecture }} {{ . }} {{ else }} "amd64" {{ end }}
bootID: {{ with .bootID }} {{ . }} {{ else }} "" {{ end }}
containerRuntimeVersion: {{ with .containerRuntimeVersion }} {{ . }} {{ else }} "kwok-{{ Version }}" {{ end }}
kernelVersion: {{ with .kernelVersion }} {{ . }} {{ else }} "kwok-{{ Version }}" {{ end }}
kubeProxyVersion: {{ with .kubeProxyVersion }} {{ . }} {{ else }} "kwok-{{ Version }}" {{ end }}
kubeletVersion: {{ with .kubeletVersion }} {{ . }} {{ else }} "kwok-{{ Version }}" {{ end }}
machineID: {{ with .machineID }} {{ . }} {{ else }} "" {{ end }}
operatingSystem: {{ with .operatingSystem }} {{ . }} {{ else }} "linux" {{ end }}
osImage: {{ with .osImage }} {{ . }} {{ else }} "" {{ end }}
systemUUID: {{ with .systemUUID }} {{ . }} {{ else }} "" {{ end }}
{{ end }}
phase: Running
resourceRef:
apiGroup: v1
kind: Node
selector:
matchExpressions:
- key: .status.conditions.[] | select( .type == "Ready" ) | .status
operator: NotIn
values:
- "True"
---
apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
name: pod-complete
spec:
next:
statusTemplate: |
{{ $now := Now }}
{{ $root := . }}
containerStatuses:
{{ range $index, $item := .spec.containers }}
{{ $origin := index $root.status.containerStatuses $index }}
- image: {{ $item.image | Quote }}
name: {{ $item.name | Quote }}
ready: false
restartCount: 0
started: false
state:
terminated:
exitCode: 0
finishedAt: {{ $now | Quote }}
reason: Completed
startedAt: {{ $now | Quote }}
{{ end }}
phase: Succeeded
resourceRef:
apiGroup: v1
kind: Pod
selector:
matchExpressions:
- key: .metadata.deletionTimestamp
operator: DoesNotExist
- key: .status.phase
operator: In
values:
- Running
- key: .metadata.ownerReferences.[].kind
operator: In
values:
- Job
---
apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
name: pod-delete
spec:
next:
delete: true
finalizers:
empty: true
resourceRef:
apiGroup: v1
kind: Pod
selector:
matchExpressions:
- key: .metadata.deletionTimestamp
operator: Exists
---
apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
name: pod-ready
spec:
next:
statusTemplate: |
{{ $now := Now }}
conditions:
- lastTransitionTime: {{ $now | Quote }}
status: "True"
type: Initialized
- lastTransitionTime: {{ $now | Quote }}
status: "True"
type: Ready
- lastTransitionTime: {{ $now | Quote }}
status: "True"
type: ContainersReady
{{ range .spec.readinessGates }}
- lastTransitionTime: {{ $now | Quote }}
status: "True"
type: {{ .conditionType | Quote }}
{{ end }}
containerStatuses:
{{ range .spec.containers }}
- image: {{ .image | Quote }}
name: {{ .name | Quote }}
ready: true
restartCount: 0
state:
running:
startedAt: {{ $now | Quote }}
{{ end }}
initContainerStatuses:
{{ range .spec.initContainers }}
- image: {{ .image | Quote }}
name: {{ .name | Quote }}
ready: true
restartCount: 0
state:
terminated:
exitCode: 0
finishedAt: {{ $now | Quote }}
reason: Completed
startedAt: {{ $now | Quote }}
{{ end }}
hostIP: {{ NodeIPWith .spec.nodeName | Quote }}
podIP: {{ index .metadata.annotations "ovn.kubernetes.io/ip_address" }}
phase: Running
startTime: {{ $now | Quote }}
resourceRef:
apiGroup: v1
kind: Pod
selector:
matchExpressions:
- key: .metadata.deletionTimestamp
operator: DoesNotExist
- key: .status.podIP
operator: DoesNotExist
- key: .metadata.annotations."ovn.kubernetes.io/routed"
operator: In
values:
- "true"

0 comments on commit acb9e97

Please sign in to comment.