-
Notifications
You must be signed in to change notification settings - Fork 30
123 lines (105 loc) · 5.31 KB
/
e2e.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: E2E
on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]
jobs:
create-cluster:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
- name: "Setup Kubevirt Infrastructure Stack"
run: |
# Install Metal LB for exposing Kubevirt based Workload Cluster's Api server
METALLB_VER=$(curl "https://api.github.com/repos/metallb/metallb/releases/latest" | jq -r ".tag_name")
kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/${METALLB_VER}/config/manifests/metallb-native.yaml"
kubectl wait pods -n metallb-system -l app=metallb,component=controller --for=condition=Ready --timeout=10m
kubectl wait pods -n metallb-system -l app=metallb,component=speaker --for=condition=Ready --timeout=2m
GW_IP=$(docker network inspect -f '{{range .IPAM.Config}}{{.Gateway}}{{end}}' kind)
NET_IP=$(echo ${GW_IP} | sed -E 's|^([0-9]+\.[0-9]+)\..*$|\1|g')
cat <<EOF | sed -E "s|172.19|${NET_IP}|g" | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: capi-ip-pool
namespace: metallb-system
spec:
addresses:
- 172.19.255.200-172.19.255.250
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: empty
namespace: metallb-system
EOF
# get KubeVirt version
KV_VER=$(curl "https://api.github.com/repos/kubevirt/kubevirt/releases/latest" | jq -r ".tag_name")
# deploy required CRDs
kubectl apply -f "https://github.com/kubevirt/kubevirt/releases/download/${KV_VER}/kubevirt-operator.yaml"
# deploy the KubeVirt custom resource
kubectl apply -f "https://github.com/kubevirt/kubevirt/releases/download/${KV_VER}/kubevirt-cr.yaml"
kubectl wait -n kubevirt kv kubevirt --for=condition=Available --timeout=10m
- name: "Install clusterctl and helm binaries"
run: |
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.4/clusterctl-linux-amd64 -o clusterctl
sudo chmod +x clusterctl
sudo mv clusterctl /usr/bin/clusterctl
clusterctl version
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
sudo chmod 700 get_helm.sh
./get_helm.sh
helm version
- name: "Setup kamaji"
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.11.0 \
--set installCRDs=true
helm repo add clastix https://clastix.github.io/charts
helm repo update
helm install kamaji clastix/kamaji -n kamaji-system --create-namespace
- name: "Setup CAPI stack with kubevirt as infra and kamaji as controlplane providers"
run: |
mkdir ~/.cluster-api
touch ~/.cluster-api/clusterctl.yaml
cat <<EOF > ~/.cluster-api/clusterctl.yaml
providers:
- name: "kamaji"
url: "https://github.com/clastix/cluster-api-control-plane-provider-kamaji/releases/v0.11.0/control-plane-components.yaml"
type: "ControlPlaneProvider"
EOF
clusterctl init --infrastructure kubevirt --control-plane kamaji
kubectl wait deploy -n kamaji-system capi-kamaji-controller-manager --for=condition=Available --timeout=10m
kubectl wait deploy -n capi-kubeadm-bootstrap-system capi-kubeadm-bootstrap-controller-manager --for=condition=Available --timeout=10m
kubectl wait deploy -n capi-system capi-controller-manager --for=condition=Available --timeout=10m
- name: "Deploy target cluster"
run: |
kubectl apply -f .github/workflows/targetcluster-controlplane.yaml
kubectl wait cluster capi-quickstart --for=condition=InfrastructureReady --timeout=10m
kubectl wait kamajicontrolplane capi-quickstart-kubevirt --for=condition=KamajiControlPlaneIsReady --timeout=10m
kubectl apply -f .github/workflows/targetcluster-workers.yaml
sleep 30 # sleep for 30sec to machine CR to be created
# wait for kubevirt pod and corresponding capi machine
kubectl wait machine -l cluster.x-k8s.io/cluster-name=capi-quickstart --for=condition=InfrastructureReady --timeout=10m
kubectl wait pod -l cluster.x-k8s.io/cluster-name=capi-quickstart --for=condition=Ready --timeout=10m
- name: "Test target cluster"
run: |
kubectl get secret capi-quickstart-kubevirt-admin-kubeconfig -o json \
| jq -r '.data["admin.conf"]' \
| base64 --decode \
> targetcluster.kubeconfig
export KUBECONFIG=targetcluster.kubeconfig
kubectl get pods -A
kubectl get nodes
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
sleep 30
kubectl get pods -A
kubectl wait nodes -l kubernetes.io/os=linux --for=condition=Ready