Skip to content

Commit 8b11d59

Browse files
authored
Merge pull request #78003 from mburke5678/cma-add-token-secret
CMA add secret to generate SA token
2 parents 4882cb2 + 01e8247 commit 8b11d59

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

modules/nodes-cma-autoscaling-custom-prometheus-config.adoc

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ These steps are not required for an external Prometheus source.
1515

1616
You must perform the following tasks, as described in this section:
1717

18-
* Create a service account to get a token.
19-
* Create the service token.
18+
* Create a service account.
19+
* Create a secret that generates a token for the service account.
20+
* Create the trigger authentication.
2021
* Create a role.
2122
* Add that role to the service account.
2223
* Reference the token in the trigger authentication object used by Prometheus.
@@ -38,49 +39,49 @@ You must perform the following tasks, as described in this section:
3839
$ oc project my-project
3940
----
4041

41-
. Use the following command to create a service account, if your cluster does not have one:
42+
. Create a service account and token, if your cluster does not have one:
43+
44+
.. Create a `service account` object by using the following command:
4245
+
4346
[source,terminal]
4447
----
45-
$ oc create serviceaccount <service_account>
48+
$ oc create serviceaccount thanos <1>
4649
----
4750
+
48-
where:
49-
+
50-
<service_account>:: Specifies the name of the service account.
51+
<1> Specifies the name of the service account.
5152

52-
. Use the following command to create the service token for the service account:
53+
.. Create a `secret` YAML to generate a service account token:
5354
+
54-
[source,terminal]
55+
[source,yaml]
5556
----
56-
$ oc apply -f - <<EOF
5757
apiVersion: v1
5858
kind: Secret
5959
metadata:
6060
name: thanos-token
6161
annotations:
62-
kubernetes.io/service-account.name: <service_account>
62+
kubernetes.io/service-account.name: thanos <1>
6363
type: kubernetes.io/service-account-token
64-
EOF
6564
----
6665
+
67-
where:
66+
<1> Specifies the name of the service account.
67+
68+
.. Create the secret object by using the following command:
6869
+
69-
<service_account>:: Specifies the name of the service account.
70+
[source,terminal]
71+
----
72+
$ oc create -f <file_name>.yaml
73+
----
7074

7175
.. Use the following command to locate the token assigned to the service account:
7276
+
7377
[source,terminal]
7478
----
75-
$ oc describe serviceaccount <service_account>
79+
$ oc describe serviceaccount thanos <1>
7680
----
7781
+
78-
--
79-
where:
80-
81-
<service_account>:: Specifies the name of the service account.
82-
--
82+
<1> Specifies the name of the service account.
8383
+
84+
--
8485
.Example output
8586
[source,terminal]
8687
----
@@ -90,11 +91,12 @@ Labels: <none>
9091
Annotations: <none>
9192
Image pull secrets: thanos-dockercfg-nnwgj
9293
Mountable secrets: thanos-dockercfg-nnwgj
93-
Tokens: thanos-token-9g4n5 <1>
94+
Tokens: thanos-token <1>
9495
Events: <none>
9596

9697
----
9798
<1> Use this token in the trigger authentication.
99+
--
98100
99101
. Create a trigger authentication with the service account token:
100102
@@ -109,10 +111,10 @@ metadata:
109111
spec:
110112
secretTargetRef: <1>
111113
- parameter: bearerToken <2>
112-
name: thanos-token-9g4n5 <3>
114+
name: thanos-token <3>
113115
key: token <4>
114116
- parameter: ca
115-
name: thanos-token-9g4n5
117+
name: thanos-token
116118
key: ca.crt
117119
----
118120
<1> Specifies that this object uses a secret for authorization.
@@ -186,6 +188,7 @@ subjects:
186188
<2> Specifies the namespace of the object you want to scale.
187189
<3> Specifies the name of the service account to bind to the role.
188190
<4> Specifies the namespace of the object you want to scale.
191+
189192
.. Create the CR object:
190193
+
191194
[source,terminal]
@@ -200,4 +203,3 @@ You can now deploy a scaled object or scaled job to enable autoscaling for your
200203
* `triggers.metadata.authModes` must be `bearer`
201204
* `triggers.metadata.namespace` must be set to the namespace of the object to scale
202205
* `triggers.authenticationRef` must point to the trigger authentication resource specified in the previous step
203-

0 commit comments

Comments
 (0)