Skip to content

Commit 4871da8

Browse files
Merge pull request #85732 from kcarmichael08/ROX-27224-re2
ROX-27224: Update regex info for Collections
2 parents aac19e7 + d77ee9b commit 4871da8

6 files changed

+72
-20
lines changed

images/collection-rules.png

79.8 KB
Loading

modules/create-collection-rules.adoc

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,10 @@ Configure rules to select the resources to include in the collection. Use the pr
1717
.Procedure
1818

1919
. In the *Deployments* section, select one of the following options from the drop-down list:
20-
* *All deployments*: Includes all deployments in the collection. If you select this option, you must filter the collection by using namespaces or clusters or by attaching another collection.
21-
* *Deployments with names matching* Click this option to select by name and then click one of the following options:
22-
** Select *An exact value of* and enter the exact name of the deployment.
23-
** Select *A regex value of* to use regular expression to search for a deployment. This option is useful if you do not know the exact name of the deployment. A regular expression is a string of letters, numbers, and symbols that defines a pattern. {product-title-short} uses this pattern to match characters or groups of characters and return results. For more information about regular expression, see "Regular-Expressions.info" in the "Additional resources" section.
24-
* *Deployments with labels matching exactly*: Click this option to select deployments with labels that match the exact text that you enter. The label must be a valid Kubernetes label in the format of `key=value`.
20+
* *No deployments specified*: Select this option if you do not want to use the deployment criteria in your search.
21+
* *Deployments with names matching*: Select this option to choose by name and then select one of the following options:
22+
** *An exact value of*: Enter the exact name of the deployment.
23+
** *A regex value of*: You can use regular expressions to search for a deployment. This option is useful if you do not know the exact name of the deployment. A regular expression is a string of letters, numbers, and symbols that defines a pattern. {product-title-short} uses this pattern to match characters or groups of characters and return results. For regular expressions, link:https://github.com/google/re2/wiki/Syntax[RE2 syntax] is supported. Perl syntax is not supported. To select _all deployments_, select this option and enter `.*`. See "Using regular expressions" for more information and examples.
24+
* *Deployments with labels matching exactly*: Select this option to select deployments with labels that match the exact text that you enter. The label must be a valid Kubernetes label in the format of `key=value`.
2525
. Optional: To add more deployments with names or labels that match additional criteria for inclusion, click *OR* and configure another exact or regular expression value.
2626

27-
The following example provides the steps for configuring a collection for a medical application. In this example, you want your collection to include the `reporting` deployment, a database called `patient-db`, and you want to select namespaces with labels where `key = kubernetes.io/metadata.name` and `value = medical`. For this example, perform the following steps:
28-
29-
. In *Collection rules*, select *Deployments with names matching*.
30-
. Click *An exact value of* and enter *reporting*.
31-
. Click *OR*.
32-
. Click *A regex value of* and enter `.*-db` to select all deployments with a name ending in `db` in your environment. The `regex value` option uses regular expression for pattern matching; for more information about regular expression, see "Regular-Expressions.info" in the Additional resources section. The panel on the right might display databases that you do not want to include. You can exclude those databases by using additional filters. For example:
33-
.. Filter by namespace labels by clicking *Namespaces with labels matching exactly* and entering `kubernetes.io/metadata.name=medical` to include only deployments in the namespace that is labeled `medical`.
34-
.. If you know the name of the namespace, click *Namespaces with names matching* and enter the name.

modules/create-policy-from-system-policies-view.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ See "Policy criteria" in the "Additional resources" section for more information
8282
Create scopes to restrict or exclude your policy from entities, such as cluster or namespaces, within your environment.
8383

8484
. To restrict by scope, click *Add inclusion scope*. This enables this policy to only be applied for a specific cluster, a namespace, or a deployment label.
85-
You can add multiple scopes and also use regular expression in link:https://github.com/google/re2/wiki/Syntax[RE2 Syntax] for namespaces and labels.
86-
. To exclude by scope, for example, to exclude specific deployments, clusters, namespaces, and deployment labels from the policy, click *Add exclusion scope*. The policy will not apply to the entities that you select. You can add multiple scopes and also use regular expression in link:https://github.com/google/re2/wiki/Syntax[RE2 Syntax] for namespaces and labels. However, you cannot use regular expression for selecting deployments.
85+
You can add multiple scopes and also use regular expressions in link:https://github.com/google/re2/wiki/Syntax[RE2 Syntax] for namespaces and labels.
86+
. To exclude by scope, for example, to exclude specific deployments, clusters, namespaces, and deployment labels from the policy, click *Add exclusion scope*. The policy will not apply to the entities that you select. You can add multiple scopes and also use regular expressions in link:https://github.com/google/re2/wiki/Syntax[RE2 Syntax] for namespaces and labels. However, you cannot use regular expressions for selecting deployments.
8787
+
8888
[NOTE]
8989
====

modules/object-collections.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ You can use collections to identify any group of deployments in your system, suc
1818
* A distributed application that spans multiple namespaces, defined with a common deployment label
1919
* An entire production or test environment
2020
21-
Collections can be created and managed by using the {product-title-short} portal. The collection editor helps you apply selection rules at the deployment, namespace, and cluster level. You can use simple and complex rules, including regular expression.
21+
Collections can be created and managed by using the {product-title-short} portal. The collection editor helps you apply selection rules at the deployment, namespace, and cluster level. You can use simple and complex rules, including regular expressions. For regular expressions, link:https://github.com/google/re2/wiki/Syntax[RE2 syntax] is supported. Perl syntax is not supported.
2222

23-
You can define a collection by selecting one or more deployments, namespaces, or clusters, as shown in the following image. This image shows a collection that contains deployments with the name reporting or that contain `db` in the name. The collection includes deployments matching those names in the namespace with a specific label of `kubernetes.io/metadata.name=medical`, and in clusters named `production`.
23+
You can define a collection by selecting one or more deployments, namespaces, or clusters, as shown in the following image. This image shows a collection that contains deployments with the name `reporting` or that contain `db` in the name. The collection includes deployments matching those names in the namespace with a specific label of `kubernetes.io/metadata.name=medical`, and in clusters named `production`.
2424

2525
image::collection-rules.png[Collection rules showing rules configured for deployments with names matching, namespaces with labels matching exactly, and clusters with names matching]
2626

27-
The collection editor also helps you to describe complex hierarchies by attaching, or nesting, other collections. The editor provides a real-time preview side panel that helps you understand the rules you are applying by showing the resulting matches to the rules that you have configured. The following image provides an example of results from a collection named "Sensitive User Data" with a set of collection rules (not shown). The "Sensitive User Data" collection has two attached collections, "Credit card processors" and "Medical records" and each of those collections have their own collection rules. The results shown in the side panel include items that match the rules configured for all three collections.
27+
The collection editor also helps you to describe complex hierarchies by attaching, or nesting, other collections. The editor provides a real-time preview side panel that helps you understand the rules you are applying by showing the resulting matches to the rules that you have configured. The following image provides an example of results from a collection named "Sensitive User Data" with a set of collection rules (not shown). The "Sensitive User Data" collection has two attached collections, "Credit card processors" and "Medical records", and each of those collections has its own collection rules. The results shown in the side panel include items that match the rules configured for all three collections.
2828

2929
image::collection-side-panel.png[Collection results from configuring a collection with two attached collections]

modules/using-regular-expression.adoc

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operating/create-use-collections.adoc
4+
:_mod-docs-content-type: CONCEPT
5+
[id="using-regular-expression_{context}"]
6+
= Using regular expressions
7+
8+
{product-title-short} uses regular expressions in some areas of the portal, including when you configure collections to include or exclude deployments.
9+
10+
For example, when configuring a collection, you can use regular expressions to search for a deployment. This option is useful if you do not know the exact name of the deployment. A regular expression is a string of letters, numbers, and symbols that defines a pattern. {product-title-short} uses this pattern to match characters or groups of characters and return results. For regular expressions, note the following guidelines:
11+
12+
* link:https://github.com/google/re2/wiki/Syntax[RE2 syntax] is supported.
13+
* Perl syntax is not supported.
14+
* Testing your regular expressions syntax is helpful, for example, by using a site such as link:https://regex101.com/[https://regex101.com/]. Select *Golang* as the flavor.
15+
16+
[NOTE]
17+
====
18+
The following examples assume naming conventions are followed where production clusters contain the word `prod` in the name.
19+
====
20+
21+
.Regular expressions example to create a collection of production clusters
22+
23+
. In *Collection rules*, select *Clusters with names matching*.
24+
. From the drop-down list, select *A regex value of* and enter the following text:
25+
+
26+
----
27+
^prod.*
28+
----
29+
30+
.Regular expressions example to create a collection of non-production clusters
31+
32+
With RE2 syntax, you cannot match by using negative lookahead, meaning that you cannot direct regular expressions to match if an element is *not* present. As a workaround, you can use regular expressions to match when the word `prod` does not appear in the cluster name; that is, to match if the letters `p`, `r`, `o`, and `d` do not appear in sequence.
33+
34+
. In *Collection rules*, select *Clusters with names matching*.
35+
. From the drop-down list, select *A regex value of* and enter the following text:
36+
+
37+
----
38+
^[^p]*(p([^r]|$|r([^o]|$|o([^d]|$))))*[^p]*$
39+
----
40+
41+
.Regular expressions example to create a collection that matches all entities in the cluster, namespace, and deployments hierarchy
42+
43+
. In *Collection rules*, select *Deployments with names matching*.
44+
.. From the drop-down list, select *A regex value of* and enter `.*`.
45+
. Select *Namespaces with names matching*.
46+
.. From the drop-down list, select *A regex value of* and enter `.*`.
47+
. Select *Clusters with names matching*.
48+
.. From the drop-down list, select *A regex value of* and enter `.*`.
49+
50+
.Regular expressions example to create a collection that includes a named deployment and database and specific labels
51+
52+
The following example provides the steps for configuring a collection for a medical application. In this example, you want your collection to include the `reporting` deployment, a database called `patient-db`, and you want to select namespaces with labels where `key = kubernetes.io/metadata.name` and `value = medical`. For this example, perform the following steps:
53+
54+
. In *Collection rules*, select *Deployments with names matching*.
55+
. Click *An exact value of* and enter *reporting*.
56+
. Click *OR*.
57+
. Click *A regex value of* and enter `.*-db` to select all deployments with a name ending in `db` in your environment. The `regex value` option uses regular expressions for pattern matching. For regular expressions, link:https://github.com/google/re2/wiki/Syntax[RE2 syntax] is supported. Perl syntax is not supported. The panel on the right might display databases that you do not want to include. You can exclude those databases by using additional filters. For example:
58+
.. Filter by namespace labels by clicking *Namespaces with labels matching exactly* and entering `kubernetes.io/metadata.name=medical` to include only deployments in the namespace that is labeled `medical`.
59+
.. If you know the name of the namespace, click *Namespaces with names matching* and enter the name.

operating/create-use-collections.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ include::modules/create-object-collections.adoc[leveloffset=+1]
3939

4040
include::modules/create-collection-rules.adoc[leveloffset=+2]
4141

42+
include::modules/using-regular-expression.adoc[leveloffset=+3]
43+
4244
include::modules/adding-attached-collections.adoc[leveloffset=+2]
4345

4446
include::modules/migrate-scope-collections.adoc[leveloffset=+1]
@@ -53,5 +55,4 @@ You can configure collections by using the `CollectionService` API object. For e
5355

5456
* xref:../operating/manage-user-access/manage-role-based-access-control-3630.adoc#manage-role-based-access-control[Managing RBAC in {product-title-short}]
5557
* xref:../operating/manage-vulnerabilities/vulnerability-reporting.adoc#vulnerability-reporting[Vulnerability reporting]
56-
//The RH CloudForms docs use this site as a reference. Other suggestions welcome. Most of the Red{nbsp}Hat sites have a lot of info about using regex with grep, etc. that doesn't apply here.
57-
* Using regular expression: link:https://www.regular-expressions.info/[Regular-Expressions.info]
58+
* link:https://github.com/google/re2/wiki/Syntax[RE2 regular expression syntax]

0 commit comments

Comments
 (0)