This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.12.5. Monitoring virtual machine health
Use this procedure to create liveness and readiness probes to monitor virtual machine health.
12.5.1. About liveness and readiness probes 复制链接链接已复制到粘贴板!
When a VirtualMachineInstance (VMI) fails, liveness probes stop the VMI. Controllers such as VirtualMachine then spawn other VMIs, restoring virtual machine responsiveness.
Readiness probes tell services and endpoints that the VirtualMachineInstance is ready to receive traffic from services. If readiness probes fail, the VirtualMachineInstance is removed from applicable endpoints until the probe recovers.
12.5.2. Define an HTTP liveness probe 复制链接链接已复制到粘贴板!
This procedure provides an example configuration file for defining HTTP liveness probes.
Procedure
Customize a YAML configuration file to create an HTTP liveness probe, using the following code block as an example. In this example:
-
You configure a probe using
spec.livenessProbe.httpGet, which queries port1500of the virtual machine instance, after an initial delay of120seconds. -
The virtual machine instance installs and runs a minimal HTTP server on port
1500usingcloud-init.
注意The
timeoutSecondsvalue must be lower than theperiodSecondsvalue. ThetimeoutSecondsdefault value is1. TheperiodSecondsdefault value is10.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
You configure a probe using
Create the VirtualMachineInstance by running the following command:
oc create -f <file name>.yaml
$ oc create -f <file name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.3. Define a TCP liveness probe 复制链接链接已复制到粘贴板!
This procedure provides an example configuration file for defining TCP liveness probes.
Procedure
Customize a YAML configuration file to create an TCP liveness probe, using this code block as an example. In this example:
-
You configure a probe using
spec.livenessProbe.tcpSocket, which queries port1500of the virtual machine instance, after an initial delay of120seconds. -
The virtual machine instance installs and runs a minimal HTTP server on port
1500usingcloud-init.
注意The
timeoutSecondsvalue must be lower than theperiodSecondsvalue. ThetimeoutSecondsdefault value is1. TheperiodSecondsdefault value is10.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
You configure a probe using
Create the VirtualMachineInstance by running the following command:
oc create -f <file name>.yaml
$ oc create -f <file name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.4. Define a readiness probe 复制链接链接已复制到粘贴板!
This procedure provides an example configuration file for defining readiness probes.
Procedure
Customize a YAML configuration file to create a readiness probe. Readiness probes are configured in a similar manner to liveness probes. However, note the following differences in this example:
-
Readiness probes are saved using a different spec name. For example, you create a readiness probe as
spec.readinessProbeinstead of asspec.livenessProbe.<type-of-probe>. -
When creating a readiness probe, you optionally set a
failureThresholdand asuccessThresholdto switch betweenreadyandnon-readystates, should the probe succeed or fail multiple times.
注意The
timeoutSecondsvalue must be lower than theperiodSecondsvalue. ThetimeoutSecondsdefault value is1. TheperiodSecondsdefault value is10.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Readiness probes are saved using a different spec name. For example, you create a readiness probe as
Create the VirtualMachineInstance by running the following command:
oc create -f <file name>.yaml
$ oc create -f <file name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow