Watchdog devices monitor guest operating system responsiveness and trigger recovery actions when a virtual machine becomes unresponsive.
A watchdog device continuously monitors the agent running on a virtual machine (VM). When the guest operating system becomes unresponsive, the watchdog can trigger one of three recovery actions depending on how it is configured.
The poweroff action causes the VM to power down immediately. If spec.runStrategy is not set to manual, the VM automatically reboots after powering down.
The reset action reboots the VM in place without allowing the guest operating system to react. When using the reset action, be aware that the reboot time might cause liveness probes to time out. If cluster-level protections detect a failed liveness probe, the VM might be forcibly rescheduled, which increases the overall reboot time.
The shutdown action initiates a graceful shutdown by stopping all services before powering down the VM.
|
|
Watchdog functionality is not available for Windows VMs.
|
To implement watchdog functionality, you must configure the watchdog device for the VM and install the watchdog agent on the guest operating system.
Configuring a watchdog device for the virtual machine
You configure a watchdog device for the virtual machine (VM).
Prerequisites
-
For x86 systems, the VM must use a kernel that works with the i6300esb watchdog device. If you use s390x architecture, the kernel must be enabled for diag288. Fedora images support i6300esb and diag288.
-
You have installed the OpenShift CLI (oc).
Procedure
-
Create a YAML file with the following contents:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: <vm-label>
name: <vm-name>
spec:
runStrategy: Halted
template:
metadata:
labels:
kubevirt.io/vm: <vm-label>
spec:
domain:
devices:
watchdog:
name: <watchdog>
<watchdog-device-model>:
action: "poweroff"
# ...
-
spec.template.spec.domain.devices.watchdog.name.<watchdog-device-model> defines the watchdog device model to use. For x86 specify i6300esb. For s390x specify diag288.
-
spec.template.spec.domain.devices.watchdog.name.<watchdog-device-model>.action defines the watchdog device action. Specify poweroff, reset, or shutdown. The shutdown action requires that the guest virtual machine is responsive to ACPI signals. Using shutdown is not recommended.
The example above configures the watchdog device on a VM with the poweroff action and exposes the device as /dev/watchdog.
This device can now be used by the watchdog binary.
-
Apply the YAML file to your cluster by running the following command:
$ oc apply -f <file_name>.yaml
Verification
-
Run the following command to verify that the VM is connected to the watchdog device:
|
|
Verification steps are provided for testing watchdog functionality only and must not be run on production machines.
|
$ lspci | grep watchdog -i
-
Run one of the following commands to confirm the watchdog is active:
Installing the watchdog agent on the guest
You can install the watchdog agent on the guest and start the watchdog service.
Procedure
-
Log in to the virtual machine as root user.
-
This step is only required when installing on IBM Z® (s390x). Enable watchdog by running the following command:
-
Verify that the /dev/watchdog file path is present in the VM by running the following command:
-
Install the watchdog package and its dependencies:
-
Uncomment the following line in the /etc/watchdog.conf file and save the changes:
#watchdog-device = /dev/watchdog
-
Enable the watchdog service to start on boot:
# systemctl enable --now watchdog.service