With declarative configuration, you can update configurations by storing them in files in repositories and apply them to the system. Declarative configuration is useful, for example, if you are using a GitOps workflow. You can currently use declarative configuration in Red Hat Advanced Cluster Security for Kubernetes (RHACS) for authentication and authorization resources such as authentication providers, roles, permission sets, and access scopes.

To use declarative configuration, you create YAML files that contain configuration information about authentication and authorization resources. These files, or configurations, are added to RHACS by using a mount point during Central installation. See the installation documentation in the "Additional references" section for more information on configuring mount points when installing RHACS.

The configuration files used with declarative configuration are stored in config maps or secrets, depending on the type of resource. Store configurations for authentication providers in a secret for greater security. You can store other configurations in config maps.

A single config map or secret can contain more than one configuration of multiple resource types. This allows you to limit the number of volume mounts for the Central instance.

Restrictions for resources created from declarative configuration

Because resources can reference other resources (for example, a role can reference both a permission set and access scope), the following restrictions for references apply:

  • A declarative configuration can only reference a resource that is either also created declaratively or a system RHACS resource; for example, a resource such as the Admin or Analyst system role or permission set.

  • All references between resources use names to identify the resource; therefore, all names within the same resource type must be unique.

  • Resources created from declarative configuration can only be modified or deleted by altering the declarative configuration files. You cannot change these resources by using the RHACS portal or the API.

Creating declarative configurations

Use roxctl to create the YAML files that store the configurations, create a config map from the files, and apply the config map.

  • You have added the mount for the config map or secret during the installation of Central. In this example, the config map is called "declarative-configs". See the installation documentation listed in the "Additional resources" section for more information.

  1. Create the permission set by entering the following command. This example creates a permission set named "restricted" and is saved as the permission-set.yaml file. It sets read and write access for the Administration resource and read access to the Access resource.

    $ roxctl declarative-config create permission-set \
    --name="restricted" \
    --description="Restriction permission set that only allows \
    access to Administration and Access resources" \
    --resource-with-access=Administration=READ_WRITE_ACCESS \
    --resource-with-access=Access=READ_ACCESS > permission-set.yaml
  2. Create the role that allows access to the Administration and Access resources by entering the following command. This example creates a role named "restricted" and is saved as the role.yaml file.

    $ roxctl declarative-config create role \
    --name="restricted" \
    --description="Restricted role that only allows access to Administration and Access" \
    --permission-set="restricted" \
    --access-scope="Unrestricted" > role.yaml
  3. Create a config map from the two YAML files that were created in the earlier steps by entering the following command. This example creates the declarative-configurations config map.

    $ kubectl create configmap declarative-configurations \ (1)
    --from-file permission-set.yaml --from-file role.yaml \
    -o yaml --namespace=stackrox > declarative-configs.yaml
    1 For OpenShift Container Platform, use oc create.
  4. Apply the config map by entering the following command:

    $ kubectl apply -f declarative-configs.yaml (1)
    1 For OpenShift Container Platform, use oc apply.

    After you apply the config map, configuration information extracted from Central creates the resources.

    Although the watch interval is 5 seconds, as described in the following paragraph, there can be a delay in propagating changes from the config map to the Central mount.

    You can configure the following intervals to specify how declarative configurations interact with Central:

    • Configuration watch interval: The interval for Central to check for changes is every 5 seconds. You can configure this interval by using the ROX_DECLARATIVE_CONFIG_WATCH_INTERVAL environment variable.

    • Reconciliation interval: By default, declarative configuration reconciliation with Central occurs every 20 seconds. You can configure this interval by using the ROX_DECLARATIVE_CONFIG_RECONCILE_INTERVAL environment variable.

After creating authentication and authorization resources by using declarative configuration, you can view them in the Access Control page in the RHACS web portal. The Origin field indicates Declarative if the resource was created by using declarative configuration.

You cannot edit resources created from declarative configurations in the RHACS web portal. You must edit the configuration files directly to make changes to these resources.

You can view the status of declarative configurations by navigating to Platform ConfigurationSystem Health and scrolling to the Declarative configuration section.

Declarative configuration examples

You can create declarative configurations by using the following examples as a guide. Use the roxctl declarative-config lint command to verify that your configurations are valid.

Declarative configuration authentication provider example

Declarative configuration authentication provider example
name: A sample auth provider
minimumRole: Analyst (1)
uiEndpoint: central.custom-domain.com:443 (2)
extraUIEndpoints: (3)
    - central-alt.custom-domain.com:443
groups: (4)
    - key: email (5)
      value: example@example.com
      role: Admin (6)
    - key: group
      value: reviewers
      role: Analyst
requiredAttributes: (7)
    - key: org_id
      value: "12345"
oidc: (8)
    issuer: sample.issuer.com (9)
    mode: auto (10)
    clientID: CLIENT_ID
    clientSecret: CLIENT_SECRET
clientSecret: CLIENT_SECRET
iap: (11)
    audience: audience
saml: (12)
    spIssuer: sample.issuer.com
    metadataURL: sample.provider.com/metadata
saml: (13)
    spIssuer: sample.issuer.com
    cert: | (14)
    ssoURL: saml.provider.com
    idpIssuer: idp.issuer.com
    certificateAuthorities: | (15)
    certificate (16)
1 Identifies the minimum role that will be assigned by default to any user logging in. If left blank, the value is None.
2 Use the user interface endpoint of your Central instance.
3 If your Central instance is exposed to different endpoints, specify them here.
4 These fields map users to specific roles, based on their attributes.
5 The key can be any claim returned from the authentication provider.
6 Identifies the role that the users are given. You can use a default role or a declaratively-created role.
7 Optional: Use these fields if attributes returned from the authentication provider are required; for example, if the audience is limited to a specific organization or group.
8 This section is required only for OpenID Connect (OIDC) authentication providers.
9 Identifies the expected issuer for the token.
10 Identifies the OIDC callback mode. Possible values are auto, post, query, and fragment. The preferred value is auto.
11 This section is required only for Google Identity-Aware Proxy (IAP) authentication providers.
12 This section is required only for Security Assertion Markup Language (SAML) 2.0 dynamic configuration authentication providers.
13 This section is required only for SAML 2.0 static configuration authentication providers.
14 Include the certificate in Privacy Enhanced Mail (PEM) format.
15 This section is required only for authentication with user certificates.
16 Include the certificate in PEM format.

Declarative configuration permission set example

Declarative configuration permission set example
name: A sample permission set
description: A sample permission set created declaratively
- resource: Integration (1)
  access: READ_ACCESS  (2)
- resource: Administration
1 For a full list of supported resources, navigate to Access ControlPermission Sets.
2 Access can be either READ_ACCESS or READ_WRITE_ACCESS.

Declarative configuration access scope example

Declarative configuration access scope example
name: A sample access scope
description: A sample access scope created declaratively
        - cluster: secured-cluster-A (1)
            - namespaceA
        - cluster: secured-cluster-B (2)
        - requirements:
            key: kubernetes.io/metadata.name
            operator: IN (3)
            - production
            - staging
            - environment
1 Identifies a cluster where only specific namespaces are included within the access scope.
2 Identifies a cluster where all namespaces are included within the access scope.
3 Identifies the Operator to use for the label selection. Valid values are IN, NOT_IN, EQUAL, EXISTS, and NOT_EXISTS.

Declarative configuration role example

Declarative configuration role example
name: A sample role
description: A sample role created declaratively
permissionSet: A sample permission set (1)
accessScope: Unrestricted (2)
1 Name of the permission set; can be either one of the system permission sets or a declaratively-created permission set.
2 Name of the access scope; can be either one of the system access scopes or a declaratively-created access scope.

Troubleshooting declarative configuration

You can use the error messages displayed in the Declarative configuration section of the Platform ConfigurationSystem Health page to help in troubleshooting. The roxctl declarative-config command also includes a lint option to validate the configuration file and help you detect errors.

The error messages displayed in the Declarative configuration section of the Platform ConfigurationSystem Health page provide information about issues with declarative configurations. Problems with declarative configurations can be caused by the following conditions:

  • The format of the configuration file is not in valid YAML.

  • The configuration file contains invalid values, such as invalid access within a permission set.

  • Invalid storage constraints exist, such as resource names are not unique or the configuration contains invalid references to a resource.

To validate configuration files, check for errors in configuration files, and make sure that there are no invalid storage constraints when creating and updating configuration files, use the roxctl declarative-config lint command.

To troubleshoot a storage constraint during deletion, check if the resource has been marked as Declarative Orphaned. This indicates that the declarative configuration referenced by a resource was deleted (for example, if the declarative configuration for a permission set that was referenced by a role was deleted). To correct this error, edit the resource to point to a new permission set, or restore the declarative configuration that was deleted.