Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/test_kubevirt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
push:
branches:
- main
tags:
- '*'
pull_request:

jobs:
test_action:
runs-on: ubuntu-latest
name: Test KubeVirt action
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Kind Action Test
uses: ./kind
- name: Get Nodes
run: kubectl get nodes
- name: Create POD
run: kubectl apply -f https://k8s.io/examples/pods/simple-pod.yaml
- name: Kubevirt Test
uses: ./kubevirt
- name: Check pods
run: kubectl get pods -A
2 changes: 1 addition & 1 deletion kind/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
- name: Install KinD
shell: bash
run: |
sudo curl -Lo /usr/local/bin/kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-amd64
sudo curl -Lo /usr/local/bin/kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-amd64
sudo curl -Lo /usr/local/bin/kubectl "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo chmod +x /usr/local/bin/kind /usr/local/bin/kubectl
- name: Start KinD
Expand Down
68 changes: 68 additions & 0 deletions kubevirt/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Create KubeVirt
description: Create KubeVirt on Kind Cluster

runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Create KubeVirt Lastest Operator
shell: bash
run: |
kubectl version
#export VERSION=$(curl -s https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)

echo $VERSION
kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml"
pod_names=$(kubectl get pod -o name --no-headers -n kubevirt)
kubectl wait -n kubevirt --for=condition=Ready $(echo $pod_names) --timeout 100s

kubectl get all -n kubevirt
sleep 10

kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml"
sleep 10
kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}}}}'

counter=0
status=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.phase}")
while [[ $status != "Deployed" ]]; do
echo "status $status"
status=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.phase}")
sleep 5
counter=$((counter + 1))
if [[ $counter -ge 10 ]]; then
break
fi
done
kubectl get all -n kubevirt


- name: Install Virtctl
shell: bash
run: |
VERSION=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.observedKubeVirtVersion}")
ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
echo ${ARCH}
curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
chmod +x virtctl
sudo install virtctl /usr/local/bin
- name: Create Virtual Machine using Virtctl
shell: bash
run: |
wget https://kubevirt.io/labs/manifests/vm.yaml

kubectl apply -f https://kubevirt.io/labs/manifests/vm.yaml
kubectl get vms
kubectl get vms -o yaml testvm

kubectl patch virtualmachine testvm --type merge -p '{"spec":{"runStrategy": "Always"}}'
virtctl start testvm

sleep 40
kubectl get vmis
kubectl get vmis -o yaml testvm
pod_name=$(kubectl get pod -o name --no-headers)
kubectl logs $pod_name
Loading