-
Notifications
You must be signed in to change notification settings - Fork 1
197 lines (163 loc) · 9 KB
/
kubevirt.yml
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Create a kind cluster, install kubevirt to test it
on:
workflow_dispatch:
push:
branches:
- main
env:
KUBEVIRT_VERSION: v1.2.1
KUBEVIRT_CDI_VERSION: v1.59.0
TEKTON_VERSION: v0.59.0
TEKTON_CLIENT: 0.37.0
ARGOCD_VERSION: v0.10.0
OLM_VERSION: v0.28.0
QUAY_ORG: snowdrop
jobs:
kubevirt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create a kind cluster running the ingress controller
run: |
curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/kind.sh" | bash -s install --server-ip 127.0.0.1
# - name: Log OS, kube tools, container versions
# run: |
# echo "########### OS ###########"
# cat /etc/os-release
#
# echo "########### Kind version ###########"
# kind --version
#
# echo "########### Docker version ###########"
# docker -v
#
# echo "########### kubectl version ###########"
# kubectl version --client
#
# echo "########### Kubevirt version: $KUBEVIRT_VERSION ###########"
#
# - name: Install OLM
# run: |
# curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/$OLM_VERSION/install.sh -o install.sh
# chmod +x install.sh
# ./install.sh $OLM_VERSION
#
# - name: Install Argocd client
# run: |
# curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
# sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
# rm argocd-linux-amd64
#
# - name : Install Tekton
# run: |
# kubectl apply -f https://github.com/tektoncd/pipeline/releases/download/${TEKTON_VERSION}/release.yaml
# kubectl wait deployment -n tekton-pipelines tekton-pipelines-controller --for condition=Available=True --timeout=90s
# kubectl wait deployment -n tekton-pipelines tekton-pipelines-webhook --for condition=Available=True --timeout=90s
#
# echo "Disabling the affinity-assistant to avoid the error: more than one PersistentVolumeClaim is bound to a TaskRun = pod"
# kubectl patch cm feature-flags -n tekton-pipelines -p '{"data":{"disable-affinity-assistant":"true"}}'
- name: Install and configure ArgoCD
run: |
# Install ArgoCD Operator subscription
# kubectl apply -f https://raw.githubusercontent.com/ch007m/test-github-action/main/.github/resources/argocd/subscription.yaml
# function csv_succeeded {
# kubectl get csv argocd-operator.${ARGOCD_VERSION} -o jsonpath='{.status.phase}'
# }
#
# # Loop until the CSV is Succeeded
# until [[ $(csv_succeeded) == "Succeeded" ]]; do
# echo "Waiting for CSV 'argocd-operator.${ARGOCD_VERSION}' to reach Succeeded phase..."
# sleep 5
# done
#
# # Create the gitops namespace and deploy the argocd instance
# kubectl create ns gitops
# kubectl apply -n gitops -f https://raw.githubusercontent.com/ch007m/test-github-action/main/.github/resources/argocd/argocd.yaml
# kubectl wait deployment -n gitops argocd-gitops-server --for condition=Available=True --timeout=90s
# kubectl wait deployment -n gitops argocd-gitops-applicationset-controller --for condition=Available=True --timeout=90s
cd .github/resources/argocd/helm
helm repo add argo-cd https://argoproj.github.io/argo-helm
helm dep update my-chart
kubectl create ns gitops
helm install argo-cd ./my-chart -f ./values.yaml -n gitops
kubectl wait deployment -n gitops argo-cd-argocd-server --for condition=Available=True --timeout=90s
kubectl wait deployment -n gitops argo-cd-argocd-applicationset-controller --for condition=Available=True --timeout=90s
echo "Update /etc/hosts"
sudo echo "127.0.0.1 argo-ui.local" >> /etc/hosts
echo "Get Argocd admin secret"
ARGOCD_PWD=$(kubectl get secret/argocd-initial-admin-secret -n gitops -ojson | jq -r '.data.password' | base64 -d)
echo "Argocd password: $ARGOCD_PWD. End"
ARGOCD_SERVER=argo-ui.local
ARGOCD_USER=admin
echo "Curl ArgoCD"
curl -H "Host: argo-ui.local" http://127.0.0.1
argocd login --insecure $ARGOCD_SERVER --username $ARGOCD_USER --password $ARGOCD_PWD --grpc-web
argocd app list
- name: Install Kubevirt
run: |
function is_nested_virt_enabled() {
kvm_nested="unknown"
if [ -f "/sys/module/kvm_intel/parameters/nested" ]; then
kvm_nested=$( cat /sys/module/kvm_intel/parameters/nested )
elif [ -f "/sys/module/kvm_amd/parameters/nested" ]; then
kvm_nested=$( cat /sys/module/kvm_amd/parameters/nested )
fi
[ "$kvm_nested" == "1" ] || [ "$kvm_nested" == "Y" ] || [ "$kvm_nested" == "y" ]
}
echo "Deploying KubeVirt"
kubectl apply -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml"
kubectl apply -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-cr.yaml"
echo "Configuring Kubevirt to use emulation if needed"
if ! is_nested_virt_enabled; then
kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}}}}'
fi
echo "Deploying KubeVirt containerized-data-importer"
kubectl apply -f "https://github.com/kubevirt/containerized-data-importer/releases/download/${KUBEVIRT_CDI_VERSION}/cdi-operator.yaml"
kubectl apply -f "https://github.com/kubevirt/containerized-data-importer/releases/download/${KUBEVIRT_CDI_VERSION}/cdi-cr.yaml"
echo "Waiting for KubeVirt to be ready"
kubectl wait --for=condition=Available kubevirt kubevirt --namespace=kubevirt --timeout=5m
echo "Patch the StorageProfile to use the storageclass standard and give ReadWrite access"
kubectl get StorageProfile
kubectl patch --type merge -p '{"spec": {"claimPropertySets": [{"accessModes": ["ReadWriteOnce"], "volumeMode": "Filesystem"}]}}' StorageProfile standard
- name: Give more RBAC to Virt resources and RW for PVC
run: |
kubectl patch --type merge -p '{"spec": {"claimPropertySets": [{"accessModes": ["ReadWriteOnce"], "volumeMode": "Filesystem"}]}}' StorageProfile standard
kubectl create clusterrolebinding pod-kubevirt-viewer --clusterrole=kubevirt.io:view --serviceaccount=default:default
kubectl create clusterrolebinding cdi-kubevirt-viewer --clusterrole=cdi.kubevirt.io:view --serviceaccount=default:default
kubectl create clusterrolebinding quarkus-dev --clusterrole=admin --serviceaccount=default:default
- name: Install our Fedora podman image
run: |
kubectl create ns vm-images
kubectl apply -n vm-images -f https://raw.githubusercontent.com/ch007m/test-github-action/main/.github/resources/quay-to-pvc-datavolume.yml
kubectl wait datavolume -n vm-images quarkus-dev-disk --for condition=Ready=True --timeout=90s
- name: Create ssh key, secret and VM
run: |
ssh-keygen -N "" -f id_rsa
kubectl create secret generic quarkus-dev-ssh-key -n default --from-file=key=id_rsa.pub
kubectl apply -f https://raw.githubusercontent.com/ch007m/test-github-action/main/.github/resources/quarkus-dev-vm.yml
kubectl wait vmi -n default quarkus-dev --for condition=Ready=True --timeout=90s
- name: Check pods ...
run: |
kubectl get pod -A
- name: Wait till podman remote replies
run: |
VM_IP=$(kubectl get vmi -o jsonpath='{.items[0].status.interfaces[0].ipAddress}')
echo "VM IP is: $VM_IP"
# Launch the podman client
kubectl run podname-client --image=quay.io/podman/stable -- "sleep" "1000000"
# Wait for the pod to be in the Running state
kubectl wait --for condition=Ready pod/podname-client --timeout=360s
echo "Wait for the command within the pod to succeed"
echo ">>>> Command to be executed to check healthiness of podman & socat"
echo ">>>> kubectl exec podname-client -- podman \"-r\" \"--url=tcp://$VM_IP:2376\" \"version\""
while true; do
kubectl exec podname-client -- podman "-r" "--url=tcp://$VM_IP:2376" "version"
if [ $? -eq 0 ]; then
echo "Command within the pod succeeded."
break
else
echo "Remote podman is not yet ready to reply.."
fi
sleep 20
done