16.2. 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.
For OpenShift Container Platform, use oc instead of kubectl.
Prerequisites
- 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.
Procedure
Create the permission set by entering the following command. This example creates a permission set named "restricted" and is saved as the
permission-set.yamlfile. It sets read and write access for theAdministrationresource 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.yamlCreate the role that allows access to the
AdministrationandAccessresources by entering the following command. This example creates a role named "restricted" and is saved as therole.yamlfile.$ 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.yamlCreate 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-configurationsconfig map.$ kubectl create configmap declarative-configurations \ --from-file permission-set.yaml --from-file role.yaml \ -o yaml --namespace=stackrox > declarative-configs.yamlApply the config map by entering the following command:
$ kubectl apply -f declarative-configs.yamlAfter 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_INTERVALenvironment 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_INTERVALenvironment variable.
-
Configuration watch interval: The interval for Central to check for changes is every 5 seconds. You can configure this interval by using the
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 Configuration