This section describes how to create a constraint template.

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.

Steps

  1. Log in to the KubeSphere web console with a user who has cluster-admin permissions and enter your cluster.

  2. Click Gatekeeper > Constraint Templates in the left navigation pane.

  3. Click Create on the page.

  4. In the Create Constraint Template dialog box, set the name and Targets for the constraint template, then click OK.

    Parameter Description

    CRD Name

    The CRD name corresponding to the constraint template.

    Targets

    Targets are the target objects of the constraint, i.e., the resource objects to which the constraint rules need to be applied. Targets can be various resources in the Kubernetes cluster, such as pods, Deployments, Namespaces, etc. The constraint will be applied to these target objects to ensure they meet the requirements of the constraint rules.

    You can view the created constraint template on the Constraint Templates page.