1
- # Installing Pub/Sub Enabled Service Account
1
+ # Installing a Service Account for the Data Plane
2
2
3
3
Besides the control plane setup described in the general
4
4
[ installation guide] ( ./install-knative-gcp.md ) , each of our resources have a
@@ -28,10 +28,10 @@ In general, we would just need permissions to receive messages
28
28
(` roles/pubsub.subscriber ` ). However, in the case of the ` Channel ` , we would
29
29
also need the ability to publish messages (` roles/pubsub.publisher ` ).
30
30
31
- 1 . Create a new Service Account named ` cre-pubsub ` with the following command:
31
+ 1 . Create a new Service Account named ` cre-dataplane ` with the following command:
32
32
33
33
``` shell
34
- gcloud iam service-accounts create cre-pubsub
34
+ gcloud iam service-accounts create cre-dataplane
35
35
```
36
36
37
37
1 . Give that Service Account the necessary permissions on your project.
@@ -43,9 +43,24 @@ also need the ability to publish messages (`roles/pubsub.publisher`).
43
43
44
44
``` shell
45
45
gcloud projects add-iam-policy-binding $PROJECT_ID \
46
- --member=serviceAccount:cre-pubsub @$PROJECT_ID .iam.gserviceaccount.com \
46
+ --member=serviceAccount:cre-dataplane @$PROJECT_ID .iam.gserviceaccount.com \
47
47
--role roles/pubsub.editor
48
48
```
49
+
50
+ *** Note:***
51
+ If you are going to use metrics and tracing to track your resources,
52
+ you also need ` roles/monitoring.metricWriter ` for metrics functionality:
53
+ ``` shell
54
+ gcloud projects add-iam-policy-binding $PROJECT_ID \
55
+ --member=serviceAccount:cre-dataplane@$PROJECT_ID .iam.gserviceaccount.com \
56
+ --role roles/monitoring.metricWriter
57
+ ```
58
+ and ` roles/cloudtrace.agent` for tracing functionality:
59
+ ` ` ` shell
60
+ gcloud projects add-iam-policy-binding $PROJECT_ID \
61
+ --member=serviceAccount:cre-dataplane@$PROJECT_ID .iam.gserviceaccount.com \
62
+ --role roles/cloudtrace.agent
63
+ ` ` `
49
64
50
65
# # Configure the Authentication Mechanism for GCP (the Data Plane)
51
66
71
86
72
87
- ** _Non-default scenario:_**
73
88
74
- Using the Google Cloud Service Account ` cre-pubsub ` you just created and using
89
+ Using the Google Cloud Service Account ` cre-dataplane ` you just created and using
75
90
[Option 1 (Recommended): Workload Identity](../install/authentication-mechanisms-gcp.md/# option-1-recommended-workload-identity)
76
91
in
77
92
[Authentication Mechanism for GCP](../install/authentication-mechanisms-gcp.md)
82
97
configuration in the Control Plane)
83
98
84
99
You will have a Kubernetes Service Account after the above configuration,
85
- which is bound to the Google Cloud Service Account ` cre-pubsub ` . Remember to
100
+ which is bound to the Google Cloud Service Account ` cre-dataplane ` . Remember to
86
101
put this Kubernetes Service Account name as the ` spec.serviceAccountName` when
87
102
you create resources in the
88
103
[example](https://github.com/google/knative-gcp/tree/master/docs/examples).
@@ -94,12 +109,12 @@ Plane:
94
109
you can authorize the Controller to configure Workload Identity for you.
95
110
96
111
You need to grant ` iam.serviceAccountAdmin` permission of the Google Cloud
97
- Service Account ` cre-pubsub ` you just created to the Control Plane's Google
112
+ Service Account ` cre-dataplane ` you just created to the Control Plane' s Google
98
113
Cloud Service Account `cloud-run-events` by:
99
114
100
115
```shell
101
116
gcloud iam service-accounts add-iam-policy-binding \
102
- cre-pubsub @$PROJECT_ID .iam.gserviceaccount.com \
117
+ cre-dataplane @$PROJECT_ID.iam.gserviceaccount.com \
103
118
--member=' serviceAccount:cloud-run-events@$PROJECT_ID .iam.gserviceaccount.com' \
104
119
--role=' roles/iam.serviceAccountAdmin'
105
120
```
@@ -118,22 +133,22 @@ Plane:
118
133
default-auth-config: |
119
134
clusterDefaults:
120
135
workloadIdentityMapping:
121
- default-cre-pubsub : cre-pubsub @$PROJECT_ID .iam.gserviceaccount.com
136
+ default-cre-dataplane : cre-dataplane @$PROJECT_ID.iam.gserviceaccount.com
122
137
```
123
138
124
- Here, ` default-cre-pubsub ` refers to a Kubernetes Service Account bound to the
125
- Google Cloud Service Account ` cre-pubsub ` . Remember to put this Kubernetes
139
+ Here, `default-cre-dataplane ` refers to a Kubernetes Service Account bound to the
140
+ Google Cloud Service Account `cre-dataplane `. Remember to put this Kubernetes
126
141
Service Account name as the `spec.serviceAccountName` when you create
127
142
resources in the
128
143
[example](https://github.com/google/knative-gcp/tree/master/docs/examples).
129
144
130
- Kubernetes Service Account ` default-cre-pubsub ` doesn't need to exist in a
145
+ Kubernetes Service Account `default-cre-dataplane ` doesn' t need to exist in a
131
146
specific namespace. Once it is set in the ConfigMap ` config-gcp-auth` , the
132
147
Control Plane will create it for you and configure the corresponding Workload
133
148
Identity relationship between the Kubernetes Service Account
134
- ` default-cre-pubsub ` and the Google Cloud Service Account ` cre-pubsub ` when
149
+ ` default-cre-dataplane ` and the Google Cloud Service Account ` cre-dataplane ` when
135
150
you create resources using the Kubernetes Service Account
136
- ` default-cre-pubsub ` .
151
+ ` default-cre-dataplane ` .
137
152
138
153
A ` Condition` ` WorkloadIdentityConfigured` will show up under resources'
139
154
`Status`, indicating the Workload Identity configuration status.
@@ -142,26 +157,26 @@ as a result, any user who can create a resource can get access to the Google Clo
142
157
Service Account which grants the `iam.serviceAccountAdmin` permission to the Controller.
143
158
As an example, if you followed the instructions above, then any user that can make
144
159
a Knative-GCP source or Channel (e.g. `CloudAuditLogsSource`, `CloudPubSubSource`,
145
- etc.) can cause the Kubernetes Service Account ` default-cre-pubsub ` to be created.
160
+ etc.) can cause the Kubernetes Service Account `default-cre-dataplane ` to be created.
146
161
If they can also create Pods in that namespace, then they can make a Pod that uses
147
- the Google Service Account ` cre-pubsub ` credentials.
162
+ the Google Service Account `cre-dataplane ` credentials.
148
163
149
164
### Option 2. Export Service Account Keys And Store Them as Kubernetes Secrets
150
165
151
166
1. Download a new JSON private key for that Service Account. **Be sure not to
152
167
check this key into source control!**
153
168
154
169
```shell
155
- gcloud iam service-accounts keys create cre-pubsub .json \
156
- --iam-account=cre-pubsub @$PROJECT_ID .iam.gserviceaccount.com
170
+ gcloud iam service-accounts keys create cre-dataplane .json \
171
+ --iam-account=cre-dataplane @$PROJECT_ID.iam.gserviceaccount.com
157
172
```
158
173
159
174
1. Create a secret on the Kubernetes cluster with the downloaded key. Remember
160
175
to create the secret in the namespace your resources will reside. The example
161
176
below does so in the `default` namespace.
162
177
163
178
```shell
164
- kubectl --namespace default create secret generic google-cloud-key --from-file=key.json=cre-pubsub .json
179
+ kubectl --namespace default create secret generic google-cloud-key --from-file=key.json=cre-dataplane .json
165
180
```
166
181
167
182
`google-cloud-key` and `key.json` are default values expected by our
@@ -178,5 +193,5 @@ the Google Service Account `cre-pubsub` credentials.
178
193
1. Delete the service account
179
194
180
195
```shell
181
- gcloud iam service-accounts delete cre-pubsub @$PROJECT_ID .iam.gserviceaccount.com
196
+ gcloud iam service-accounts delete cre-dataplane @$PROJECT_ID.iam.gserviceaccount.com
182
197
```
0 commit comments