Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "time"
type SessionMessage struct {
ID string `gorm:"column:id;primaryKey;type:varchar(36)" json:"id"`
SessionID string `gorm:"column:session_id;type:varchar(36)" json:"session_id"`
Seq int64 `gorm:"column:seq" json:"seq"`
Seq int64 `gorm:"column:seq;->" json:"seq"`
EventType string `gorm:"column:event_type;type:varchar(255)" json:"event_type"`
Payload string `gorm:"column:payload;type:text" json:"payload"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamptz" json:"created_at"`
Expand Down
26 changes: 26 additions & 0 deletions components/manifests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ Components are opt-in kustomize modules included via the `components:` block in
| `ambient-api-server-db` | Same RHEL patch for the ambient-api-server's dedicated DB | `production`, `local-dev` |
| `postgresql-init-scripts` | ConfigMap + volume for DB init SQL (vanilla postgres only) | `kind`, `e2e` |

## Prerequisites for New Deployments

Before deploying, create these secrets in the target namespace:

### Control-plane OIDC credentials

The control-plane authenticates to the api-server using Keycloak client credentials (OAuth2 `client_credentials` grant). Create a **confidential** Keycloak client with only the **Service accounts roles** flow enabled, then:

```bash
oc create secret generic ambient-control-plane-oidc \
-n <namespace> \
--from-literal=client-id=<keycloak-client-id> \
--from-literal=client-secret=<keycloak-client-secret>
```

### API server auth ConfigMap

The api-server validates JWTs using keys from the Keycloak JWKS endpoint (configured via `--jwk-cert-url`). A local fallback is also loaded from a ConfigMap:

```bash
oc create configmap ambient-api-server-auth \
-n <namespace> \
--from-file=jwks.json=<(curl -s <KEYCLOAK_REALM_URL>/protocol/openid-connect/certs) \
--from-file=acl.yml=<(echo '- claim: email\n pattern: ^.*$')
Comment on lines +149 to +150

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix ACL ConfigMap command: current echo likely writes literal \n

Line 150 uses echo with \n inside single quotes, which commonly produces a single-line literal string instead of valid YAML. That can break ACL loading for authz.

Suggested fix
-  --from-file=acl.yml=<(echo '- claim: email\n  pattern: ^.*$')
+  --from-file=acl.yml=<(printf '%s\n' '- claim: email' '  pattern: ^.*$')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/manifests/README.md` around lines 149 - 150, The ACL ConfigMap
command currently uses echo with a literal '\n' which produces a single-line
string; update the command that generates acl.yml (the --from-file=acl.yml part)
to emit a real multi-line YAML string (for example use printf, echo -e, or a
shell $'...' quoted string) so the resulting acl.yml contains actual newlines
and valid YAML mapping for the claim and pattern; ensure the command still runs
in a POSIX shell and produces content matching "- claim: email\n  pattern: ^.*$"
across two lines so ACL loading works correctly.

```

## Building and Validating

```bash
Expand Down
13 changes: 10 additions & 3 deletions components/manifests/overlays/hcmais/control-plane-env-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ spec:
value: "false"
- name: CP_TOKEN_URL
value: "http://ambient-control-plane.ambient-api.svc:8080/token"
- name: AMBIENT_API_TOKEN
- name: OIDC_TOKEN_URL
value: "https://keycloak-ambient-keycloak.apps.rosa.hcmais01ue1.s9m2.p3.openshiftapps.com/realms/ambient-code/protocol/openid-connect/token"
- name: OIDC_CLIENT_ID
valueFrom:
secretKeyRef:
name: ambient-control-plane-token
key: token
name: ambient-control-plane-oidc
key: client-id
- name: OIDC_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: ambient-control-plane-oidc
key: client-secret
29 changes: 18 additions & 11 deletions components/manifests/templates/template-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ objects:
initialDelaySeconds: 30
periodSeconds: 30
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
Expand Down Expand Up @@ -189,6 +190,7 @@ objects:
cpu: 500m
memory: 512Mi
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
Expand All @@ -200,13 +202,11 @@ objects:
env:
- name: AMBIENT_ENV
value: production
- name: AMBIENT_API_TOKEN
- name: GRPC_SERVICE_ACCOUNT
valueFrom:
secretKeyRef:
name: ambient-control-plane-token
key: token
- name: JWK_CERT_URL
value: "${KEYCLOAK_REALM_URL}/protocol/openid-connect/certs"
name: ambient-control-plane-oidc
key: client-id
- name: CREDENTIAL_ENCRYPTION_KEYRING
valueFrom:
secretKeyRef:
Expand All @@ -219,8 +219,6 @@ objects:
name: credential-encryption-key
key: version
optional: true
- name: CREDENTIAL_ENCRYPTION_ALLOW_PLAINTEXT
value: "true"
command:
- /usr/local/bin/ambient-api-server
- serve
Expand All @@ -230,8 +228,9 @@ objects:
- --db-password-file=/secrets/db/db.password
- --db-name-file=/secrets/db/db.name
- --enable-jwt=true
- --enable-authz=false
- --enable-authz=true
- --jwk-cert-file=/configs/authentication/jwks.json
- --jwk-cert-url=${KEYCLOAK_REALM_URL}/protocol/openid-connect/certs
- --enable-https=false
- --enable-grpc=true
- --grpc-enable-tls=false
Expand Down Expand Up @@ -295,6 +294,7 @@ objects:
initialDelaySeconds: 20
periodSeconds: 10
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
Expand Down Expand Up @@ -375,11 +375,18 @@ objects:
value: standard
- name: LOG_LEVEL
value: info
- name: AMBIENT_API_TOKEN
- name: OIDC_TOKEN_URL
value: "${KEYCLOAK_REALM_URL}/protocol/openid-connect/token"
- name: OIDC_CLIENT_ID
valueFrom:
secretKeyRef:
name: ambient-control-plane-oidc
key: client-id
- name: OIDC_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: ambient-control-plane-token
key: token
name: ambient-control-plane-oidc
key: client-secret
- name: AMBIENT_API_SERVER_URL
value: "http://ambient-api-server.${NAMESPACE}.svc:8000"
- name: AMBIENT_GRPC_SERVER_ADDR
Expand Down
Loading