Open Policy Agent is a general-purpose policy engine that unifies policy enforcement across the stack. OPA provides a high-level declarative language that let’s you specify policy as code and simple APIs to offload policy decision-making from your software. You can use OPA to enforce policies in Kubernetes.
Gatekeeper provides a Kubernetes admission controller built around the OPA engine to integrate OPA and the Kubernetes API service. Although there are other methods to integrate OPA with kubernetes, Gatekeeper has the following capabilities making it more kubernetes native.
- An extensible, parameterized policy library
- Native Kubernetes CRDs for instantiating the policy library (aka "constraints")
- Native Kubernetes CRDs for extending the policy library (aka "constraint templates")
- Audit functionality
OPA policies are expressed in a high-level declarative language called Rego.
Rego is purpose-built for expressing policies over complex hierarchical data structures.
You will create a cluster blueprint with a "gatekeeper" addon
You will then apply this cluster blueprint to a managed cluster
Important
This tutorial describes the steps to create and use a gatekeeper based blueprint using the Web Console. The entire workflow can also be fully automated and embedded into an automation pipeline.
Now, we are ready to apply this blueprint to a cluster.
Click on Options for the target Cluster in the Web Console
Select "Update Blueprint" and select the "governance" blueprint from the from the dropdown and for the version select "v3.1.0" from the dropdown.
Click on "Save and Publish".
This will start the deployment of the addons configured in the "governance" blueprint to the targeted cluster. The blueprint sync process can take a few minutes. Once complete, the cluster will display the current cluster blueprint details and whether the sync was successful or not.