Skip to content

Commit deeea34

Browse files
authored
Update README.md to include csvInjector info (#99)
Add additional clarification on the following: 1. It's relationship to the Operator SDK, OLM and OperatorGroups. 2. The new csvInjector capability 3. How to install independently without common services into any Operator namespace.
1 parent dceb615 commit deeea34

File tree

1 file changed

+70
-22
lines changed

1 file changed

+70
-22
lines changed

README.md

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# namespaceScope - Manage operator and operand authority across namespaces
22

3-
This operator automates the extension of operator watch and service account permission scope to other namespaces in an openshift cluster.
3+
This operator automates the extension of operator watch and service account permission scope to other namespaces in an openshift cluster, which is similar, but complementary to `OperatorGroups` that are available with Operator Lifecycle Manager (OLM). By using the `NamespaceScope` operator with the `Own Namespace` `OperatorGroup` install mode, you can more easily manage the security domain of your Operators and the Operand namespaces.
44

5-
The operator runs in the namespace whose operator WATCH statements and roles/rolebindings are to be extended to other namespaces as specified in a NamespaceScope CR.
5+
The `NamespaceScope` operator runs in the namespace whose operator's `WATCH_NAMESPACES` and `Roles`/`RoleBindings` are to be extended to other namespaces (the Operand namespaces) as specified in a NamespaceScope CR. `WATCH_NAMESPACES` is an enviromental variable that the Operator SDK uses in conjunction with OLM `ClusterServiceVersion` deployment to identify which namespaces to watch. OLM will inject the namespaces into an annotation into the Operator's Deployment resource and then use the downward API to pass those values into the `WATCH_NAMESPACES` environment variable. To avoid conflicts with OLM, the `NamespaceScope` operator instead stores the watched namespace list in a user-configurable `ConfigMap` and the Deployment instead mounts this `ConfigMap` as an environment variable.
66

77
A sample CR is below:
88

@@ -23,26 +23,21 @@ spec:
2323
# Restart pods with the following labels when the namespace list changes
2424
restartLabels:
2525
intent: projected
26+
27+
# Automatically inject the configmap into the ClusterServiceVersion, overriding the OLM OperatorGroup membership for those operators that have
28+
# the nss.operator.ibm.com/managed-operators annotation defined. This annotation is a comma-separate list of OLM operator package names that should
29+
# be honored. This should include the package of itself and any dependent operators that cannot be annotated (e.g. third-party operators)
30+
csvInjector:
31+
enable: true
2632
```
2733

2834
- The **namespaceMembers** contains a list of other namespace in the cluster that:
2935
- should be watched by operators running in the current namespace
30-
- to which roles and rolebindings for service accounts in the current namespace should be authorized for service accounts in this namespace
36+
- to which `Roles` and `RoleBindings` for `ServiceAccounts` in the current namespace should be authorized for `ServiceAccounts` in this namespace
3137

3238
- The **namespaceMembers** list ALWAYS contains the current namespace whether specifically listed or not (it is implicit)
3339

34-
- The **configmapName** identifies a ConfigMap that is created to contain a common-separated list of the namespaces to be watched in its **namespaces** key. All operators that want to participate in namespace extension should be configured to watch the key on this configmap. An example of this is in the operator deployment fragment below (the latest operator SDK support watching multiple namespaces in a comma-separated list). The configmap is created and maintained ONLY by the NamespaceScope operator.
35-
36-
```
37-
...
38-
env:
39-
- name: WATCH_NAMESPACE
40-
valueFrom:
41-
configMapKeyRef:
42-
name: namespace-scope
43-
key: namespaces
44-
...
45-
```
40+
- The **configmapName** identifies a `ConfigMap` that is created to contain a common-separated list of the namespaces to be watched in its **namespaces** key.
4641

4742
- The **restartLabels** list specifies the labels for operator pods that are to be restarted when the namespace-scope list changes so they can reset their WATCH parameters. The default label is "intent=projected". All operator Pods that are configured as above should also be labelled so that the operator will auto-restart them the configmap changes the list of namespaces to watch. An example of this label is below.
4843

@@ -64,7 +59,26 @@ spec:
6459
spec:
6560
...
6661
```
62+
- The **csvInjector** (default is false / disabled) automatically modifies any `ClusterServiceVersion` that appears in the current namespace with the `nss.operator.ibm.com/managed-operators` annotation to consume the `NamespaceScope` operator's `ConfigMap` specified by `configmapName` instead of the traditional downward API syntax scaffolded by the Operator SDK, allowing uninstrumented Operators to read the `NamespaceScope` watch namespaces.
6763
64+
The following is an example of what is added and overridden in all `ClusterServiceVersion` resources in the namespace:
65+
66+
```
67+
...
68+
# This annotation must be added to the CSV for injection to occur. Include THIS operator package and any dependant packages.
69+
metadata:
70+
annotations:
71+
nss.operator.ibm.com/managed-operators: "my-operator1,my-thirdparty-operator"
72+
...
73+
# This is injected
74+
env:
75+
- name: WATCH_NAMESPACE
76+
valueFrom:
77+
configMapKeyRef:
78+
name: namespace-scope
79+
key: namespaces
80+
...
81+
```
6882
6983
## How does it work
7084
@@ -137,25 +151,59 @@ When the `NamespaceScope` CR is created/updated, it will:
137151
```
138152
139153
140-
## How to manually deploy it
154+
## How to manually deploy the NamespaceScope Operator
141155
142156
NOTE: This operator is part of the IBM Common Services and will be automatically installed. Following commands are only applicable when you want to deploy it without IBM Common Services.
143157
158+
In this example, the `my-operators` namespace is the namespace that will contain your OLM-Deployed operators:
159+
144160
```
145161
git clone https://github.com/IBM/ibm-namespace-scope-operator.git
146162
cd ibm-namespace-scope-operator
147163

148-
oc create ns ibm-common-services
164+
oc create ns my-operators
149165

150166
oc apply -f deploy/operator.ibm.com_namespacescopes.yaml
151-
oc -n ibm-common-services apply -f deploy/service_account.yaml
152-
oc -n ibm-common-services apply -f deploy/role.yaml
153-
oc -n ibm-common-services apply -f deploy/role_binding.yaml
154-
oc -n ibm-common-services apply -f deploy/operator.yaml
167+
oc -n my-operators apply -f deploy/service_account.yaml
168+
oc -n my-operators apply -f deploy/role.yaml
169+
oc -n my-operators apply -f deploy/role_binding.yaml
170+
oc -n my-operators apply -f deploy/operator.yaml
171+
```
172+
173+
Once the Operator is deployed, create a `NamespaceScope` custom resource (CR) in the Operators namespace to watch other Operand namespaces:
174+
175+
```
176+
oc create ns my-operand-tenant1
177+
oc create ns my-operand-tenant2
178+
179+
cat <<EOF | oc apply -n my-operators -f -
180+
apiVersion: operator.ibm.com/v1
181+
kind: NamespaceScope
182+
metadata:
183+
name: my-operator
184+
spec:
185+
# Namespaces that are part of this scope
186+
namespaceMembers:
187+
- my-operand-tenant1
188+
- my-operand-tenant1
189+
190+
# ConfigMap name that will contain the list of namespaces to be watched
191+
configmapName: namespace-scope
155192

156-
oc -n ibm-common-services apply -f deploy/cr.yaml
193+
# Restart pods with the following labels when the namespace list changes
194+
restartLabels:
195+
intent: projected
196+
197+
# Automatically inject the configmap into the ClusterServiceVersion, overriding the OLM OperatorGroup membership for those operators that have
198+
# the nss.operator.ibm.com/managed-operators annotation defined. This annotation is a comma-separate list of OLM operator package names that should
199+
# be honored. This should include the package of itself and any dependent operators that cannot be annotated (e.g. third-party operators)
200+
csvInjector:
201+
enable: true
202+
203+
EOF
157204
```
158205
206+
159207
## Authorization and Permissions
160208
161209
The **authorize-namespace.sh** script in the `scripts/` directory is used to set up roles and binding in a target namespace.

0 commit comments

Comments
 (0)