Skip to content

Commit 14bc1db

Browse files
feat: add example helm chart (#587)
1 parent 2741367 commit 14bc1db

File tree

7 files changed

+160
-4
lines changed

7 files changed

+160
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v2
2+
name: rhoas-helm-example
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
appVersion: 1.16.0
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# rhoas-helm-template
2+
3+
Example how to use RHOAS services with Helm.
4+
This example deploys Kafka Example application to your cluster.
5+
6+
## Running the chart:
7+
8+
1. Generate connection configuration as ConfigMap:
9+
10+
```
11+
rhoas generate-config --type configmap --output-file ./rhoas-services.yaml
12+
```
13+
14+
2. Create service account and save its credentials as a Secret
15+
16+
```
17+
$ rhoas service-account create --file-format secret --output-file ./rhoas-secrets.yaml
18+
```
19+
20+
3. Grant permission to the service account to produce and consume messages from Kafka instance:
21+
22+
```
23+
rhoas kafka acl grant-access --producer --consumer --service-account <service-account-id> --topic all --group all
24+
```
25+
26+
4. Apply the ConfigMap and Secret to the OpenShift cluster
27+
28+
```
29+
$ oc apply -f ./rhoas-secrets.yaml
30+
```
31+
32+
```
33+
$ oc apply -f ./rhoas-services.yaml
34+
```
35+
36+
5. Deploy the helm chart setting the appropriate values:
37+
38+
```
39+
$ helm install . --generate-name --set-string rhoas.config=<configmap-name>,rhoas.secret=<secret-name>
40+
```
41+
42+
To see how to use this code example follow the [guide](../../docs/rhoas/rhoas-helm-guide/).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: rhoas-quarkus-kafka-quickstart
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
name: rhoas-quarkus-kafka-quickstart
10+
version: 1.0-SNAPSHOT
11+
template:
12+
metadata:
13+
labels:
14+
name: rhoas-quarkus-kafka-quickstart
15+
version: 1.0-SNAPSHOT
16+
spec:
17+
containers:
18+
- env:
19+
- name: KAFKA_HOST
20+
valueFrom:
21+
configMapKeyRef:
22+
name: {{ .Values.rhoas.config }}
23+
key: kafka_host
24+
- name: RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL
25+
valueFrom:
26+
secretKeyRef:
27+
name: {{ .Values.rhoas.secret }}
28+
key: RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL
29+
- name: RHOAS_SERVICE_ACCOUNT_CLIENT_ID
30+
valueFrom:
31+
secretKeyRef:
32+
name: {{ .Values.rhoas.secret }}
33+
key: RHOAS_SERVICE_ACCOUNT_CLIENT_ID
34+
- name: RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET
35+
valueFrom:
36+
secretKeyRef:
37+
name: {{ .Values.rhoas.secret }}
38+
key: RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET
39+
image: rkpattnaik/quarkus-kafka-quickstart:1.0-SNAPSHOT
40+
imagePullPolicy: Always
41+
name: rhoas-quarkus-kafka-quickstart
42+
ports:
43+
- containerPort: 8080
44+
name: http
45+
protocol: TCP
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
name: rhoas-quarkus-kafka-quickstart
6+
version: 1.0-SNAPSHOT
7+
name: rhoas-quarkus-kafka-quickstart
8+
spec:
9+
selector:
10+
name: rhoas-quarkus-kafka-quickstart
11+
version: 1.0-SNAPSHOT
12+
type: LoadBalancer
13+
ports:
14+
- protocol: TCP
15+
port: 8080
16+
targetPort: 8080
17+
nodePort: 31110
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## RHOAS Config
2+
rhoas:
3+
config: my-context-3-configuration
4+
secret: service-account-credentials

docs/rhoas/rhoas-helm-guide/README.adoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ env:
169169
----
170170
+
171171
Helm renders the value for ConfigMap name and generates the manifest file for the deployment.
172-
The values can be fetched from the Values.yaml file which is native to Helm, or a different file can be used by passing the file name to “--values” flag:
172+
The values can be fetched from the `values.yaml` file which is native to Helm, or a different file can be used by passing the file name to “--values” flag:
173173
+
174174
[source,shell]
175175
----
@@ -278,20 +278,22 @@ $ helm install . --generate-name --set-string rhoas.secret=service-account-crede
278278
[id="proc-connecting-helm-chart-with-application-services_{context}"]
279279
== Connecting a Helm chart to Application Services
280280

281-
The following example shows how to connect an https://github.com/rkpattnaik780/rhoas-helm-example:[example Helm chart] to the service instances defined in a context in OpenShift Application Services. The example Helm chart contains Kubernetes resources required to deploy the application used in https://github.com/redhat-developer/app-services-guides/tree/main/code-examples/quarkus-kafka-quickstart:[Quarkus Kafka quickstart] in a Kubernetes cluster.
281+
The following example shows how to connect an https://github.com/redhat-developer/app-services-guides/tree/main/code-examples/helm-kafka-example:[example Helm chart] to the service instances defined in a context in OpenShift Application Services. The example Helm chart contains Kubernetes resources required to deploy the application used in https://github.com/redhat-developer/app-services-guides/tree/main/code-examples/quarkus-kafka-quickstart:[Quarkus Kafka quickstart] in a Kubernetes cluster.
282282

283283
Once we have the files for connection configuration and credentials. We can use it with an example Helm chart that uses the values.
284284
Now we will be using the generated configurations and credentials with the Helm example.
285285

286286
.Procedure
287287

288-
. On the command line, clone the example repository from GitHub.
288+
. On the command line, clone the {product-kafka} {samples-git-repo}[Guides and Samples^] repository from GitHub.
289289
+
290290
[source,shell]
291291
----
292-
$ git clone https://github.com/rkpattnaik780/rhoas-helm-example.git
292+
git clone https://github.com/redhat-developer/app-services-guides app-services-guides
293293
----
294294

295+
. In your IDE, open the `code-examples/helm-kafka-example` directory from the repository that you cloned.
296+
295297
. Log in to the CLI.
296298
+
297299
[source,shell]

0 commit comments

Comments
 (0)