Generic Helm Chart
A generic, reusable Helm chart for deploying Java operators built with JOSDK is available at
helm/generic-helm-chart.
It is intended as a template for operator developers — a starting point that covers common deployment patterns so you don’t have to write a chart from scratch. The chart is maintained on a best-effort basis. Contributions are more than welcome.
The chart is used in the
operations sample operator E2E test
to deploy the operator to a cluster via Helm.
What the Chart Provides
- Deployment with security defaults (non-root user, read-only filesystem, no privilege escalation)
- Dynamic RBAC (ClusterRole, ClusterRoleBinding, ServiceAccount) — permissions are generated automatically
from the primary and secondary resources you declare in
values.yaml - ConfigMap for operator configuration (
config.yaml) and logging (log4j2.xml), mounted at/config - Leader election support (opt-in)
- Extensibility via extra containers, init containers, volumes, and environment variables
Key Configuration
The most important values to set when adapting the chart for your operator:
image:
repository: my-operator-image # required
tag: "latest"
# Custom resources your operator reconciles
primaryResources:
- apiGroup: "sample.javaoperatorsdk"
resources:
- myresources
# Kubernetes resources your operator manages
secondaryResources:
- apiGroup: ""
resources:
- configmaps
- services
Primary resources get read/watch/patch permissions and status sub-resource access. Secondary resources get full CRUD permissions. Default verbs can be overridden per resource entry.
The ClusterRole always grants get, create and patch on events in the core API group, so
recording events works without any extra configuration. All three are needed: an event is looked up
by name before it is created, so that recording the same event again resolves to the event already
recorded, and that event is then patched to count the new occurrence rather than recorded again. See
Events for what this means if you write your own RBAC.
Operator Environment
The chart injects OPERATOR_NAMESPACE automatically. You can optionally set WATCH_NAMESPACE to
restrict the operator to a single namespace, and add arbitrary environment variables:
operator:
watchNamespace: "" # empty = all namespaces
env:
- name: MY_CUSTOM_VAR
value: "some-value"
Resource Defaults
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
See the full
values.yaml
for all available options.
Usage Example
A working example of how to use the chart can be found in the operations sample operator’s
helm-values.yaml:
image:
repository: operations-operator
pullPolicy: Never
tag: "latest"
nameOverride: "operations-operator"
resources: {}
primaryResources:
- apiGroup: "sample.javaoperatorsdk"
resources:
- metricshandlingcustomresource1s
- metricshandlingcustomresource2s
Install with:
helm install my-operator ./helm/generic-helm-chart -f my-values.yaml --namespace my-ns
Testing the Chart
The chart includes unit tests using the helm-unittest plugin. Run them with:
./helm/run-tests.sh
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.