Skip to content

Commit d303dbc

Browse files
committed
Add secret step to OLM policy scoping
1 parent cec5661 commit d303dbc

File tree

1 file changed

+53
-8
lines changed

1 file changed

+53
-8
lines changed

modules/olm-policy-scoping-operator-install.adoc

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Using this example, a cluster administrator can confine a set of Operators to a
1919

2020
. Create a new namespace:
2121
+
22+
.Example creation of a `Namespace` object
23+
[%collapsible]
24+
====
2225
[source,terminal]
2326
----
2427
$ cat <<EOF | oc create -f -
@@ -28,9 +31,15 @@ metadata:
2831
name: scoped
2932
EOF
3033
----
34+
====
3135
32-
. Allocate permissions that you want the Operator(s) to be confined to. This involves creating a new service account, relevant role(s), and role binding(s).
36+
. Allocate permissions that you want the Operator(s) to be confined to. This involves creating a new service account, relevant role(s), and role binding(s) in the newly created, designated namespace:
37+
38+
.. Create a service account by running the following command:
3339
+
40+
.Example creation of a `ServiceAccount` object
41+
[%collapsible]
42+
====
3443
[source,terminal]
3544
----
3645
$ cat <<EOF | oc create -f -
@@ -41,9 +50,39 @@ metadata:
4150
namespace: scoped
4251
EOF
4352
----
53+
====
54+
55+
.. Create a secret by running the following command:
4456
+
45-
The following example grants the service account permissions to do anything in the designated namespace for simplicity. In a production environment, you should create a more fine-grained set of permissions:
57+
.Example creation of a long-lived API token `Secret` object
58+
[%collapsible]
59+
====
60+
[source,terminal]
61+
----
62+
$ cat <<EOF | oc create -f -
63+
apiVersion: v1
64+
kind: Secret
65+
type: kubernetes.io/service-account-token <1>
66+
metadata:
67+
name: scoped
68+
namespace: scoped
69+
annotations:
70+
kubernetes.io/service-account.name: scoped
71+
EOF
72+
----
73+
<1> The secret must be a long-lived API token, which is used by the service account.
74+
====
75+
76+
.. Create a role by running the following command.
4677
+
78+
[WARNING]
79+
====
80+
In this example, the role grants the service account permissions to do anything in the designated namespace for simplicity. In a production environment, you should create a more fine-grained set of permissions. For more information, see "Fine-grained permissions".
81+
====
82+
+
83+
.Example creation of `Role` and `RoleBinding` objects
84+
[%collapsible]
85+
====
4786
[source,terminal]
4887
----
4988
$ cat <<EOF | oc create -f -
@@ -72,11 +111,13 @@ subjects:
72111
namespace: scoped
73112
EOF
74113
----
114+
====
75115
76-
. Create an `OperatorGroup` object in the designated namespace. This Operator group targets the designated namespace to ensure that its tenancy is confined to it.
77-
+
78-
In addition, Operator groups allow a user to specify a service account. Specify the service account created in the previous step:
116+
. Create an `OperatorGroup` object in the designated namespace by running the following command. This Operator group targets the designated namespace to ensure that its tenancy is confined to it. In addition, Operator groups allow a user to specify a service account.
79117
+
118+
.Example creation of am `OperatorGroup` object
119+
[%collapsible]
120+
====
80121
[source,terminal]
81122
----
82123
$ cat <<EOF | oc create -f -
@@ -86,16 +127,19 @@ metadata:
86127
name: scoped
87128
namespace: scoped
88129
spec:
89-
serviceAccountName: scoped
130+
serviceAccountName: scoped <1>
90131
targetNamespaces:
91132
- scoped
92133
EOF
93134
----
94-
+
95-
Any Operator installed in the designated namespace is tied to this Operator group and therefore to the service account specified.
135+
<1> Specify the service account created in the previous step. Any Operator installed in the designated namespace is tied to this Operator group and therefore to the service account specified.
136+
====
96137

97138
. Create a `Subscription` object in the designated namespace to install an Operator:
98139
+
140+
.Example creation of `Subscription` object
141+
[%collapsible]
142+
====
99143
[source,terminal]
100144
----
101145
$ cat <<EOF | oc create -f -
@@ -115,3 +159,4 @@ EOF
115159
<2> Specify a namespace where the catalog source was created.
116160
+
117161
Any Operator tied to this Operator group is confined to the permissions granted to the specified service account. If the Operator requests permissions that are outside the scope of the service account, the installation fails with relevant errors.
162+
====

0 commit comments

Comments
 (0)