Skip to content

Commit 8f6b329

Browse files
author
Shikha Jhala
committed
CNV-21825: latency checkup permissions and API update
1 parent 7da6eeb commit 8f6b329

File tree

3 files changed

+58
-117
lines changed

3 files changed

+58
-117
lines changed

modules/virt-about-cluster-checkup-framework.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
A _checkup_ is an automated test workload that allows you to verify if a specific cluster functionality works as expected. The cluster checkup framework uses native Kubernetes resources to configure and execute the checkup.
1010

11-
By using predefined checkups, cluster administrators can improve cluster maintainability, troubleshoot unexpected behavior, minimize errors, and save time. They can also review the results of the checkup and share them with experts for further analysis. Vendors can write and publish checkups for features or services that they provide and verify that their customer environments are configured correctly.
11+
By using predefined checkups, cluster administrators and developers can improve cluster maintainability, troubleshoot unexpected behavior, minimize errors, and save time. They can also review the results of the checkup and share them with experts for further analysis. Vendors can write and publish checkups for features or services that they provide and verify that their customer environments are configured correctly.
1212

13-
Running a predefined checkup in the cluster involves setting up the namespace and service account for the framework, creating the `ClusterRole` and `ClusterRoleBinding` objects for the service account, enabling permissions for the checkup, and creating the input config map and the checkup job. You can run a checkup multiple times.
13+
Running a predefined checkup in an existing namespace involves setting up a service account for the checkup, creating the `Role` and `RoleBinding` objects for the service account, enabling permissions for the checkup, and creating the input config map and the checkup job. You can run a checkup multiple times.
1414

1515
[IMPORTANT]
1616
====
1717
You must always:
1818
1919
* Verify that the checkup image is from a trustworthy source before applying it.
20-
* Review the checkup permissions before creating the `ClusterRole` and `Role` objects.
21-
* Verify the name of the `ServiceAccount` in the config map. This is because the framework automatically binds these permissions to the checkup instance.
20+
* Review the checkup permissions before creating the `Role` and `RoleBinding` objects.
2221
====

modules/virt-measuring-latency-vm-secondary-network.adoc

Lines changed: 54 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[id="virt-measuring-latency-vm-secondary-network_{context}"]
77
= Checking network connectivity and latency for virtual machines on a secondary network
88

9-
As a cluster administrator, you use a predefined checkup to verify network connectivity and measure latency between virtual machines (VMs) that are attached to a secondary network interface.
9+
You use a predefined checkup to verify network connectivity and measure latency between two virtual machines (VMs) that are attached to a secondary network interface.
1010

1111
To run a checkup for the first time, follow the steps in the procedure.
1212

@@ -15,87 +15,12 @@ If you have previously run a checkup, skip to step 5 of the procedure because th
1515
.Prerequisites
1616

1717
* You installed the OpenShift CLI (`oc`).
18-
* You logged in to the cluster as a user with the `cluster-admin` role.
1918
* The cluster has at least two worker nodes.
2019
* The Multus Container Network Interface (CNI) plug-in is installed on the cluster.
2120
* You configured a network attachment definition for a namespace.
2221
2322
.Procedure
2423

25-
. Create a configuration file that contains the resources to set up the framework. This includes a namespace and service account for the framework, and the `ClusterRole` and `ClusterRoleBinding` objects to define permissions for the service account.
26-
+
27-
.Example framework manifest file
28-
[%collapsible]
29-
====
30-
[source,yaml]
31-
----
32-
---
33-
apiVersion: v1
34-
kind: Namespace
35-
metadata:
36-
name: kiagnose
37-
---
38-
apiVersion: v1
39-
kind: ServiceAccount
40-
metadata:
41-
name: kiagnose
42-
namespace: kiagnose
43-
---
44-
apiVersion: rbac.authorization.k8s.io/v1
45-
kind: ClusterRole
46-
metadata:
47-
name: kiagnose
48-
rules:
49-
- apiGroups: [ "" ]
50-
resources: [ "configmaps" ]
51-
verbs:
52-
- get
53-
- list
54-
- create
55-
- update
56-
- patch
57-
- delete
58-
- apiGroups: [ "rbac.authorization.k8s.io" ]
59-
resources:
60-
- roles
61-
- rolebindings
62-
verbs:
63-
- get
64-
- list
65-
- create
66-
- delete
67-
- apiGroups: [ "batch" ]
68-
resources: [ "jobs" ]
69-
verbs:
70-
- get
71-
- list
72-
- create
73-
- delete
74-
- watch
75-
---
76-
apiVersion: rbac.authorization.k8s.io/v1
77-
kind: ClusterRoleBinding
78-
metadata:
79-
name: kiagnose
80-
roleRef:
81-
apiGroup: rbac.authorization.k8s.io
82-
kind: ClusterRole
83-
name: kiagnose
84-
subjects:
85-
- kind: ServiceAccount
86-
name: kiagnose
87-
namespace: kiagnose
88-
...
89-
----
90-
====
91-
92-
. Apply the framework manifest:
93-
+
94-
[source,terminal]
95-
----
96-
$ oc apply -f <framework_manifest>.yaml
97-
----
98-
9924
. Create a manifest file that contains the `ServiceAccount`, `Role`, and `RoleBinding` objects with permissions that the checkup requires for cluster access:
10025
+
10126
.Example role manifest file
@@ -108,13 +33,11 @@ apiVersion: v1
10833
kind: ServiceAccount
10934
metadata:
11035
name: vm-latency-checkup-sa
111-
namespace: <target_namespace> <1>
11236
---
11337
apiVersion: rbac.authorization.k8s.io/v1
11438
kind: Role
11539
metadata:
11640
name: kubevirt-vm-latency-checker
117-
namespace: <target_namespace>
11841
rules:
11942
- apiGroups: ["kubevirt.io"]
12043
resources: ["virtualmachineinstances"]
@@ -130,24 +53,44 @@ apiVersion: rbac.authorization.k8s.io/v1
13053
kind: RoleBinding
13154
metadata:
13255
name: kubevirt-vm-latency-checker
133-
namespace: <target_namespace>
13456
subjects:
13557
- kind: ServiceAccount
13658
name: vm-latency-checkup-sa
13759
roleRef:
13860
kind: Role
13961
name: kubevirt-vm-latency-checker
14062
apiGroup: rbac.authorization.k8s.io
63+
---
64+
apiVersion: rbac.authorization.k8s.io/v1
65+
kind: Role
66+
metadata:
67+
name: kiagnose-configmap-access
68+
rules:
69+
- apiGroups: [ "" ]
70+
resources: [ "configmaps" ]
71+
verbs: ["get", "update"]
72+
---
73+
apiVersion: rbac.authorization.k8s.io/v1
74+
kind: RoleBinding
75+
metadata:
76+
name: kiagnose-configmap-access
77+
subjects:
78+
- kind: ServiceAccount
79+
name: vm-latency-checkup-sa
80+
roleRef:
81+
kind: Role
82+
name: kiagnose-configmap-access
83+
apiGroup: rbac.authorization.k8s.io
14184
----
14285
====
143-
<1> Specify the namespace where the checkup is to be executed. This must be an existing namespace where the `NetworkAttachmentDefinition` object resides.
14486
14587
. Apply the checkup roles manifest:
14688
+
14789
[source,terminal]
14890
----
149-
$ oc apply -f <latency_roles>.yaml
91+
$ oc apply -n <target_namespace> -f <latency_roles>.yaml <1>
15092
----
93+
<1> `<target_namespace>` is the namespace where the checkup is to be run. This must be an existing namespace where the `NetworkAttachmentDefinition` object resides.
15194
15295
. Create a `ConfigMap` manifest that contains the input parameters for the checkup. The config map provides the input for the framework to run the checkup and also stores the results of the checkup.
15396
+
@@ -158,31 +101,26 @@ apiVersion: v1
158101
kind: ConfigMap
159102
metadata:
160103
name: kubevirt-vm-latency-checkup-config
161-
namespace: <target_namespace> <1>
162104
data:
163-
spec.image: registry.redhat.io/container-native-virtualization/vm-network-latency-checkup:v4.12.0
164105
spec.timeout: 5m
165-
spec.serviceAccountName: vm-latency-checkup-sa
166-
spec.param.network_attachment_definition_namespace: <target_namespace> <2>
167-
spec.param.network_attachment_definition_name: "bridge-network" <3>
168-
spec.param.max_desired_latency_milliseconds: "10" <4>
169-
spec.param.sample_duration_seconds: "5" <5>
170-
spec.param.source_node: "worker1" <6>
171-
spec.param.target_node: "worker2" <7>
172-
----
173-
<1> The namespace where the checkup is to be executed. This must be an existing namespace where the `NetworkAttachmentDefinition` object resides.
174-
<2> The namespace where the `NetworkAttachmentDefinition` object resides.
175-
<3> The name of the `NetworkAttachmentDefinition` object.
176-
<4> Optional: The maximum desired latency, in milliseconds, between the virtual machines. If the measured latency exceeds this value, the checkup fails.
177-
<5> Optional: The duration of the latency check, in seconds.
178-
<6> Optional: When specified, latency is measured from this node to the target node. If the source node is specified, the `spec.param.target_node` field cannot be empty.
179-
<7> Optional: When specified, latency is measured from the source node to this node.
180-
181-
. Apply the config map manifest in the framework’s namespace:
106+
spec.param.network_attachment_definition_namespace: <target_namespace>
107+
spec.param.network_attachment_definition_name: "blue-network" <1>
108+
spec.param.max_desired_latency_milliseconds: "10" <2>
109+
spec.param.sample_duration_seconds: "5" <3>
110+
spec.param.source_node: "worker1" <4>
111+
spec.param.target_node: "worker2" <5>
112+
----
113+
<1> The name of the `NetworkAttachmentDefinition` object.
114+
<2> Optional: The maximum desired latency, in milliseconds, between the virtual machines. If the measured latency exceeds this value, the checkup fails.
115+
<3> Optional: The duration of the latency check, in seconds.
116+
<4> Optional: When specified, latency is measured from this node to the target node. If the source node is specified, the `spec.param.target_node` field cannot be empty.
117+
<5> Optional: When specified, latency is measured from the source node to this node.
118+
119+
. Apply the config map manifest in the target namespace:
182120
+
183121
[source,terminal]
184122
----
185-
$ oc apply -f <latency_config_map>.yaml
123+
$ oc apply -n <target_namespace> -f <latency_config_map>.yaml
186124
----
187125
188126
. Create a `Job` object to run the checkup:
@@ -194,16 +132,22 @@ apiVersion: batch/v1
194132
kind: Job
195133
metadata:
196134
name: kubevirt-vm-latency-checkup
197-
namespace: kiagnose
198135
spec:
199136
backoffLimit: 0
200137
template:
201138
spec:
202-
serviceAccount: kiagnose
139+
serviceAccountName: vm-latency-checkup-sa
203140
restartPolicy: Never
204141
containers:
205-
- name: framework
206-
image: registry.redhat.io/container-native-virtualization/checkup-framework:v4.12.0
142+
- name: vm-latency-checkup
143+
image: registry.redhat.io/container-native-virtualization/vm-network-latency-checkup:v4.12.0
144+
securityContext:
145+
allowPrivilegeEscalation: false
146+
capabilities:
147+
drop: ["ALL"]
148+
runAsNonRoot: true
149+
seccompProfile:
150+
type: "RuntimeDefault"
207151
env:
208152
- name: CONFIGMAP_NAMESPACE
209153
value: <target_namespace>
@@ -215,14 +159,14 @@ spec:
215159
+
216160
[source,terminal]
217161
----
218-
$ oc apply -f <latency_job>.yaml
162+
$ oc apply -n <target_namespace> -f <latency_job>.yaml
219163
----
220164
221165
. Wait for the job to complete:
222166
+
223167
[source,terminal]
224168
----
225-
$ oc wait job kubevirt-vm-latency-checkup -n kiagnose --for condition=complete --timeout 6m
169+
$ oc wait job kubevirt-vm-latency-checkup -n <target_namespace> --for condition=complete --timeout 6m
226170
----
227171
228172
. Review the results of the latency checkup by running the following command. If the maximum measured latency is greater than the value of the `spec.param.max_desired_latency_milliseconds` attribute, the checkup fails and returns an error.
@@ -241,11 +185,9 @@ metadata:
241185
name: kubevirt-vm-latency-checkup-config
242186
namespace: <target_namespace>
243187
data:
244-
spec.image: registry.redhat.io/container-native-virtualization/vm-network-latency-checkup:v4.12.0
245188
spec.timeout: 5m
246-
spec.serviceAccountName: vm-latency-checkup-sa
247189
spec.param.network_attachment_definition_namespace: <target_namespace>
248-
spec.param.network_attachment_definition_name: "bridge-network"
190+
spec.param.network_attachment_definition_name: "blue-network"
249191
spec.param.max_desired_latency_milliseconds: "10"
250192
spec.param.sample_duration_seconds: "5"
251193
spec.param.source_node: "worker1"
@@ -267,14 +209,14 @@ data:
267209
+
268210
[source,terminal]
269211
----
270-
$ oc logs job.batch/kubevirt-vm-latency-checkup -n kiagnose
212+
$ oc logs job.batch/kubevirt-vm-latency-checkup -n <target_namespace>
271213
----
272214
273215
. Delete the job and config map resources that you previously created by running the following commands:
274216
+
275217
[source,terminal]
276218
----
277-
$ oc delete job -n kiagnose kubevirt-vm-latency-checkup
219+
$ oc delete job -n <target_namespace> kubevirt-vm-latency-checkup
278220
----
279221
+
280222
[source,terminal]

virt/logging_events_monitoring/virt-running-cluster-checkups.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
{VirtProductName} {VirtVersion} includes a diagnostic framework to run predefined checkups that can be used for cluster maintenance and troubleshooting.
9+
{VirtProductName} includes predefined checkups that can be used for cluster maintenance and troubleshooting.
1010

1111
:FeatureName: The {product-title} cluster checkup framework
1212
include::snippets/technology-preview.adoc[]

0 commit comments

Comments
 (0)