UNCLASSIFIED

README.md 3.89 KB
Newer Older
michaelmcleroy's avatar
michaelmcleroy committed
1
# Open Policy Agent Gatekeeper
Brian Miller's avatar
Brian Miller committed
2

michaelmcleroy's avatar
michaelmcleroy committed
3
The [Open Policy Agent (OPA) Gatekeeper](https://github.com/open-policy-agent/gatekeeper) assists in enforcing, monitoring, and remediating policies while strengthening governance of an environment. It provides integration between OPA and Kubernetes.
4

michaelmcleroy's avatar
michaelmcleroy committed
5 6 7 8 9 10 11 12 13 14 15
OPA Gatekeeper controls the policies for Kubernetes and acts as a customizable Kubernetes Admission Webhook. Its audit functionality offers constant monitoring of existing clusters to detect policy violations.

OPA Gatekeeper functionality includes:

- [An extensible, parameterized policy library](./docs/policylibrary.md).
- Native Kubernetes CRDs called [`ConstraintTemplates`](./docs/constraint-templates.md) for extending the policy library
  - A high level language, [Rego](./docs/rego.md), to create policies.
- Native Kubernetes CRDs called `Constraints` for instantiating the policy library.
- Audit functionality.
- [Security](./docs/security.md)
- [Test framework](./docs/test.md) for developing tests for policies.
16
- [Upgrade](./docs/upgrade.md) Guide for upgrading versions.
michaelmcleroy's avatar
michaelmcleroy committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

## Installation

To install and test the Gatekeeper application, follow these steps

### Prerequisite

- A kubernetes cluster with cluster-admin access
- [Helm](https://helm.sh/docs/intro/install/)

### Procedure

- Clone the application repository
   `git clone https://repo1.dso.mil/platform-one/big-bang/apps/core/policy.git`
- Change into the policy directory and lint the chart  - make surre there are no errors.
   `cd policy && helm lint chart`
- Install the chart
    `helm upgrade -i -n gatekeeper-system --create-namespace --wait opa-gatekeeper chart --debug`
- Confirm the application installed with no issues.

    ```shell
    kubectl get po -n gatekeeper-system
    NAME                                            READY   STATUS    RESTARTS   AGE
    gatekeeper-audit-7997ddc847-8pt5h               1/1     Running   0          28s
    gatekeeper-controller-manager-7fdfd7bfd-8g5sm   1/1     Running   0          28s
    gatekeeper-controller-manager-7fdfd7bfd-khc7j   1/1     Running   0          28s
    gatekeeper-controller-manager-7fdfd7bfd-nzzd8   1/1     Running   0          28s
    ```

## ConstraintTemplates and Constraints

The repo contains `ConstraintTemplate` and `Constraints`.

- `ConstraintTemplates` describe both the Rego that enforces the constraint and the schema of the constraint. It is the same context as the `ConstraintTemplate` being a CRD with the schema definition and the `Contraints` being the CRs passing parameters.

You can find `ConstraintTemplates` in [`/chart/templates/constraint-templates`](./chart/templates/constraint-templates).

- `Constraints` represent the instantiation of the `ConstraintTemplates`. They inform Gatekeeper that the admin wants a `ConstraintTemplate` to be enforced, and how.

You can find `Constraint` in [`/chart/templates/constraints`](./chart/templates/constraints).

Further information on `Constraints` and `ConstraintTemplates`:

- [Constraint Framework](./docs/constraint-framework.md)
- [Constraint Template List](./docs/constraint-templates.md)
- [Constraint Annotations](./docs/constraint-annotations.md)
- [Policy Library](./docs/policylibrary.md)
- [Rego](./docs/rego.md)

## Additional OPA Gatekeeper Links

- [Webinar: K8s with OPA Gatekeeper](https://www.youtube.com/watch?v=v4wJE3I8BYM)
- [Difference between OPA and Gatekeeper](https://www.infracloud.io/blogs/opa-and-gatekeeper/)
- [K8s with OPA Gatekeeper](https://www.youtube.com/watch?v=v4wJE3I8BYM&t=2735s)
- [Fitness Validation For Your Kubernetes Apps: Policy As Code](https://itnext.io/fitness-validation-for-your-kubernetes-apps-policy-as-code-7fad698e7dec)
- [Introduction to Open Policy Agent | Rawkode Live](https://www.youtube.com/watch?v=ejH4EzmL7e0)
- [Open Policy Agent Debugging](https://www.openpolicyagent.org/docs/latest/kubernetes-debugging/)
- [OPA Gatekeeper Debugging](https://open-policy-agent.github.io/gatekeeper/website/docs/debug/)