-
Notifications
You must be signed in to change notification settings - Fork 40
Feat: AIAC Event Broker + Keycloak SPI listener (phase 2, PR 2) #754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd31fa4
9041072
ad90b0a
eb85ee3
371ac40
b565000
e4601e8
f17aee4
092853d
0905561
425a8b1
9266f60
bee62e6
20a71eb
37bd3d0
4efbe29
9401264
aa2411e
b85f514
f1c7366
58f225e
9d3a36e
1c8372e
199da88
c92cb89
432a884
087d19b
8013618
316c8f7
3b05cdb
2639f81
f1e6ae4
677d103
591b433
091c0bf
24e855e
e2d37eb
bc5fdcf
2233b70
113bcf9
ba30155
cf5bf7d
9f79b42
37223c8
b55011f
1c3e319
89374fe
010215f
21bd3f0
1611ca1
c9540a1
80a44c4
ac78321
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: aiac-event-broker | ||
| namespace: aiac-system | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: aiac-event-broker | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: aiac-event-broker | ||
| spec: | ||
| # The stock image runs as root by default. fsGroup makes the mounted JetStream data | ||
| # volume group-writable by UID 10001, matching the rest of AIAC's non-root convention. | ||
| securityContext: | ||
| runAsNonRoot: true | ||
| runAsUser: 10001 | ||
| runAsGroup: 10001 | ||
| fsGroup: 10001 | ||
| seccompProfile: | ||
| type: RuntimeDefault | ||
| containers: | ||
| - name: nats | ||
| image: nats:2.14-alpine | ||
| imagePullPolicy: IfNotPresent | ||
| args: ["-js", "-sd", "/data/jetstream"] | ||
| ports: | ||
| - containerPort: 4222 | ||
| # JetStream data lives on its own volume; the rest of the root filesystem is | ||
| # read-only, so temp writes go to the /tmp emptyDir. | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| readOnlyRootFilesystem: true | ||
| capabilities: | ||
| drop: | ||
| - ALL | ||
| resources: | ||
| requests: | ||
| cpu: 50m | ||
| memory: 64Mi | ||
| limits: | ||
| cpu: 250m | ||
| memory: 256Mi | ||
| # No HTTP health endpoint on a plain "-js" NATS server (no -m monitoring port), so | ||
| # this uses tcpSocket like the repo's other non-HTTP workloads. | ||
| readinessProbe: | ||
| tcpSocket: | ||
| port: 4222 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| livenessProbe: | ||
| tcpSocket: | ||
| port: 4222 | ||
| initialDelaySeconds: 10 | ||
| periodSeconds: 20 | ||
| volumeMounts: | ||
| - name: jetstream-data | ||
| mountPath: /data/jetstream | ||
| - name: tmp | ||
| mountPath: /tmp | ||
| volumes: | ||
| # Dev-only: emptyDir means a pod restart or eviction drops the aiac-events stream and | ||
| # any unacked messages. aiac-init recreates the stream, but in-flight messages are lost. | ||
| # Fine while this broker is opt-in/inactive; switch to a PersistentVolumeClaim before | ||
| # this is wired live. | ||
| - name: jetstream-data | ||
| emptyDir: {} | ||
|
coderabbitai[bot] marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
Comment on lines
+60
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Use persistent storage for JetStream data.
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deliberately deferred rather than fixed as suggested — see clawgenti's adjacent comment on this same line, which asked for the lighter fix (a comment documenting the tradeoff) instead of a PVC. Went with that: kept There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The finding remains valid while JetStream uses 🐇 ✏️ Learnings added
You are interacting with an AI system.
omerboehm marked this conversation as resolved.
|
||
| - name: tmp | ||
| emptyDir: {} | ||
|
|
||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: aiac-event-broker-service | ||
| namespace: aiac-system | ||
| spec: | ||
| selector: | ||
| app: aiac-event-broker | ||
| ports: | ||
| - name: nats | ||
| port: 4222 | ||
| targetPort: 4222 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| target/ | ||
| .idea/ | ||
| .vscode/ | ||
| .git/ | ||
| .gitignore | ||
| *.iml | ||
| README.md | ||
| Makefile |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Maven build output — regenerated by `mvn package`, never committed. | ||
| target/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # syntax=docker/dockerfile:1.7 | ||
|
|
||
| ARG KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:26.6.3 | ||
|
|
||
| # Stage 1: build the SPI JAR (shaded — bundles jnats, since it isn't on Keycloak's classpath). | ||
| FROM maven:3.9-eclipse-temurin-17 AS jar-builder | ||
| WORKDIR /build | ||
| COPY pom.xml . | ||
| COPY src ./src | ||
| RUN --mount=type=cache,target=/root/.m2 mvn -B -DskipTests package | ||
|
|
||
| # Stage 2: drop the JAR into Keycloak and run `kc.sh build` so the augmented server is baked | ||
| # into the final image (no per-pod build at startup). | ||
| FROM ${KEYCLOAK_IMAGE} AS keycloak-builder | ||
| COPY --from=jar-builder /build/target/aiac-event-listener-*.jar /opt/keycloak/providers/ | ||
| RUN /opt/keycloak/bin/kc.sh build | ||
|
|
||
| # Stage 3: final runtime image — copy the augmented Keycloak from stage 2. | ||
| FROM ${KEYCLOAK_IMAGE} | ||
| COPY --from=keycloak-builder /opt/keycloak/ /opt/keycloak/ | ||
| # Match the AIAC non-root UID convention (10001) used by every other service container in this | ||
| # repo, instead of the base image's default UID 1000. /opt/keycloak is group-writable by GID 0 | ||
| # (the base image's own "arbitrary UID" convention), so UID 10001 in group 0 already has the | ||
| # access it needs — no useradd/chown required. | ||
| USER 10001:0 | ||
| ENTRYPOINT ["/opt/keycloak/bin/kc.sh"] | ||
| CMD ["start"] | ||
|
omerboehm marked this conversation as resolved.
|
||
Uh oh!
There was an error while loading. Please reload this page.