Skip to content

Commit 020797c

Browse files
committed
add example using the existing Dev Services in the README.md
1 parent f8e539d commit 020797c

5 files changed

Lines changed: 87 additions & 0 deletions

File tree

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,93 @@ make test
5252

5353
Afterward, the project can be started in IntelliJ by navigating to `Run` -> `Run '...'`.
5454

55+
## Test the CRD on the Dev Services cluster and AI assistance
56+
57+
This example demonstrates how to set up a local development environment using Quarkus Dev Services and AI assistance to generate Kubernetes resources.
58+
59+
### 1. Configure Kubeconfig from Dev Services
60+
61+
When running in dev mode (`make run` or via IntelliJ), Quarkus starts the pre-configured K3s and PostgreSQL Dev Services.
62+
63+
1. Access the Quarkus Dev UI at [http://localhost:8080/q/dev-ui/dev-services](http://localhost:8080/q/dev-ui/dev-services).
64+
2. Locate the properties for the `kubernetes-client` Dev Service.
65+
3. Ask an AI to convert these properties into a **Kubeconfig YAML** format.
66+
4. Merge this configuration into your local `~/.kube/config`. This allows your local environment to communicate with the ephemeral Kubernetes cluster provided by Dev Services.
67+
68+
### 2. Create PostgreSQL Connection and Secret
69+
70+
For the `postgresql` Dev Service, you can generate the necessary Custom Resources to test the operator:
71+
72+
1. From the Dev UI, get the `postgresql` Dev Service properties (username, password, host, port).
73+
2. Ask the AI to convert the `postgresql` Dev Service properties to a **Basic Auth Secret** and a **ClusterConnection** CR instance.
74+
3. Provide the AI with the `ClusterConnection` CRD definition from `build/kubernetes/clusterconnections.postgresql.aboutbits.it-v1.yml` as a reference.
75+
4. Apply the generated files using IntelliJ or `kubectl`.
76+
![Apply Cluster Connection](docs/apply-cluster-connection.png)
77+
78+
**Example Secret (`secret.yml`):**
79+
80+
```yaml
81+
apiVersion: v1
82+
kind: Secret
83+
metadata:
84+
name: quarkus-db-secret
85+
labels:
86+
app.kubernetes.io/name: quarkus-postgres
87+
type: kubernetes.io/basic-auth
88+
stringData:
89+
# extracted from quarkus.datasource.username
90+
username: root
91+
# extracted from quarkus.datasource.password
92+
password: password
93+
```
94+
95+
**Example ClusterConnection (`cluster-connection.yml`):**
96+
97+
```yaml
98+
apiVersion: postgresql.aboutbits.it/v1
99+
kind: ClusterConnection
100+
metadata:
101+
name: quarkus-postgres-connection
102+
spec:
103+
adminSecretRef:
104+
name: quarkus-db-secret
105+
host: localhost
106+
port: 5432
107+
maintenanceDatabase: postgres
108+
```
109+
110+
![Established Cluster Connection](docs/established-cluster-connection.png)
111+
112+
### 3. Create a Role
113+
114+
Similarly, you can create a `Role` resource:
115+
116+
1. Ask the AI to convert the desired role properties to a **Role** CR instance.
117+
2. Provide the AI with the `Role` CRD definition from `build/kubernetes/roles.postgresql.aboutbits.it-v1.yml` as a reference.
118+
3. Apply the file using IntelliJ or `kubectl`.
119+
120+
**Example Role (`role.yml`):**
121+
122+
```yaml
123+
apiVersion: postgresql.aboutbits.it/v1
124+
kind: Role
125+
metadata:
126+
name: test-role-from-crd
127+
spec:
128+
# The actual name of the role to be created in the PostgreSQL database
129+
name: test-role-from-crd
130+
comment: It simply works
131+
# Connects this role definition to the specific Postgres ClusterConnection CR instance
132+
clusterRef:
133+
name: quarkus-postgres-connection
134+
flags:
135+
createdb: true
136+
validUntil: "2026-12-31T23:59:59Z"
137+
```
138+
139+
![Created Role](docs/created-role.png)
140+
![Role in pg_authid](docs/role-in-table-pg-authid.png)
141+
55142
## Packaging and running the application
56143

57144
The application can be packaged using:

docs/apply-cluster-connection.png

51.2 KB
Loading

docs/created-role.png

27.1 KB
Loading
46.6 KB
Loading

docs/role-in-table-pg-authid.png

83.5 KB
Loading

0 commit comments

Comments
 (0)