Skip to content

Commit 15302a5

Browse files
maysunfaisalclaude
andcommitted
refactor(lightspeed): define OKP resources in flavour YAML [RHIDP-16103]
Move the OKP (Offline Knowledge Portal) Deployment, Service, and Route out of imperative Go construction in internal/controller/okp.go and into the lightspeed flavour as YAML manifests, so OKP is described like every other flavour resource and its image string rides in the bundle ConfigMap (visible to midstream image pinning). Addresses PR #3370 review comment: "should OKP be in the flavour YAML rather than Go?". Each OKP object is a separately registered model key (OkpDeploymentKey, OkpServiceKey, OkpRouteKey) with its own MergeFunc, and stays gated to OpenShift in addToModel. Flavour gating is implicit (files live only in flavours/lightspeed/). The runtime behavior is unchanged: same objects, same OpenShift-only gating, same OKP_SERVICE_URL injection into the lightspeed-core sidecar before apply (no dual ReplicaSet). Remove applyOkpResources; OKP now flows through the normal applyObjects(GetRuntimeObjects()) SSA path. Keep prepareOkpEnvVar and prepareOkpConfig as controller wiring. Regenerate bundle manifests and dist/rhdh/install.yaml. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3bbec01 commit 15302a5

15 files changed

Lines changed: 698 additions & 317 deletions

File tree

bundle/rhdh/manifests/rhdh-flavour-lightspeed-config_v1_configmap.yaml

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# OKP (Offline Knowledge Portal) standalone Deployment.
2+
# name/labels/selector are set by the operator at runtime (per Backstage CR); the values
3+
# below are placeholders. The image ref is intentionally declared here (not in Go source)
4+
# so midstream digest-pinning can resolve it in the generated bundle ConfigMap.
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: lightspeed-okp
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app.kubernetes.io/name: lightspeed-okp
14+
template:
15+
metadata:
16+
labels:
17+
app.kubernetes.io/name: lightspeed-okp
18+
spec:
19+
containers:
20+
- name: okp
21+
image: registry.redhat.io/offline-knowledge-portal/rhokp-rhel9:1.2.10-1786628394
22+
imagePullPolicy: IfNotPresent
23+
ports:
24+
- name: httpd
25+
containerPort: 8080
26+
protocol: TCP
27+
- name: solr
28+
containerPort: 8983
29+
protocol: TCP
30+
env:
31+
- name: SOLR_JAVA_MEM
32+
value: "-Xms1g -Xmx1g"
33+
- name: SOLR_HOST_BIND
34+
value: "0.0.0.0"
35+
- name: HTTPD_SERVER_NAME
36+
value: "localhost"
37+
- name: HTTPD_COMPRESSED
38+
value: "true"
39+
- name: HTTPD_ENCRYPT
40+
value: "false"
41+
resources:
42+
requests:
43+
cpu: 200m
44+
memory: 2Gi
45+
limits:
46+
cpu: "2"
47+
memory: 4Gi
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# OKP (Offline Knowledge Portal) standalone OpenShift Route.
2+
# name/labels and spec.to.name are set by the operator at runtime (per Backstage CR).
3+
# Applied on OpenShift only.
4+
apiVersion: route.openshift.io/v1
5+
kind: Route
6+
metadata:
7+
name: lightspeed-okp
8+
spec:
9+
to:
10+
kind: Service
11+
name: lightspeed-okp
12+
port:
13+
targetPort: httpd
14+
tls:
15+
termination: edge
16+
insecureEdgeTerminationPolicy: Allow
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# OKP (Offline Knowledge Portal) standalone ClusterIP Service.
2+
# name/labels/selector are set by the operator at runtime (per Backstage CR).
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: lightspeed-okp
7+
spec:
8+
type: ClusterIP
9+
selector:
10+
app.kubernetes.io/name: lightspeed-okp
11+
ports:
12+
- name: httpd
13+
port: 8080
14+
targetPort: httpd
15+
protocol: TCP
16+
- name: solr
17+
port: 8983
18+
targetPort: solr
19+
protocol: TCP

config/profile/rhdh/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ configMapGenerator:
5353
- default-config/flavours/lightspeed/configmap-files.yaml
5454
- default-config/flavours/lightspeed/deployment.yaml
5555
- default-config/flavours/lightspeed/dynamic-plugins.yaml
56+
- default-config/flavours/lightspeed/okp-deployment.yaml
57+
- default-config/flavours/lightspeed/okp-service.yaml
58+
- default-config/flavours/lightspeed/okp-route.yaml
5659
name: flavour-lightspeed-config
5760
- files:
5861
- default-config/flavours/orchestrator/metadata.yaml

dist/rhdh/install.yaml

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/backstage_controller.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,13 @@ func (r *BackstageReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
115115
// Inject OKP_SERVICE_URL into lightspeed-core before applying objects
116116
r.prepareOkpEnvVar(&backstage, bsModel)
117117

118-
// Apply the runtime objects
118+
// Apply the runtime objects (OKP Deployment/Service/Route are part of the model,
119+
// sourced from the lightspeed flavour YAML and gated to OpenShift in pkg/model/okp-*.go)
119120
err = r.applyObjects(ctx, bsModel.GetRuntimeObjects())
120121
if err != nil {
121122
return ctrl.Result{}, errorAndStatus(&backstage, "failed to apply backstage objects", err)
122123
}
123124

124-
// Apply OKP resources if lightspeed flavour is enabled
125-
if err := r.applyOkpResources(ctx, &backstage, bsModel); err != nil {
126-
return ctrl.Result{}, errorAndStatus(&backstage, "failed to apply OKP resources", err)
127-
}
128-
129125
r.setDeploymentStatus(ctx, &backstage, *bsModel)
130126
return ctrl.Result{}, nil
131127
}

0 commit comments

Comments
 (0)