Skip to content

Commit c38569f

Browse files
docs: update environment variables according to CLI outputs (#561)
1 parent fa22df1 commit c38569f

File tree

10 files changed

+54
-53
lines changed

10 files changed

+54
-53
lines changed

code-examples/quarkus-kafka-quickstart/src/main/resources/application.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ quarkus.container-image.push=false
2626

2727
%dev.kafka.sasl.mechanism=OAUTHBEARER
2828
%dev.kafka.sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required \
29-
oauth.client.id="${RHOAS_CLIENT_ID}" \
30-
oauth.client.secret="${RHOAS_CLIENT_SECRET}" \
31-
oauth.token.endpoint.uri="${RHOAS_OAUTH_TOKEN_URL}" ;
29+
oauth.client.id="${RHOAS_SERVICE_ACCOUNT_CLIENT_ID}" \
30+
oauth.client.secret="${RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET}" \
31+
oauth.token.endpoint.uri="${RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL}" ;
3232
%dev.kafka.sasl.login.callback.handler.class=io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler
3333

3434
## sbo-dev profile that can be used for local development when using

code-examples/quarkus-service-registry-quickstart/consumer/.env

Lines changed: 0 additions & 6 deletions
This file was deleted.

code-examples/quarkus-service-registry-quickstart/consumer/src/main/resources/application.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ mp.messaging.incoming.quotes.value.deserializer=io.apicurio.registry.serde.avro.
44
mp.messaging.incoming.quotes.apicurio.registry.use-specific-avro-reader=true
55
mp.messaging.incoming.quotes.apicurio.registry.avro-datum-provider=io.apicurio.registry.serde.avro.ReflectAvroDatumProvider
66

7-
%dev.mp.messaging.incoming.quotes.apicurio.auth.service.token.endpoint=${RHOAS_OAUTH_TOKEN_URL:https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token}
8-
%dev.mp.messaging.incoming.quotes.apicurio.auth.client.id=${RHOAS_CLIENT_ID}
9-
%dev.mp.messaging.incoming.quotes.apicurio.auth.client.secret=${RHOAS_CLIENT_SECRET}
7+
%dev.mp.messaging.incoming.quotes.apicurio.auth.service.token.endpoint=${RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL:https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token}
8+
%dev.mp.messaging.incoming.quotes.apicurio.auth.client.id=${RHOAS_SERVICE_ACCOUNT_CLIENT_ID}
9+
%dev.mp.messaging.incoming.quotes.apicurio.auth.client.secret=${RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET}
1010

1111
mp.messaging.connector.smallrye-kafka.apicurio.registry.url=${SERVICE_REGISTRY_URL}${SERVICE_REGISTRY_CORE_PATH}
1212

@@ -19,7 +19,7 @@ mp.messaging.connector.smallrye-kafka.apicurio.registry.url=${SERVICE_REGISTRY_U
1919

2020
%dev.kafka.sasl.mechanism=OAUTHBEARER
2121
%dev.kafka.sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required \
22-
oauth.client.id="${RHOAS_CLIENT_ID}" \
23-
oauth.client.secret="${RHOAS_CLIENT_SECRET}" \
24-
oauth.token.endpoint.uri="${RHOAS_OAUTH_TOKEN_URL}" ;
22+
oauth.client.id="${RHOAS_SERVICE_ACCOUNT_CLIENT_ID}" \
23+
oauth.client.secret="${RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET}" \
24+
oauth.token.endpoint.uri="${RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL}" ;
2525
%dev.kafka.sasl.login.callback.handler.class=io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler

code-examples/quarkus-service-registry-quickstart/producer/.env

Lines changed: 0 additions & 6 deletions
This file was deleted.

code-examples/quarkus-service-registry-quickstart/producer/src/main/resources/application.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ mp.messaging.outgoing.quotes.value.serializer=io.apicurio.registry.serde.avro.Av
1010
mp.messaging.outgoing.quotes.key.serializer=org.apache.kafka.common.serialization.StringSerializer
1111
mp.messaging.outgoing.quotes.merge=true
1212

13-
%dev.mp.messaging.outgoing.quotes.apicurio.auth.service.token.endpoint=${RHOAS_OAUTH_TOKEN_URL:https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token}
14-
%dev.mp.messaging.outgoing.quotes.apicurio.auth.client.id=${RHOAS_CLIENT_ID}
15-
%dev.mp.messaging.outgoing.quotes.apicurio.auth.client.secret=${RHOAS_CLIENT_SECRET}
13+
%dev.mp.messaging.outgoing.quotes.apicurio.auth.service.token.endpoint=${RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL:https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token}
14+
%dev.mp.messaging.outgoing.quotes.apicurio.auth.client.id=${RHOAS_SERVICE_ACCOUNT_CLIENT_ID}
15+
%dev.mp.messaging.outgoing.quotes.apicurio.auth.client.secret=${RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET}
1616

1717
mp.messaging.connector.smallrye-kafka.apicurio.registry.url=${SERVICE_REGISTRY_URL}${SERVICE_REGISTRY_CORE_PATH}
1818
%test.quarkus.apicurio-registry.devservices.port=8888
@@ -25,7 +25,7 @@ mp.messaging.connector.smallrye-kafka.apicurio.registry.url=${SERVICE_REGISTRY_U
2525

2626
%dev.kafka.sasl.mechanism=OAUTHBEARER
2727
%dev.kafka.sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required \
28-
oauth.client.id="${RHOAS_CLIENT_ID}" \
29-
oauth.client.secret="${RHOAS_CLIENT_SECRET}" \
30-
oauth.token.endpoint.uri="${RHOAS_OAUTH_TOKEN_URL}" ;
28+
oauth.client.id="${RHOAS_SERVICE_ACCOUNT_CLIENT_ID}" \
29+
oauth.client.secret="${RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET}" \
30+
oauth.token.endpoint.uri="${RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL}" ;
3131
%dev.kafka.sasl.login.callback.handler.class=io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler

docs/kafka/kcat-kafka/README.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ endif::[]
159159
[source,subs="+quotes"]
160160
----
161161
$ export KAFKA_HOST=__<bootstrap_server>__
162-
$ export RHOAS_CLIENT_ID=__<client_id>__
163-
$ export RHOAS_CLIENT_SECRET=__<client_secret>__
162+
$ export RHOAS_SERVICE_ACCOUNT_CLIENT_ID=__<client_id>__
163+
$ export RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET=__<client_secret>__
164164
----
165165
--
166166

@@ -186,8 +186,8 @@ This example uses the SASL/PLAIN authentication mechanism with the server and cr
186186
----
187187
$ kafkacat -t my-first-kafka-topic -b "$KAFKA_HOST" \
188188
-X security.protocol=SASL_SSL -X sasl.mechanisms=PLAIN \
189-
-X sasl.username="$RHOAS_CLIENT_ID" \
190-
-X sasl.password="$RHOAS_CLIENT_SECRET" -P
189+
-X sasl.username="$RHOAS_SERVICE_ACCOUNT_CLIENT_ID" \
190+
-X sasl.password="$RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET" -P
191191
----
192192

193193
NOTE: {product-kafka} also supports the SASL/OAUTHBEARER mechanism for authentication, which is the recommended authentication mechanism to use. However, Kafkacat does not yet fully support OAUTHBEARER, so this example uses SASL/PLAIN.
@@ -237,8 +237,8 @@ This example uses the SASL/PLAIN authentication mechanism with the server and cr
237237
----
238238
$ kafkacat -t my-first-kafka-topic -b "$KAFKA_HOST" \
239239
-X security.protocol=SASL_SSL -X sasl.mechanisms=PLAIN \
240-
-X sasl.username="$RHOAS_CLIENT_ID" \
241-
-X sasl.password="$RHOAS_CLIENT_SECRET" -C
240+
-X sasl.username="$RHOAS_SERVICE_ACCOUNT_CLIENT_ID" \
241+
-X sasl.password="$RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET" -C
242242
243243
First message
244244
Second message

docs/kafka/nodejs-kafka/README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ endif::[]
165165
[source,subs="+quotes"]
166166
----
167167
KAFKA_HOST=__<bootstrap_server>__
168-
RHOAS_CLIENT_ID=__<client_id>__
169-
RHOAS_CLIENT_SECRET=__<client_secret>__
168+
RHOAS_SERVICE_ACCOUNT_CLIENT_ID=__<client_id>__
169+
RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET=__<client_secret>__
170170
KAFKA_SASL_MECHANISM=plain
171171
----
172172
ifdef::qs[]

docs/kafka/quarkus-kafka/README.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ endif::[]
160160
[source,subs="+quotes"]
161161
----
162162
$ export KAFKA_HOST=__<bootstrap_server>__
163-
$ export RHOAS_CLIENT_ID=__<client_id>__
164-
$ export RHOAS_CLIENT_SECRET=__<client_secret>__
165-
$ export RHOAS_OAUTH_TOKEN_URL=__<oauth_token_endpoint_uri>__
163+
$ export RHOAS_SERVICE_ACCOUNT_CLIENT_ID=__<client_id>__
164+
$ export RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET=__<client_secret>__
165+
$ export RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL=__<oauth_token_endpoint_uri>__
166166
----
167167
--
168168
. In the Quarkus example application, review the `src/main/resources/application.properties` file to understand how the environment variables you set in the previous step are used in your application. This example uses the `dev` configuration profile in the `application.properties` file.

docs/registry/quarkus-registry/README.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ This Quarkus example application includes producer and consumer processes that s
170170
$ export KAFKA_HOST=__<bootstrap_server>__
171171
$ export SERVICE_REGISTRY_URL=__<service_registry_url>__
172172
$ export SERVICE_REGISTRY_CORE_PATH=/apis/registry/v2
173-
$ export RHOAS_OAUTH_TOKEN_URL=__<oauth_token_endpoint_uri>__
174-
$ export RHOAS_CLIENT_ID=__<client_id>__
175-
$ export RHOAS_CLIENT_SECRET=__<client_secret>__
173+
$ export RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL=__<oauth_token_endpoint_uri>__
174+
$ export RHOAS_SERVICE_ACCOUNT_CLIENT_ID=__<client_id>__
175+
$ export RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET=__<client_secret>__
176176
----
177177

178178
. In the Quarkus example application, review the `/src/main/resources/application.properties` files in the `consumer` and `producer` sub-folders to understand how the environment variables you set in the previous step are used. This example uses the `dev` configuration profile in the `application.properties` files.

docs/rhoas/rhoas-service-contexts/README.adoc

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ In {product-long-rhoas}, a service context is a defined set of instances running
108108

109109
To create a context, you can use the {product-long-rhoas} (`rhoas`) command-line interface (CLI). New service instances that you create are automatically added to the context that is currently in use. You can switch between different contexts and add or remove service instances as required. You can include the same service instance in multiple contexts.
110110

111-
When you have created a service context, you can use a single CLI command to generate the configuration information that client applications need to connect to the instances in that context. You can generate connection configuration information in various formats such as an environment variables file (.env), a JSON file, a Java properties file, and a Kubernetes secret.
111+
When you have created a service context, you can use a single CLI command to generate the configuration information that client applications need to connect to the instances in that context. You can generate connection configuration information in various formats such as an environment variables file (.env), a JSON file, a Java properties file, and a Kubernetes ConfigMap.
112112

113113
[id="proc-creating-new-service-contexts_{context}"]
114114
== Creating new service contexts
@@ -277,14 +277,28 @@ $ rhoas context use --name development-context
277277
$ cd ~/app-services-guides/code-examples/quarkus-service-registry-quickstart/
278278
----
279279

280+
. Create a service account for the Quarkus application to authenticate with the Kafka and {registry} instances in the context. Save the credentials in an environment variables file in the directory for the producer component.
281+
+
282+
[source,shell]
283+
----
284+
$ rhoas service-account create --type env --output-file ./producer/.env
285+
----
286+
280287
. Generate an environment variables file that contains the connection configuration information required by the producer component.
281288
+
282289
[source,shell]
283290
----
284-
$ rhoas generate-config --type env --output-file ./producer/.env
291+
$ rhoas generate-config --type env --output-file ./producer/rhoas.env
285292
----
286293

287-
. Copy the `.env` file to the directory for the consumer component, as shown in the following Linux example:
294+
. Append the contents of the connection configuration file to the service account environment variables file.
295+
+
296+
[source,shell]
297+
----
298+
$ cat ./producer/rhoas.env >> ./producer/.env
299+
----
300+
301+
. Copy the updated `.env` file to the directory for the consumer component, as shown in the following Linux example:
288302
+
289303
[source,shell]
290304
----
@@ -293,24 +307,23 @@ $ cp ./producer/.env ./consumer/.env
293307
+
294308
For a service context with single Kafka and {registry} instances, the `.env` file looks like the following example:
295309
+
296-
.Example environment variables file for connection configuration information
310+
.Example environment variables file for connection configuration and credentials
297311
[source,shell,subs="+attributes,+quotes"]
298312
----
299313
\\## Generated by rhoas cli
300-
## Kafka Configuration
314+
RHOAS_SERVICE_ACCOUNT_CLIENT_ID=_<client-id>_
315+
RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET=_<client-secret>_
316+
RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL={sso-token-url}
317+
## Generated by rhoas cli
318+
\\## Kafka Configuration
301319
KAFKA_HOST=kafka-inst-cafkr-jma--lhulbl-ca.bf2.kafka.rhcloud.com:443
302-
\\## Service Registry Configuration
320+
## Service Registry Configuration
303321
SERVICE_REGISTRY_URL=https://bu98.serviceregistry.rhcloud.com/t/0aa1dd8b-63d5-466c-9de8-7c03320a81c2
304322
SERVICE_REGISTRY_CORE_PATH=/apis/registry/v2
305323
SERVICE_REGISTRY_COMPAT_PATH=/apis/ccompat/v6
306-
307-
## Authentication Configuration
308-
RHOAS_CLIENT_ID=_<client-id>_
309-
RHOAS_CLIENT_SECRET=_<client-secret>_
310-
RHOAS_OAUTH_TOKEN_URL={sso-token-url}
311324
----
312325
+
313-
As shown in the example, the file that you generate contains the endpoints for your service instances, and the credentials required to connect to those instances. The CLI automatically created a service account (under the environment variable name `RHOAS_CLIENT_ID`) that client applications can use to authenticate with the Kafka and {registry} instances.
326+
As shown in the example, the file that you generate contains the endpoints for your service instances, and the credentials required to connect to those instances.
314327

315328
. Set Access Control List (ACL) permissions to enable the new service account to access resources in the Kafka instance.
316329
+

0 commit comments

Comments
 (0)