Skip to content

adding openshift template#12

Merged
omertuc merged 1 commit intorh-ecosystem-edge:mainfrom
zszabo-rh:openshift_template
Jul 8, 2025
Merged

adding openshift template#12
omertuc merged 1 commit intorh-ecosystem-edge:mainfrom
zszabo-rh:openshift_template

Conversation

@zszabo-rh
Copy link
Collaborator

@zszabo-rh zszabo-rh commented Jul 4, 2025

Openshift template for Lightspeed stack (+llama stack)

Creates Route, Service, Deployment, PVC (for persistent data like sqlite, feedback and transcript) , and ConfigMap (lightspeed stack yamls) objects.

GEMINI_API_KEY is replaced with a k8s Secret, which needs to be created first before applying this template:
oc create secret generic assisted-chat-gemini-secret --from-literal=api-key="your-actual-gemini-api-key"

Summary by CodeRabbit

  • New Features
    • Introduced a new OpenShift template for deploying the assisted-chat service integrated with the lightspeed-stack.
    • Supports flexible configuration options, including image selection, resource limits, storage, telemetry, and model inference settings.
    • Enables secure API key management and external access via service exposure.
    • Includes configurable deployment settings such as replica count, readiness and liveness probes, and feature toggles for authentication and feedback collection.

@coderabbitai
Copy link

coderabbitai bot commented Jul 4, 2025

Walkthrough

A new OpenShift template named assisted-chat has been added in template.yaml. This template defines parameters and specifies the creation of Kubernetes/OpenShift resources including two ConfigMaps, a Deployment, and a Service for deploying the assisted-chat service integrated with the lightspeed-stack.

Changes

File(s) Change Summary
template.yaml Added new OpenShift template assisted-chat with parameters and resource definitions for two ConfigMaps, Deployment, and Service

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant OpenShift
    participant ConfigMaps
    participant assisted-chat Deployment
    participant Service

    User->>OpenShift: Instantiate assisted-chat template
    OpenShift->>ConfigMaps: Create lightspeed-stack and llama-stack-client ConfigMaps
    OpenShift->>assisted-chat Deployment: Deploy container with configs and secrets
    assisted-chat Deployment->>Service: Expose service on configured port
    User->>Service: Access assisted-chat application
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c63b50 and 84aad60.

📒 Files selected for processing (1)
  • template.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • template.yaml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zszabo-rh zszabo-rh force-pushed the openshift_template branch 2 times, most recently from 7236d54 to 84f6233 Compare July 4, 2025 11:53
@zszabo-rh
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jul 4, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
template.yaml (3)

82-82: Trim trailing whitespace

YAML linters flag the blank space at the end of this line.

-    api-key: "" 
+    api-key: ""

317-324: ReadWriteMany may not be available; make the access mode configurable

Most default storage classes (e.g., gp2 on AWS or standard on GCP) only support ReadWriteOnce. Hard-coding ReadWriteMany will cause the PVC to remain Pending on those platforms.

-    accessModes:
-    - ReadWriteMany
+    accessModes:
+    - ${STORAGE_ACCESS_MODE}

Add STORAGE_ACCESS_MODE to the parameters list with a sane default (ReadWriteOnce).


2-30: Parameters lack descriptions and display names

Providing description (and optionally displayName) for each parameter greatly improves oc explain template output and the Web Console form generation.

Example:

 - name: IMAGE
   value: "quay.io/lightspeed-core/lightspeed-stack"
+  description: Container image for the Lightspeed stack

Adding these fields is low-effort and boosts template usability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 902b88e and 84f6233.

📒 Files selected for processing (1)
  • template.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
template.yaml

[error] 83-83: trailing spaces

(trailing-spaces)

@zszabo-rh zszabo-rh force-pushed the openshift_template branch from 84f6233 to 4f99995 Compare July 4, 2025 13:21
@eranco74
Copy link
Collaborator

eranco74 commented Jul 6, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jul 6, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the template.yaml file to review its contents
cat template.yaml

Length of output: 8938


@eranco74, I've reviewed the OpenShift template for the assisted-chat service. Here's my comprehensive analysis:

Strengths

  1. Security: Proper handling of sensitive data using Kubernetes Secrets for the GEMINI_API_KEY
  2. Configurability: Extensive parameterization (25+ parameters) for flexible deployments
  3. Health Checks: Both liveness and readiness probes are properly configured
  4. TLS: Route includes TLS termination with edge termination policy
  5. Resource Management: CPU/memory limits and requests are parameterized
  6. Volume Management: Proper use of ConfigMaps for configuration files and PVC for persistent data

⚠️ Areas for Improvement

1. Security Enhancements

# Add security context to the deployment
securityContext:
  runAsNonRoot: true
  runAsUser: 1001
  fsGroup: 1001
  seccompProfile:
    type: RuntimeDefault

2. Image Pull Policy

# Consider changing from "Always" to "IfNotPresent" for production
imagePullPolicy: IfNotPresent  # Instead of Always

3. PVC Access Mode

# ReadWriteMany may not be supported by all storage classes
accessModes:
- ReadWriteOnce  # More widely supported than ReadWriteMany

4. Parameter Validation

Consider adding parameter validation:

parameters:
- name: ROUTE_HOST
  value: "assisted-chat.example.com"
  required: true
  description: "External hostname for the route"

5. Missing Required Resources

The template references but doesn't create the Secret. Consider adding:

# Add conditional Secret creation
- apiVersion: v1
  kind: Secret
  metadata:
    name: ${GEMINI_API_SECRET_NAME}
  type: Opaque
  stringData:
    api-key: "REPLACE_WITH_ACTUAL_KEY"

6. Resource Quotas

Consider adding namespace-level resource quotas for better resource management.

7. Labels and Annotations

Add more comprehensive labels:

labels:
  app: assisted-chat
  component: lightspeed-stack
  version: ${IMAGE_TAG}
  app.kubernetes.io/name: assisted-chat
  app.kubernetes.io/component: lightspeed-stack
  app.kubernetes.io/version: ${IMAGE_TAG}

🔧 Production Readiness Suggestions

  1. Storage Class: Consider adding a storageClassName parameter
  2. Probes: Add startup probes for better container lifecycle management
  3. Resource Quotas: Add namespace-level resource management
  4. Monitoring: Consider adding ServiceMonitor for Prometheus integration
  5. Network Policies: Add network segmentation for enhanced security

📋 Minor Issues

  1. Default Route Host: Change from example.com to a more descriptive placeholder
  2. Probe Timing: Consider adjusting initialDelaySeconds based on actual startup time
  3. Environment Variables: Some environment variables could be moved to ConfigMap

The template is well-designed and follows OpenShift best practices. The main recommendations focus on security hardening and production readiness. Great work on parameterizing the configuration and properly handling secrets!

@zszabo-rh zszabo-rh force-pushed the openshift_template branch 2 times, most recently from 86816bc to d1fa864 Compare July 7, 2025 07:35
template.yaml Outdated
description: "Size of the persistent volume for storing feedback, transcripts, and SQLite databases"
- name: STORAGE_MOUNT_PATH
value: "/tmp/data"
description: "Container path where the persistent volume will be mounted"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this temporary or does it really need to be persisted between restarts of the pods? If it is temporary, can we use an emptyDir instead of a PVC?

If we really need to use a PVC, then the access mode of the PVC below would need to be ReadWriteMany, and we will need to ensure that multiple pods know how to coordinate access to that storage.

I'd very much prefer if we use an emptyDir, as then these concerns go away and the deployment is simpler.

template.yaml Outdated
insecureEdgeTerminationPolicy: Redirect

- apiVersion: v1
kind: PersistentVolumeClaim
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I commented above I think it is better if we use an emptyDir, if possible, at least initially.

@zszabo-rh zszabo-rh force-pushed the openshift_template branch from d1fa864 to 6fd2459 Compare July 7, 2025 08:18
@zszabo-rh zszabo-rh marked this pull request as ready for review July 7, 2025 08:34
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 84f6233 and 6fd2459.

📒 Files selected for processing (1)
  • template.yaml (1 hunks)
🔇 Additional comments (1)
template.yaml (1)

272-294: Good move: swapped PVC for emptyDir

Switching to emptyDir eliminates multi-writer storage complexity and matches the feedback from previous reviews.

Comment on lines +15 to +18
- name: REPLICAS_COUNT
value: "1"
description: "Number of pod replicas to deploy for high availability"
- name: SERVICE_PORT
value: "8090"
description: "Port number on which the lightspeed-stack service listens"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Unquoted numeric parameters break Kubernetes type-validation

Values for REPLICAS_COUNT, SERVICE_PORT, and LIGHTSPEED_SERVICE_WORKERS are wrapped in quotes, so after substitution fields like spec.replicas, containerPort, and port end up as strings ("1", "8090" …). Kubernetes expects integers and will reject the Deployment/Service.

-  value: "1"            # REPLICAS_COUNT
+  value: 1

-  value: "8090"         # SERVICE_PORT
+  value: 8090

-  value: "1"            # LIGHTSPEED_SERVICE_WORKERS
+  value: 1

Apply the same pattern to any other purely-numeric parameters.

Also applies to: 43-45

🤖 Prompt for AI Agents
In template.yaml lines 15 to 20, the numeric values for REPLICAS_COUNT and
SERVICE_PORT are quoted strings, which causes Kubernetes to reject them due to
type mismatch. Remove the quotes around these numeric values to ensure they are
treated as integers. Also, apply this fix to any other numeric parameters in the
file, including lines 43 to 45, to maintain consistent type validation.

Comment on lines +236 to +283
spec:
containers:
- name: lightspeed-stack
image: ${IMAGE}:${IMAGE_TAG}
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: ${SERVICE_PORT}
protocol: TCP
env:
- name: GEMINI_API_KEY
valueFrom:
secretKeyRef:
name: ${GEMINI_API_SECRET_NAME}
key: api-key
- name: LLAMA_STACK_SQLITE_STORE_DIR
value: ${STORAGE_MOUNT_PATH}/sqlite
- name: LLAMA_STACK_OTEL_SERVICE_NAME
value: ${LLAMA_STACK_OTEL_SERVICE_NAME}
- name: LLAMA_STACK_TELEMETRY_SINKS
value: ${LLAMA_STACK_TELEMETRY_SINKS}
resources:
limits:
memory: ${MEMORY_LIMIT}
cpu: ${CPU_LIMIT}
requests:
memory: ${MEMORY_REQUEST}
cpu: ${CPU_REQUEST}
volumeMounts:
- name: lightspeed-config
mountPath: /app-root/lightspeed-stack.yaml
subPath: lightspeed-stack.yaml
- name: llama-stack-config
mountPath: /app-root/llama_stack_client_config.yaml
subPath: llama_stack_client_config.yaml
- name: data-storage
mountPath: ${STORAGE_MOUNT_PATH}
livenessProbe:
httpGet:
path: /v1/liveness
port: ${SERVICE_PORT}
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /v1/readiness
port: ${SERVICE_PORT}
initialDelaySeconds: 5
periodSeconds: 5
volumes:
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Harden the pod with a securityContext

The container currently runs without any explicit restrictions. Add a pod-level security context to enforce non-root execution and a default seccomp profile.

       spec:
+        securityContext:
+          runAsUser: 10001
+          runAsGroup: 10001
+          runAsNonRoot: true
+          seccompProfile:
+            type: RuntimeDefault
         containers:
         - name: lightspeed-stack

This is a low-effort win for compliance and cluster policy alignment.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
spec:
containers:
- name: lightspeed-stack
image: ${IMAGE}:${IMAGE_TAG}
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: ${SERVICE_PORT}
protocol: TCP
env:
- name: GEMINI_API_KEY
valueFrom:
secretKeyRef:
name: ${GEMINI_API_SECRET_NAME}
key: api-key
- name: LLAMA_STACK_SQLITE_STORE_DIR
value: ${STORAGE_MOUNT_PATH}/sqlite
- name: LLAMA_STACK_OTEL_SERVICE_NAME
value: ${LLAMA_STACK_OTEL_SERVICE_NAME}
- name: LLAMA_STACK_TELEMETRY_SINKS
value: ${LLAMA_STACK_TELEMETRY_SINKS}
resources:
limits:
memory: ${MEMORY_LIMIT}
cpu: ${CPU_LIMIT}
requests:
memory: ${MEMORY_REQUEST}
cpu: ${CPU_REQUEST}
volumeMounts:
- name: lightspeed-config
mountPath: /app-root/lightspeed-stack.yaml
subPath: lightspeed-stack.yaml
- name: llama-stack-config
mountPath: /app-root/llama_stack_client_config.yaml
subPath: llama_stack_client_config.yaml
- name: data-storage
mountPath: ${STORAGE_MOUNT_PATH}
livenessProbe:
httpGet:
path: /v1/liveness
port: ${SERVICE_PORT}
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /v1/readiness
port: ${SERVICE_PORT}
initialDelaySeconds: 5
periodSeconds: 5
volumes:
spec:
securityContext:
runAsUser: 10001
runAsGroup: 10001
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
containers:
- name: lightspeed-stack
image: ${IMAGE}:${IMAGE_TAG}
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: ${SERVICE_PORT}
protocol: TCP
env:
- name: GEMINI_API_KEY
valueFrom:
secretKeyRef:
name: ${GEMINI_API_SECRET_NAME}
key: api-key
- name: LLAMA_STACK_SQLITE_STORE_DIR
value: ${STORAGE_MOUNT_PATH}/sqlite
- name: LLAMA_STACK_OTEL_SERVICE_NAME
value: ${LLAMA_STACK_OTEL_SERVICE_NAME}
- name: LLAMA_STACK_TELEMETRY_SINKS
value: ${LLAMA_STACK_TELEMETRY_SINKS}
resources:
limits:
memory: ${MEMORY_LIMIT}
cpu: ${CPU_LIMIT}
requests:
memory: ${MEMORY_REQUEST}
cpu: ${CPU_REQUEST}
volumeMounts:
- name: lightspeed-config
mountPath: /app-root/lightspeed-stack.yaml
subPath: lightspeed-stack.yaml
- name: llama-stack-config
mountPath: /app-root/llama_stack_client_config.yaml
subPath: llama_stack_client_config.yaml
- name: data-storage
mountPath: ${STORAGE_MOUNT_PATH}
livenessProbe:
httpGet:
path: /v1/liveness
port: ${SERVICE_PORT}
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /v1/readiness
port: ${SERVICE_PORT}
initialDelaySeconds: 5
periodSeconds: 5
volumes:
🤖 Prompt for AI Agents
In template.yaml around lines 236 to 285, the container spec lacks a pod-level
securityContext to enforce security best practices. Add a securityContext at the
pod level that sets runAsNonRoot to true and specifies a default seccompProfile
(e.g., type: RuntimeDefault) to ensure the container does not run as root and
uses a secure syscall filter. This will harden the pod with minimal changes and
improve compliance.

@zszabo-rh zszabo-rh force-pushed the openshift_template branch 2 times, most recently from 37fc7e0 to 1c63b50 Compare July 8, 2025 07:52
@zszabo-rh zszabo-rh force-pushed the openshift_template branch from 1c63b50 to 84aad60 Compare July 8, 2025 08:12
@omertuc omertuc merged commit e3652b9 into rh-ecosystem-edge:main Jul 8, 2025
1 check passed
This was referenced Jul 9, 2025
This was referenced Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants