17.4. Creating deployment collections


When creating a collection, you must name it and define the rules for the collection.

Procedure

  1. In the Collections page, click Create collection.
  2. Enter the name and description for the collection.
  3. In the Collection rules section, you must perform at least one of the following actions:

    • Define the rules for the collection: See the "Creating collection rules" section for more information.
    • Attach existing collections to the collection: See the "Adding attached collections" section for more information.
  4. The results of your rule configuration or choosing attached collections are available in the Collection results live preview panel. Click Hide results to remove this panel from display.
  5. Click Save.

17.4.1. Creating collection rules

When creating collections, you must configure at least one rule or attach another collection to the new collection that you are creating.

注意

Currently, collections are available only for deployments.

Configure rules to select the resources to include in the collection. Use the preview panel to see the results of the collection rules as you configure them. You can configure rules in any order.

Procedure

  1. In the Deployments section, select one of the following options from the drop-down list:

    • No deployments specified: Select this option if you do not want to use the deployment criteria in your search.
    • Deployments with names matching: Select this option to choose by name and then select one of the following options:

      • An exact value of: Enter the exact name of the deployment.
      • 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. RHACS uses this pattern to match characters or groups of characters and return results. For regular expressions, 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.
    • 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.
  2. 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.

17.4.1.1. Using regular expressions

RHACS uses regular expressions in some areas of the portal, including when you configure collections to include or exclude deployments.

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. RHACS uses this pattern to match characters or groups of characters and return results. For regular expressions, note the following guidelines:

  • RE2 syntax is supported.
  • Perl syntax is not supported.
  • Testing your regular expressions syntax is helpful, for example, by using a site such as https://regex101.com/. Select Golang as the flavor.
注意

The following examples assume naming conventions are followed where production clusters contain the word prod in the name.

Regular expressions example to create a collection of production clusters

  1. In Collection rules, select Clusters with names matching.
  2. From the drop-down list, select A regex value of and enter the following text:

    ^prod.*

Regular expressions example to create a collection of non-production clusters

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.

  1. In Collection rules, select Clusters with names matching.
  2. From the drop-down list, select A regex value of and enter the following text:

    ^[^p]*(p([^r]|$|r([^o]|$|o([^d]|$))))*[^p]*$

Regular expressions example to create a collection that matches all entities in the cluster, namespace, and deployments hierarchy

  1. In Collection rules, select Deployments with names matching.

    1. From the drop-down list, select A regex value of and enter .*.
  2. Select Namespaces with names matching.

    1. From the drop-down list, select A regex value of and enter .*.
  3. Select Clusters with names matching.

    1. From the drop-down list, select A regex value of and enter .*.

Regular expressions example to create a collection that includes a named deployment and database and specific labels

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:

  1. In Collection rules, select Deployments with names matching.
  2. Click An exact value of and enter reporting.
  3. Click OR.
  4. 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, 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:

    1. 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.
    2. If you know the name of the namespace, click Namespaces with names matching and enter the name.

17.4.2. Adding attached collections

Grouping collections and adding them to other collections can be useful if you want to create small collections based on deployments. You can reuse and combine those smaller collections into larger, hierarchical collections. To add additional collections to a collection that you are creating:

  1. Perform one of the following actions:

    • Enter text in the Filter by name field and press to view matching results.
    • Click the name of a collection from the Available collections list to view information about the collection, such as the name and rules for the collection and the deployments that match that collection.
  2. After viewing collection information, close the window to return to the Attached collections page.
  3. Click +Attach. The Attached collections section lists the collections that you attached.

    注意

    When you add an attached collection, the attached collection contains results based on the configured selection rules. For example, if an attached collection includes resources that would be filtered out by the rules used in the parent collection, then those items are still added to the parent collection because of the rules in the attached collection. Attached collections extend the original collection using an OR operator.

  4. Click Save.
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部