Skip to content

Included helm chart tests & values specific to cluster type#6

Open
chandrams wants to merge 11 commits intokruize:mvp_demofrom
chandrams:helm_charts_tests
Open

Included helm chart tests & values specific to cluster type#6
chandrams wants to merge 11 commits intokruize:mvp_demofrom
chandrams:helm_charts_tests

Conversation

@chandrams
Copy link
Copy Markdown
Contributor

@chandrams chandrams commented Mar 11, 2026

Changes in this PR

  • Included helm chart unit tests
  • Separated out values specific to cluster type
  • Include values schema json

This is on top of #4

Summary by Sourcery

Add a fully featured Kruize Helm chart with environment-specific configuration and introduce comprehensive unit tests for chart resources across Kubernetes, OpenShift, and Minikube.

New Features:

  • Introduce a production-ready Kruize Helm chart with templates for core services, database, UI, storage, RBAC, network policies, cron jobs, and monitoring integration.
  • Provide separate values files and configuration for OpenShift and Minikube clusters alongside the default Kubernetes configuration.
  • Define a JSON values schema for the Kruize chart to validate configuration values.

Enhancements:

  • Refine chart helper templates for consistent naming, labeling, and service account handling across all resources.

Documentation:

  • Document Helm chart installation, configuration options, and environment-specific usage for Kruize, including example custom values and testing instructions.

Tests:

  • Add extensive helm-unittest-based test suites for common, OpenShift-specific, and Minikube-specific chart templates, covering services, deployments, RBAC, storage, cron jobs, monitoring, and network policies.

@chandrams chandrams self-assigned this Mar 11, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 11, 2026

Reviewer's Guide

Adds a fully structured Kruize Helm chart with platform-specific values for OpenShift and Minikube, introduces templated manifests (deployments, services, configmaps, storage, RBAC, cronjobs, monitoring, UI proxy), and backs them with an extensive helm-unittest test suite and JSON schema/README documentation.

Flow diagram for Helm values and platform-specific configuration

graph LR
  User[User] -->|chooses_cluster_type| ClusterType

  ClusterType -->|OpenShift| ValuesOpenshift[values_openshift_yaml]
  ClusterType -->|Minikube| ValuesMinikube[values_minikube_yaml]
  ClusterType -->|Generic_Kubernetes| ValuesDefault[values_yaml]

  ValuesDefault --> HelmEngine[Helm_template_engine]
  ValuesOpenshift --> HelmEngine
  ValuesMinikube --> HelmEngine

  HelmEngine -->|renders| Templates[Helm_templates]
  Templates -->|produces| K8sManifests[Kubernetes_manifests]
  K8sManifests -->|applied_to| Cluster[Kubernetes_cluster]

  subgraph Examples_of_overrides
    ValuesDefault --> DefaultDatasource[datasource_empty]
    ValuesOpenshift --> OSMetricSources[prometheus_and_thanos_in_openshift_monitoring]
    ValuesMinikube --> MiniMetricSource[prometheus_in_monitoring_namespace]

    ValuesDefault --> DefaultRBAC[rbac_create_true]
    ValuesMinikube --> MiniRBAC[rbac_create_false]
  end

  OSMetricSources --> KruizeConfig[ConfigMap_kruize_config]
  MiniMetricSource --> KruizeConfig
  DefaultDatasource --> KruizeConfig

  KruizeConfig --> KruizePod[Running_kruize_pod]
Loading

File-Level Changes

Change Details Files
Introduce a full Helm chart definition and default configuration for Kruize, including common values and schema.
  • Create Chart.yaml with metadata, app version, and maintainers
  • Define default values.yaml for Kruize core, DB, UI, cron jobs, monitoring, RBAC, and network policies
  • Add values-openshift.yaml and values-minikube.yaml to override defaults for cluster-specific behavior (RBAC, resources, datasources, storage, networkPolicy, monitoring)
  • Add values.schema.json placeholder for values validation
charts/kruize/Chart.yaml
charts/kruize/values.yaml
charts/kruize/values-openshift.yaml
charts/kruize/values-minikube.yaml
charts/kruize/values.schema.json
Implement Helm templates for Kruize application, database, UI, storage resources, RBAC, cron jobs, monitoring, and helpers.
  • Add helper template functions for naming, labels, selector labels, and service account resolution
  • Template Kruize deployment, service, DB deployment/service, UI nginx pod/service, configmaps, storage PV/PVC and manual StorageClass
  • Implement RBAC ClusterRoles/ClusterRoleBindings and optional ServiceAccount wired via values
  • Add CronJob templates for DB partition management that derive image/env from values and configmap
  • Add optional ServiceMonitor and NetworkPolicy templates controlled by values
charts/kruize/templates/_helpers.tpl
charts/kruize/templates/kruize_deployment.yaml
charts/kruize/templates/kruize_service.yaml
charts/kruize/templates/kruize_db_deployment.yaml
charts/kruize/templates/kruize_db_service.yaml
charts/kruize/templates/kruize_ui_nginx_pod.yaml
charts/kruize/templates/kruize_ui_nginx_service.yaml
charts/kruize/templates/configmap_kruize.yaml
charts/kruize/templates/configmap_nginx.yaml
charts/kruize/templates/storage_pv.yaml
charts/kruize/templates/storage_pvc.yaml
charts/kruize/templates/storage_manual.yaml
charts/kruize/templates/role.yaml
charts/kruize/templates/rolebinding.yaml
charts/kruize/templates/cronjobs.yaml
charts/kruize/templates/service_account.yaml
charts/kruize/templates/service_monitor.yaml
charts/kruize/templates/network_policy.yaml
Add a comprehensive helm-unittest test suite covering common, OpenShift, and Minikube behaviors for the chart.
  • Document helm-unittest usage, directory structure, and patterns in tests/README.md
  • Add common tests for configmaps, services, DB deployment/service, cronjobs, storage, network policy, ServiceMonitor, and UI nginx resources
  • Add OpenShift-specific tests for Kruize deployment and RBAC behavior using values-openshift.yaml
  • Add Minikube-specific tests for deployment, DB deployment, RBAC, storage, network policy, and ServiceMonitor using values-minikube.yaml
charts/kruize/tests/README.md
charts/kruize/tests/common-tests/configmap_test.yaml
charts/kruize/tests/common-tests/cronjobs_test.yaml
charts/kruize/tests/common-tests/kruize_service_test.yaml
charts/kruize/tests/common-tests/kruize_db_deployment_test.yaml
charts/kruize/tests/common-tests/kruize_db_service_test.yaml
charts/kruize/tests/common-tests/kruize_ui_test.yaml
charts/kruize/tests/common-tests/network_policy_test.yaml
charts/kruize/tests/common-tests/service_monitor_test.yaml
charts/kruize/tests/common-tests/storage_test.yaml
charts/kruize/tests/openshift/kruize_deployment_test.yaml
charts/kruize/tests/openshift/rbac_test.yaml
charts/kruize/tests/minikube/kruize_deployment_minikube_test.yaml
charts/kruize/tests/minikube/kruize_db_deployment_minikube_test.yaml
charts/kruize/tests/minikube/network_policy_minikube_test.yaml
charts/kruize/tests/minikube/rbac_minikube_test.yaml
charts/kruize/tests/minikube/service_monitor_minikube_test.yaml
charts/kruize/tests/minikube/storage_minikube_test.yaml
Provide user-facing documentation and repo-level glue for the chart.
  • Add a detailed chart README describing installation modes, configuration options, and examples
  • Add tests README under charts/kruize explaining how to run and structure unit tests
  • Wire repo root README.md to the chart README and include LICENSE files and .helmignore
charts/kruize/README.md
charts/kruize/tests/README.md
charts/kruize/.helmignore
charts/kruize/LICENSE
LICENSE
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chandrams chandrams changed the title Included helm chart tests & separated out values specific to cluster type Included helm chart tests & values specific to cluster type Mar 11, 2026
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • In kruize_db_deployment.yaml the labels block under the pod template has a mis‑indented include "kruize.selectorLabels" line (it’s indented with a tab and doesn’t line up under labels:), which will produce invalid YAML at render time; align it with spaces like in the other templates.
  • In cronjobs.yaml both the create‑partition and delete‑partition CronJobs use the same cronJob.createSchedule value; if you expect these to run on different cadences it would be clearer to introduce a separate cronJob.deleteSchedule (or similar) value and wire that into the delete CronJob.
  • The NetworkPolicy in network_policy.yaml hardcodes app.kubernetes.io/name: prometheus and port 9090, while the monitoring configuration is otherwise driven by kruize.config.datasource/monitoring values; consider wiring the selector/port to values (or documenting the assumption) so the chart can better support non‑Prometheus or differently labeled monitoring stacks.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `kruize_db_deployment.yaml` the `labels` block under the pod template has a mis‑indented `include "kruize.selectorLabels"` line (it’s indented with a tab and doesn’t line up under `labels:`), which will produce invalid YAML at render time; align it with spaces like in the other templates.
- In `cronjobs.yaml` both the create‑partition and delete‑partition CronJobs use the same `cronJob.createSchedule` value; if you expect these to run on different cadences it would be clearer to introduce a separate `cronJob.deleteSchedule` (or similar) value and wire that into the delete CronJob.
- The NetworkPolicy in `network_policy.yaml` hardcodes `app.kubernetes.io/name: prometheus` and port `9090`, while the monitoring configuration is otherwise driven by `kruize.config.datasource`/`monitoring` values; consider wiring the selector/port to values (or documenting the assumption) so the chart can better support non‑Prometheus or differently labeled monitoring stacks.

## Individual Comments

### Comment 1
<location path="charts/kruize/templates/kruize_db_deployment.yaml" line_range="5-14" />
<code_context>
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ $fullName }}-config
+  namespace: {{ .Release.Namespace }}
</code_context>
<issue_to_address>
**issue (bug_risk):** Mixed tab/space indentation under `metadata.labels` will likely break YAML parsing.

The line with `{{- include "kruize.selectorLabels" . | nindent 8 }}` appears to use a tab instead of spaces. Mixed indentation can cause Kubernetes to reject the manifest. Please replace the tab with 8 spaces (and any other tabs in this block) so it correctly aligns under `labels:`.
</issue_to_address>

### Comment 2
<location path="charts/kruize/templates/network_policy.yaml" line_range="12-14" />
<code_context>
+  labels:
+    {{- include "kruize.labels" . | nindent 4 }}
+spec:
+  podSelector:
+    matchLabels:
+      app.kubernetes.io/name: prometheus
+  policyTypes:
+    - Ingress
</code_context>
<issue_to_address>
**suggestion (bug_risk):** NetworkPolicy selects Prometheus pods by a hard-coded label that may not match common deployments.

The `podSelector` only matches pods labeled `app.kubernetes.io/name: prometheus`, but many deployments (kube-prometheus-stack, OpenShift, etc.) use different labels (e.g., `prometheus-k8s`). If the labels don’t match, this policy won’t apply to any Prometheus pods. Consider making the selector configurable via values or aligning it with the labels used by your Prometheus datasources.

Suggested implementation:

```
spec:
  podSelector:
    matchLabels:
{{- if .Values.prometheus.podSelector.matchLabels }}
{{ toYaml .Values.prometheus.podSelector.matchLabels | nindent 6 }}
{{- else }}
      app.kubernetes.io/name: prometheus
{{- end }}
  policyTypes:
    - Ingress

```

1. In `charts/kruize/values.yaml`, add a configurable section, for example:
   ```yaml
   prometheus:
     podSelector:
       # matchLabels to select Prometheus pods for the NetworkPolicy.
       # Example for kube-prometheus-stack:
       # matchLabels:
       #   app.kubernetes.io/name: kube-prometheus-stack-prometheus
       matchLabels: {}
   ```
2. Update the chart README / values documentation to explain how to set `prometheus.podSelector.matchLabels` to match the labels used by the target Prometheus deployment (e.g., kube-prometheus-stack, OpenShift `prometheus-k8s`, etc.).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +12 to +14
podSelector:
matchLabels:
app.kubernetes.io/name: prometheus
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): NetworkPolicy selects Prometheus pods by a hard-coded label that may not match common deployments.

The podSelector only matches pods labeled app.kubernetes.io/name: prometheus, but many deployments (kube-prometheus-stack, OpenShift, etc.) use different labels (e.g., prometheus-k8s). If the labels don’t match, this policy won’t apply to any Prometheus pods. Consider making the selector configurable via values or aligning it with the labels used by your Prometheus datasources.

Suggested implementation:

spec:
  podSelector:
    matchLabels:
{{- if .Values.prometheus.podSelector.matchLabels }}
{{ toYaml .Values.prometheus.podSelector.matchLabels | nindent 6 }}
{{- else }}
      app.kubernetes.io/name: prometheus
{{- end }}
  policyTypes:
    - Ingress

  1. In charts/kruize/values.yaml, add a configurable section, for example:
    prometheus:
      podSelector:
        # matchLabels to select Prometheus pods for the NetworkPolicy.
        # Example for kube-prometheus-stack:
        # matchLabels:
        #   app.kubernetes.io/name: kube-prometheus-stack-prometheus
        matchLabels: {}
  2. Update the chart README / values documentation to explain how to set prometheus.podSelector.matchLabels to match the labels used by the target Prometheus deployment (e.g., kube-prometheus-stack, OpenShift prometheus-k8s, etc.).

chandrams and others added 11 commits March 30, 2026 14:43
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@ibm.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@ibm.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
@chandrams chandrams force-pushed the helm_charts_tests branch from aa1f3c5 to e43e9ff Compare April 2, 2026 10:52
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.

1 participant