KOP OPA GateKeeper - Constraints - Rafay Product Documentation

Constraints

Constraints are used to notify Gatekeeper that a Constraint Template needs to be enforced. It also specifies the 'how' by passing the required parameters. Constraint spec is used to select the enforcement action (deny, warn or dryrun). By default, it is set to deny i.e. any admission requests that result in violations are denied.


Step 1: Create New Constraint

Perform the below steps to create a new constraint:

All constraints are version-controlled so that the lifecycle can be properly managed. In this example, the admin has not yet configured anything. So, no versions are available as yet.

Important
Constraints created before versioning was introduced will have Initial as the version name.

Step 2: New Version

Below is an example of a constraint code set to 3 minimum replicas and 50 maximum replicas. Applications that enter with less than 3 replicas and more than 50 replicas are not allowed.

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sReplicaLimits
metadata:
  name: replica-limits
spec:
  match:
    kinds:
      - apiGroups: ["apps"]
        kinds: ["Deployment"]
  parameters:
    ranges:
    - min_replicas: 3
      max_replicas: 50

Edit / Delete Constraints


Constraint Types

Two types of Constraints are Custom and System:

Important
Users with Namespace Admin role do not have access to Constraints page.


Back to top