Skip to content

Commit b044bdf

Browse files
committed
cleanup & docs
1 parent 85abdc2 commit b044bdf

File tree

5 files changed

+61
-35
lines changed

5 files changed

+61
-35
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ All notable changes to this project will be documented in this file.
99
- Run a `containerdebug` process in the background of each OPA container to collect debugging information ([#666]).
1010
- Added support for OPA `1.0.x` ([#677]) and ([#687]).
1111
- Aggregate emitted Kubernetes events on the CustomResources ([#675]).
12-
- Added role level service and discovery configmap called `<cluster-name>-lb` with `internalTrafficPolicy` set to "Cluster" ([#688]).
12+
- Added role level services and discovery configmaps called `<cluster-name>-local` with `internalTrafficPolicy` set to `Local`
13+
and `<cluster-name>-cluster` with `internalTrafficPolicy` set to `Cluster` ([#688]).
1314

1415
### Removed
1516

docs/modules/opa/pages/implementation-notes.adoc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ but should not be required reading for regular use.
55

66
== OPA replica per node
77

8-
Since OPA is deployed as a DaemonSet and runs on each Node, two entrypoint Services are defined.
8+
OPA is deployed as a DaemonSet and runs on each Node. two entrypoint Services are defined.
99

1010
=== Local Traffic Policy
1111

@@ -16,15 +16,16 @@ This means that https://kubernetes.io/docs/concepts/workloads/pods/[Pods] access
1616

1717
This should be the default entrypoint and has the same name as the defined OPA cluster.
1818

19-
If the `metadata.name` is `opa`, this service is called `opa`.
19+
If the `metadata.name` is `opa`, this service is called `opa-local`.
2020

21-
=== Cluster Traffic Policy (load-balanced / round-robin)
21+
=== Cluster Traffic Policy (round-robin)
2222

23-
This service is called as the OPA cluster suffixed with `-lb`. This entrypoint can be used if latency (e.g. no network requests) is less important.
23+
This service is called as the OPA cluster suffixed with `-cluster`. This entrypoint can be used if latency (e.g. no network requests) is less important.
2424
Evaluating complicated rego rules may take some time depending on the provided resources, and can be the limiting factor in e.g. bulk requests.
25-
Therefore, using this service, every Pod in the cluster is utilized to evaluate policies than instead e.g. just one.
25+
Therefore, using this service, every Pod in the cluster is utilized to evaluate policies (via round robin). This allows better parallelism when
26+
evaluating policies, but results in network roundtrips.
2627

27-
If the `metadata.name` is `opa`, this service is called `opa-lb`.
28+
If the `metadata.name` is `opa`, this service is called `opa-cluster`.
2829

2930
== OPA Bundle Builder
3031

docs/modules/opa/pages/reference/discovery.adoc

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ metadata:
2626
spec:
2727
[...]
2828
----
29-
<1> The name of the OPA cluster, which is also the name of the created discovery ConfigMap.
30-
<2> The namespace of the discovery ConfigMap.
29+
<1> The name of the OPA cluster, which is used in the created discovery ConfigMaps.
30+
<2> The namespace of the discovery ConfigMaps.
3131

32-
The resulting discovery ConfigMap is `{namespace}/{clusterName}`.
32+
Currently, three discovery ConfigMaps are provided.
3333

34-
== Contents
34+
=== (DEPRECATED) Internal Traffic Policy `Local`
3535

36-
The `{namespace}/{clusterName}` discovery ConfigMap contains the following fields where `{clusterName}` represents the name and `{namespace}` the namespace of the cluster:
36+
The discovery ConfigMap `{namespace}/{clusterName}` contains the following fields where `{clusterName}` represents the name and `{namespace}` the namespace of the cluster.
37+
This is deprecated and only kept for backwards compatibitliy. Users are adviced to switch to `{namespace}/{clusterName}-local`, which is the identical replacement.
3738

3839
`OPA`::
3940
====
@@ -49,3 +50,44 @@ In order to query policies you have to configure your product and its OPA URL as
4950
[subs="attributes"]
5051
http://{clusterName}.{namespace}.svc.cluster.local:8081/v1/data/{packageName}/{policyName}
5152
====
53+
54+
=== Internal Traffic Policy `Local`
55+
56+
The discovery ConfigMap `{namespace}/{clusterName}-local` contains the following fields where `{clusterName}-local` represents the name and `{namespace}` the namespace of the cluster.
57+
Using this discovery service, requests from one Node will always reach the OPA Pod on the same Node. This allows for low latency authorization queriers.
58+
59+
`OPA`::
60+
====
61+
A connection string for cluster internal OPA requests.
62+
Provided the cluster example above, the connection string is created as follows:
63+
64+
[subs="attributes"]
65+
http://{clusterName}-local.{namespace}.svc.cluster.local:8081/
66+
67+
This connection string points to the base URL (and web UI) of the OPA cluster.
68+
In order to query policies you have to configure your product and its OPA URL as follows, given the bundle package name `{packageName}` and the policy name `{policyName}`:
69+
70+
[subs="attributes"]
71+
http://{clusterName}-local.{namespace}.svc.cluster.local:8081/v1/data/{packageName}/{policyName}
72+
====
73+
74+
=== Internal Traffic Policy `Cluster`
75+
76+
The discovery ConfigMap `{namespace}/{clusterName}-cluster` contains the following fields where `{clusterName}-cluster` represents the name and `{namespace}` the namespace of the cluster.
77+
Using this discovery service, requests to OPA are distributed over all available OPA Pods, improving parallelism when evaluating policies but slightly increasing the latency of each single query
78+
to due additional network requests.
79+
80+
`OPA`::
81+
====
82+
A connection string for cluster internal OPA requests.
83+
Provided the cluster example above, the connection string is created as follows:
84+
85+
[subs="attributes"]
86+
http://{clusterName}-cluster.{namespace}.svc.cluster.local:8081/
87+
88+
This connection string points to the base URL (and web UI) of the OPA cluster.
89+
In order to query policies you have to configure your product and its OPA URL as follows, given the bundle package name `{packageName}` and the policy name `{policyName}`:
90+
91+
[subs="attributes"]
92+
http://{clusterName}-cluster.{namespace}.svc.cluster.local:8081/v1/data/{packageName}/{policyName}
93+
====

rust/operator-binary/src/controller.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ pub enum Error {
158158
source: error_boundary::InvalidObject,
159159
},
160160

161-
#[snafu(display("object does not define meta name"))]
162-
NoName,
163-
164161
#[snafu(display("internal operator failure"))]
165162
InternalOperatorFailure {
166163
source: stackable_opa_operator::crd::Error,
@@ -453,7 +450,7 @@ pub async fn reconcile_opa(
453450

454451
let required_services = vec![
455452
// The server-role service is the primary endpoint that should be used by clients that do
456-
// require local access - Deprecated, kept for downwards compatibility
453+
// require local access - deprecated, kept for downwards compatibility
457454
ServiceConfig {
458455
name: opa
459456
.server_role_service_name_itp_local_deprecated()

rust/operator-binary/src/service.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ pub enum Error {
2727
#[snafu(display("object has no name associated"))]
2828
NoName,
2929

30-
#[snafu(display("object has no namespace associated"))]
31-
NoNamespace,
32-
33-
#[snafu(display("failed to build ConfigMap"))]
34-
BuildConfigMap {
35-
source: stackable_operator::builder::configmap::Error,
36-
},
37-
3830
#[snafu(display("failed to build object meta data"))]
3931
ObjectMeta {
4032
source: stackable_operator::builder::meta::Error,
@@ -58,13 +50,7 @@ pub fn build_discoverable_services(
5850

5951
// discoverable role services
6052
for sc in service_configs {
61-
let service_name = sc.name;
62-
services.push(build_server_role_service(
63-
opa,
64-
resolved_product_image,
65-
&service_name,
66-
Some(sc.internal_traffic_policy.to_string()),
67-
)?);
53+
services.push(build_server_role_service(opa, resolved_product_image, sc)?);
6854
}
6955

7056
Ok(services)
@@ -73,14 +59,13 @@ pub fn build_discoverable_services(
7359
fn build_server_role_service(
7460
opa: &v1alpha1::OpaCluster,
7561
resolved_product_image: &ResolvedProductImage,
76-
service_name: &str,
77-
internal_traffic_policy: Option<String>,
62+
service_config: ServiceConfig,
7863
) -> Result<Service> {
7964
let role_name = v1alpha1::OpaRole::Server.to_string();
8065

8166
let metadata = ObjectMetaBuilder::new()
8267
.name_and_namespace(opa)
83-
.name(service_name)
68+
.name(service_config.name)
8469
.ownerreference_from_resource(opa, None, Some(true))
8570
.context(ObjectMissingMetadataForOwnerRefSnafu {
8671
opa: ObjectRef::from_obj(opa),
@@ -106,7 +91,7 @@ fn build_server_role_service(
10691
..ServicePort::default()
10792
}]),
10893
selector: Some(service_selector_labels.into()),
109-
internal_traffic_policy,
94+
internal_traffic_policy: Some(service_config.internal_traffic_policy),
11095
..ServiceSpec::default()
11196
};
11297

0 commit comments

Comments
 (0)