TLS encryption for securing connections between clients and the OPA server can be configured in the OpaCluster resource. When TLS is enabled, OPA will serve requests over HTTPS instead of HTTP.
TLS encryption in OPA is disabled by default. To enable it, you need to:
-
Create a
SecretClassthat provides TLS certificates -
Reference the
SecretClassin yourOpaClusterspecification
The operator integrates with the Secret Operator to automatically provision and mount TLS certificates to the OPA pods.
First, create a SecretClass that will provide TLS certificates. Here’s an example using autoTls:
apiVersion: secrets.stackable.tech/v1alpha1
kind: SecretClass
metadata:
name: opa-tls
spec:
backend:
autoTls:
ca:
autoGenerate: true
secret:
name: opa-tls-ca
namespace: defaultThis SecretClass uses the autoTls backend, which automatically generates a Certificate Authority (CA) and signs certificates for your OPA cluster.
Similarly, you can also use other backends supported by Secret Operator.
The operator automatically creates a discovery ConfigMap, with the same name as the OPA cluster, that contains the connection URL for your cluster. When TLS is enabled, this ConfigMap will contain an HTTPS URL and the SecretClass name:
apiVersion: v1
kind: ConfigMap
metadata:
name: opa-with-tls
data:
OPA: "https://opa-with-tls.default.svc.cluster.local:8443/"
OPA_SECRET_CLASS: "opa-tls"Applications can use this ConfigMap to discover and connect to the OPA cluster automatically.