Finalise exercise 3 with automated standup and teardown.

This commit is contained in:
2024-04-14 13:16:11 +12:00
parent 7d6e58db36
commit 4ee286e015
3 changed files with 148 additions and 9 deletions

View File

@ -15,6 +15,106 @@ For our purposes we have clusters running in Equinix Metal provisioned via the [
Follow the steps below to prepare each cluster in advance of the hackathon.
#+begin_src tmux
# Create the exercise three namespace
oc create namespace demotestwtf17
# Create the exercise three virtual machine
cat << EOF | oc apply --namespace demotestwtf17 --filename -
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: fedora
namespace: demotestwtf17
finalizers:
- kubevirt.io/virtualMachineControllerFinalize
labels:
app: fedora
vm.kubevirt.io/template: fedora-server-small
vm.kubevirt.io/template.namespace: openshift
vm.kubevirt.io/template.revision: '1'
vm.kubevirt.io/template.version: v0.25.0
spec:
dataVolumeTemplates:
- apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
creationTimestamp: null
name: fedora
spec:
sourceRef:
kind: DataSource
name: fedora
namespace: openshift-virtualization-os-images
storage:
resources:
requests:
storage: 30Gi
running: true
template:
metadata:
annotations:
vm.kubevirt.io/flavor: small
vm.kubevirt.io/os: fedora
vm.kubevirt.io/workload: server
creationTimestamp: null
labels:
kubevirt.io/domain: fedora
kubevirt.io/size: small
spec:
domain:
cpu:
cores: 1
sockets: 1
threads: 1
devices:
disks:
- disk:
bus: virtio
name: rootdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- macAddress: '02:d5:73:00:00:07'
masquerade: {}
model: virtio
name: default
networkInterfaceMultiqueue: true
rng: {}
features:
acpi: {}
smm:
enabled: true
firmware:
bootloader:
efi: {}
machine:
type: pc-q35-rhel9.2.0
resources:
requests:
memory: 2Gi
evictionStrategy: LiveMigrate
networks:
- name: default
pod: {}
nodeSelector:
seems: legit
terminationGracePeriodSeconds: 180
volumes:
- dataVolume:
name: fedora
name: rootdisk
- cloudInitNoCloud:
userData: |-
#cloud-config
user: fedora
password: fedora
chpasswd: { expire: False }
name: cloudinitdisk
EOF
#+end_src
* Automated scenario population
@ -28,7 +128,7 @@ oc create namespace crusty-corp
# Create the virtual machine template
#+begin_src tmux
cat << 'EOF' | oc apply --namespace crusty-corp -f -
cat << 'EOF' | oc apply --namespace crusty-corp --filename -
kind: Template
apiVersion: template.openshift.io/v1
metadata:
@ -183,7 +283,7 @@ parameters:
EOF
# Create the virtual machine from template
cat << 'EOF' | oc apply --namespace crusty-corp -f -
cat << 'EOF' | oc apply --namespace crusty-corp --filename -
apiVersion: 'kubevirt.io/v1'
kind: 'VirtualMachine'
metadata:
@ -284,10 +384,49 @@ EOF
#+end_src
** Exercise three - But can it do live migration?
#+begin_src tmux
# Create the namespace
oc create namespace demotestwtf17
# Patch the bogus virtual machine nodeselector
cat << EOF | oc apply --namespace demotestwtf17 --filename -
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: fedora
namespace: demotestwtf17
spec:
template:
spec:
nodeSelector:
EOF
# Initiate the live migration
cat << EOF | oc create --namespace demotestwtf17 --filename -
apiVersion: kubevirt.io/v1
kind: VirtualMachineInstanceMigration
metadata:
name: fedora-migration-hackathon
namespace: demotestwtf17
finalizers:
- kubevirt.io/migrationJobFinalize
labels:
kubevirt.io/vmi-name: fedora
spec:
vmiName: fedora
EOF
# Check the node virtual machine migrated to
oc --namespace demotestwtf17 get VirtualMachineInstance fedora
#+end_src
* Automated scenario cleanup
If you need to quickly reset an example environment to have no solutions populated you can use the following source blocks.
#+begin_src tmux
oc delete namespace crusty-corp
oc delete namespace --ignore-not-found crusty-corp demotestwtf17
#+end_src

View File

@ -8,7 +8,7 @@ authors: ['default']
summary: "Let's get underway with the hackathon."
---
Welcome to the OpenShift Virtualisation Hackathon! Here you'll have a chance to build your container native virtualisation prowess. Exercises will gradually increase in difficulty as you go and award points for each correct solution. You're in a race to reach the highest score before the session concludes!
Welcome to the OpenShift Virtualisation Hackathon! Here you'll have a chance to build your container native virtualisation prowess. Exercises will award points for each correct solution. You're in a race to reach the highest score before the session concludes!
**Let's get started!**

View File

@ -1,7 +1,7 @@
---
title: But can it do live migration?
exercise: 3
date: '2024-04-05'
date: '2024-04-14'
tags: ['openshift','virtualisation','kubernetes','kubevirt']
draft: false
authors: ['default']
@ -10,16 +10,16 @@ summary: "Will OpenShift Virtualisation live migrate a virtual machine?"
During the demo with the Acme Financial Services team one of their traditional hypervisor team asked if you can show them a live migration for a running virtual machine.
Thinking on your feet you remember the Fedora virtual machine you were tinkering with last night in the `demotestblah17` namespace on the cluster. Perhaps you can quickly use that to demo a live migration?
Thinking on your feet you remember the Fedora virtual machine you were tinkering with last night in the `demotestwtf17` namespace on the cluster. Perhaps you can quickly use that to demo a live migration?
The Acme Financial Services team have put you on the spot, can you pull off a virtual machine live migration? 😅
## 3.1 - Initiate the live migration
For this task, your team must live migrate the virtual machine named `fedora` in namespace `demotestblah17` from one node to another and record the name of the node the vm has migrated to.
For this task, your team must live migrate the virtual machine named `fedora` in namespace `demotestwtf17` from one node to another and record the name of the node the vm has migrated to.
No command line is required. However before you can complete the migration you will first need to investigate and correct why the virtual machine is currently not running. You had one too many coke zeros last night and can't remember how the machine got into the state it did.
No command line is required. However before you can complete the migration you will first need to investigate and correct why the virtual machine is currently not running. You had one too many coke zeros last night and can't remember how the machine got into the state it did 🤦.
Documentation you may find helpful is:
- https://docs.openshift.com/container-platform/4.15/virt/live_migration/virt-configuring-live-migration.html
@ -30,6 +30,6 @@ Documentation you may find helpful is:
If the virtual machine in your **demotestblah17** namespace has been live migrated to another node successfully please post a message in `#event-anz-ocp-virt-hackathon` with the message:
> Please review team [name] solution for exercise 3. Our vm has migrated to node [node name].
> Please review [team name] solution for exercise 3. Our vm has migrated to node [node name].
This exercise is worth 25 points. The event team will reply in slack to confirm your updated team total score.