Create Constraint
This section describes how to create a constraint.
Prerequisites
-
You need to join a cluster and have the cluster-admin permission in the cluster. For more information, see Cluster Members and Cluster Roles.
-
The KubeSphere platform needs to have the Gatekeeper extension installed and enabled.
-
A constraint template has been created.
Steps
-
Log in to the KubeSphere web console with a user who has cluster-admin permissions and enter your cluster.
-
Click Gatekeeper > Constraints in the left navigation pane.
-
Click Create on the page.
-
In the Create Constraint dialog box, set the following parameters, then click OK.
Parameter Description Constraint Name
The name of the constraint.
Constraint Type
The constraint template used by the constraint.
enforcementAction
The
enforcementActionfield defines the action to take for constraint violations. It is set todenyby default, meaning any admission request that violates the constraint is denied by default. For more information, refer to Constraint Violation Handling.Match Kinds
The
matchfield defines the resources to which the constraint applies. For more information, refer to match.kindsaccepts a list of objects containingapiGroupsandkindsfields, which list the groups/kinds of objects the constraint applies to. If multiple groups/kinds objects are specified, a resource is in scope for the constraint if it matches any one of those objects.Namespace Labels
Identifiable key-value pairs set for the namespace where the object resides or for the object itself if the object is a namespace.
Parameters
Used to describe the intent of the constraint. For more information, refer to parameters.
You can view the created constraint on the Constraints page.