Basic examples

Example #1

Here is an example of a custom rule logic that will ensure only pre-approved values are used (allow-list) with the label key `environment`:

YAML

Every custom rule must be coupled with a specific policy

YAML

And this is how the Policy as code file should look:

policies.yaml

Applying the new policies to your account

Enable PaC mode and publish the policies.yaml configuration (read more)

Dashboard

Terminal

Document image
Document image

Example #2

Here is an example of a custom rule logic that will ensure pre-defined `namespace` values are excluded (block-list):

policies.yaml

The above rule enforces similar logic to our built-in rule - ☑️ Prevent workload from using the default namespace

Example #3

Here is an example of a custom rule logic that will ensure the number of `replicas` is set between 2-10 for resources kind `Deployment`:

policies.yaml

The above rule enforces similar logic to our built-in rule - ☑️ Ensure Deployment has more than one replica configured