You create a validation rule by applying a config map custom resource (CR) containing the rule to the Validation
service.
Important
|
|
Validation rules are based on virtual machine (VM) attributes collected by the Provider Inventory
service.
For example, the VMware API uses this path to check whether a VMware VM has NUMA node affinity configured: MOR:VirtualMachine.config.extraConfig["numa.nodeAffinity"]
.
The Provider Inventory
service simplifies this configuration and returns a testable attribute with a list value:
"numaNodeAffinity": [
"0",
"1"
],
You create a Rego query, based on this attribute, and add it to the forklift-validation-config
config map:
`count(input.numaNodeAffinity) != 0`
-
Create a config map CR according to the following example:
$ cat << EOF | {oc} apply -f - apiVersion: v1 kind: ConfigMap metadata: name: <forklift-validation-config> namespace: {namespace} data: vmware_multiple_disks.rego: |- package <provider_package> (1) has_multiple_disks { (2) count(input.disks) > 1 } concerns[flag] { has_multiple_disks (3) flag := { "category": "<Information>", (4) "label": "Multiple disks detected", "assessment": "Multiple disks detected on this VM." } } EOF
-
Specify the provider package name. Allowed values are
io.konveyor.forklift.vmware
for VMware andio.konveyor.forklift.ovirt
for {rhv-full}. -
Specify the
concerns
name and Rego query. -
Specify the
concerns
name andflag
parameter values. -
Allowed values are
Critical
,Warning
, andInformation
.
-
-
Stop the
Validation
pod by scaling theforklift-controller
deployment to0
:$ {oc} scale -n {namespace} --replicas=0 deployment/forklift-controller
-
Start the
Validation
pod by scaling theforklift-controller
deployment to1
:$ {oc} scale -n {namespace} --replicas=1 deployment/forklift-controller
-
Check the
Validation
pod log to verify that the pod started:$ {oc} logs -f <validation_pod>
If the custom rule conflicts with a default rule, the
Validation
pod will not start. -
Remove the source provider:
$ {oc} delete provider <provider> -n {namespace}
-
Add the source provider to apply the new rule:
$ cat << EOF | {oc} apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Provider metadata: name: <provider> namespace: {namespace} spec: type: <provider_type> (1) url: <api_end_point> (2) secret: name: <secret> (3) namespace: {namespace} EOF
-
Allowed values are
ovirt
,vsphere
, andopenstack
. -
Specify the API end point URL, for example,
https://<vCenter_host>/sdk
for vSphere,https://<engine_host>/ovirt-engine/api
for {rhv-short}, orhttps://<identity_service>/v3
for {osp}. -
Specify the name of the provider
Secret
CR.
-
You must update the rules version after creating a custom rule so that the Inventory
service detects the changes and validates the VMs.