# Stackable Operator for OPA (OpenPolicyAgent)

> Manage OPA instances with the Stackable Kubernetes operator. Supports policy-as-code with Rego, integrates with Druid, Kafka, and Trino.

-   [GitHub](https://github.com/stackabletech/opa-operator/)

-   [Feature Tracker](https://features.stackable.tech/unified)

-   [CRD documentation](https://crds.stackable.tech/opa-operator/26.7.0/)


The Stackable operator for the [OpenPolicyAgent](https://www.openpolicyagent.org/) (OPA) manages OPA instances. OPA is an open-source policy engine that allows you to define, manage and enforce policies across a number of software systems. OPA promotes "policy-as-code"; policies are defined in the declarative [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/) language.

## Getting started

The [Getting started guide](https://docs.stackable.tech/home/stable/opa/getting_started/index.md) guides you through the installation of the operator and setting up OPA. You will also create your first Rego rule and query the OPA for a policy decision.

## Operator model

The _OpaCluster_ custom resource is used to declare OPA instances, only one [role](https://docs.stackable.tech/home/stable/concepts/stacklet/index.md) is defined: `server`. OPA is deployed as a DaemonSet because policy decisions must be fast and efficient. Therefore, an OPA agent must be available on every Node to reduce latency and network calls. A DaemonSet with its own ConfigMap is created for every role group. The DaemonSet then deploys a Pod on every node. Every role group also gets its own Service definition.

![A diagram depicting the Kubernetes resources created by the Stackable operator for OPA](https://docs.stackable.tech/home/stable/opa/_images/opa_overview.drawio.svg)

Rego rules are defined in ConfigMaps, which are labeled with the `opa.stackable.tech/bundle: "true"` label. Every OPA Pod has a sidecar `bundle-builder` container that collects these ConfigMaps and builds them into a policy bundle. This ensures that policies can be updated on-the-fly.

The operator also creates a [service discovery ConfigMap](https://docs.stackable.tech/home/stable/concepts/service-discovery/index.md) for the OPA instance. The discovery ConfigMap contains the URL of the OPA API.

## Dependencies

OPA and the Stackable operator for OPA do not have any dependencies.

## Supported products

Currently the following products on the Stackable Data Platform support policy decisions with OPA:

-   [Apache Airflow](https://docs.stackable.tech/home/stable/airflow/usage-guide/security/index.md)

-   [Apache Druid](https://docs.stackable.tech/home/stable/druid/usage-guide/security/index.md)

-   [Apache Hadoop HDFS](https://docs.stackable.tech/home/stable/hdfs/usage-guide/security/index.md)

-   [Apache Kafka](https://docs.stackable.tech/home/stable/kafka/usage-guide/security/index.md)

-   [Apache NiFi](https://docs.stackable.tech/home/stable/nifi/usage_guide/security/index.md)

-   [Apache Superset](https://docs.stackable.tech/home/stable/superset/usage-guide/security/index.md)

-   [Trino](https://docs.stackable.tech/home/stable/trino/usage-guide/security/index.md)


## Supported versions

The Stackable operator for OPA currently supports the OPA versions listed below. To use a specific OPA version in your OpaCluster, you have to specify an image - this is explained in the [Product image selection](https://docs.stackable.tech/home/stable/concepts/product-image-selection/index.md) documentation. The operator also supports running images from a custom registry or running entirely customized images; both of these cases are explained under [Product image selection](https://docs.stackable.tech/home/stable/concepts/product-image-selection/index.md) as well.

-   1.16.2

-   1.12.3 (deprecated)


## Useful links

-   The [opa-operator](https://github.com/stackabletech/opa-operator/) GitHub repository

-   The operator feature overview in the [feature tracker](https://features.stackable.tech/unified)

-   The [OpaCluster](https://crds.stackable.tech/26.7.0/opa.stackable.tech/opacluster/v1alpha2/) CRD documentation
