Skip to content

Add step to kustomize the resources and create the vm #113

Add step to kustomize the resources and create the vm

Add step to kustomize the resources and create the vm #113

Workflow file for this run

name: Create a kind cluster, install kubevirt to testit
on:
workflow_dispatch:
push:
branches:
- main
env:
KUBEVIRT_VERSION: v1.2.1
KUBEVIRT_CDI_VERSION: v1.59.0
KUBEVIRT_TEKTON_TASKS: v0.16.0
TEKTON_VERSION: v0.59.0
TEKTON_CLIENT: 0.37.0
QUAY_ORG: snowdrop
jobs:
kubevirt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create kind cluster
run: |
kind create cluster
- 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: Deploy 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
echo "Successfully deployed KubeVirt, CDI:"
kubectl get pods -n kubevirt
kubectl get pods -n cdi
- name: Deploy Tekton
run: |
kubectl apply -f https://github.com/tektoncd/pipeline/releases/download/v0.59.0/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"}}'
curl -LO https://github.com/tektoncd/cli/releases/download/v${TEKTON_CLIENT}/tektoncd-cli-${TEKTON_CLIENT}_Linux-64bit.deb
sudo dpkg -i ./tektoncd-cli-${TEKTON_CLIENT}_Linux-64bit.deb
- name: Grant more rights to the default serviceaccount to access Kubevirt, Kubevirt CDI & Kubernetes APIs
run: |
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: Creating a VM and generating a SSH key (private/public)
run: |
echo "## Creating the kubernetes secret storing the public key"
ssh-keygen -N "" -f id_rsa
kubectl create secret generic quarkus-dev-ssh-key -n default --from-file=key=id_rsa.pub
echo "## Creating a DataVolume using as registry image our customized Fedora Cloud OS packaging: podman, socat"
kubectl create ns vm-images
kubectl apply -n vm-images -f .github/resources/quay-to-pvc-datavolume.yml
echo "## Kustomize the VM yaml resource to clone the PVC of the OS using the vm-images namespace instead of the default on ocp ..."
kustomize build .github/resources | kubectl apply -f -
kubectl wait --for=condition=Ready vm/quarkus-dev --timeout=180s