mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
59 lines
2.1 KiB
Plaintext
59 lines
2.1 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/support/virt-monitoring-vm-health.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="virt-define-http-liveness-probe_{context}"]
|
|
|
|
= Defining an HTTP liveness probe
|
|
|
|
Define an HTTP liveness probe by setting the `spec.livenessProbe.httpGet` field of the virtual machine (VM) configuration. You can define both HTTP and TCP tests for liveness probes in the same way as readiness probes. This procedure configures a sample liveness probe with an HTTP GET test.
|
|
|
|
.Prerequisites
|
|
|
|
* You have installed the {oc-first}.
|
|
|
|
.Procedure
|
|
|
|
. Include details of the HTTP liveness probe in the VM configuration file.
|
|
+
|
|
|
|
.Sample liveness probe with an HTTP GET test
|
|
[source,yaml]
|
|
----
|
|
apiVersion: kubevirt.io/v1
|
|
kind: VirtualMachine
|
|
metadata:
|
|
annotations:
|
|
name: fedora-vm
|
|
namespace: example-namespace
|
|
# ...
|
|
spec:
|
|
template:
|
|
spec:
|
|
livenessProbe:
|
|
initialDelaySeconds: 120 <1>
|
|
periodSeconds: 20 <2>
|
|
httpGet: <3>
|
|
port: 1500 <4>
|
|
path: /healthz <5>
|
|
httpHeaders:
|
|
- name: Custom-Header
|
|
value: Awesome
|
|
timeoutSeconds: 10 <6>
|
|
# ...
|
|
----
|
|
<1> The time, in seconds, after the VM starts before the liveness probe is initiated.
|
|
<2> The delay, in seconds, between performing probes. The default delay is 10 seconds. This value must be greater than `timeoutSeconds`.
|
|
<3> The HTTP GET request to perform to connect to the VM.
|
|
<4> The port of the VM that the probe queries. In the above example, the probe queries port 1500. The VM installs and runs a minimal HTTP server on port 1500 via cloud-init.
|
|
<5> The path to access on the HTTP server. In the above example, if the handler for the server's `/healthz` path returns a success code, the VM is considered to be healthy. If the handler returns a failure code, the VM is deleted and a new VM is created.
|
|
<6> The number of seconds of inactivity after which the probe times out and the VM is assumed to have failed. The default value is 1. This value must be lower than `periodSeconds`.
|
|
|
|
. Create the VM by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc create -f <file_name>.yaml
|
|
----
|