|
| 1 | +# Regenerating Charts and Bundle Manifests |
| 2 | + |
| 3 | +Several files in this repository are **generated** and must never be hand-edited. This guide documents how to regenerate Helm charts and OLM bundle manifests from their sources of truth. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +| Generated artifact | Source of truth | Command | |
| 8 | +|---|---|---| |
| 9 | +| Helm chart templates (`charts/stellar-operator/templates/`) | `src/` Rust types + `config/` manifests | `helm template` or `make crd-gen` | |
| 10 | +| CRD YAML (`config/crd/*.yaml`) | `src/crd/` Rust structs | `make crd-gen` | |
| 11 | +| OLM bundle (`bundle/manifests/`, `bundle/metadata/`) | `config/manifests/bases/` | `make bundle` | |
| 12 | +| API reference docs (`docs/api-reference.md`) | `src/crd/` + `scripts/generate-api-docs.py` | `make generate-api-docs` | |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +| Tool | Version | Required for | |
| 17 | +|---|---|---| |
| 18 | +| [operator-sdk](https://sdk.operatorframework.io/docs/installation/) | >= 1.42.0 | Bundle generation | |
| 19 | +| [kustomize](https://kustomize.io/) | >= 5.x | Bundle generation | |
| 20 | +| [helm](https://helm.sh/) | >= 3.x | Chart rendering | |
| 21 | +| Python 3 | >= 3.12 | API docs generation | |
| 22 | + |
| 23 | +```bash |
| 24 | +# Verify installed tools |
| 25 | +operator-sdk version |
| 26 | +kustomize version |
| 27 | +helm version |
| 28 | +python3 --version |
| 29 | +``` |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Regenerating CRD Manifests |
| 34 | + |
| 35 | +The StellarNode CRD and all other CRDs are generated from Rust types in `src/crd/`. |
| 36 | + |
| 37 | +```bash |
| 38 | +make crd-gen |
| 39 | +``` |
| 40 | + |
| 41 | +This runs the `crdgen` binary which reads the `#[derive(JsonSchema)]` annotated structs and outputs updated CRD YAML files to `config/crd/`. |
| 42 | + |
| 43 | +> **Note:** After modifying any `src/crd/*.rs` file, always run `make crd-gen` and commit the updated CRD alongside your Rust changes. The CI pipeline will fail if CRDs are stale. |
| 44 | +
|
| 45 | +--- |
| 46 | + |
| 47 | +## Regenerating the OLM Bundle |
| 48 | + |
| 49 | +The Operator Lifecycle Manager (OLM) bundle is generated from the Kustomize bases in `config/manifests/`. |
| 50 | + |
| 51 | +### Step-by-step |
| 52 | + |
| 53 | +```bash |
| 54 | +# 1. Generate OLM manifests from Helm chart + bases |
| 55 | +make bundle |
| 56 | + |
| 57 | +# 2. Validate the generated bundle |
| 58 | +operator-sdk bundle validate ./bundle |
| 59 | + |
| 60 | +# 3. (Optional) Build the bundle container image |
| 61 | +make bundle-build |
| 62 | +``` |
| 63 | + |
| 64 | +The `make bundle` target performs these steps internally: |
| 65 | + |
| 66 | +1. Renders the Helm chart to raw manifests: `helm template stellar-operator charts/stellar-operator` |
| 67 | +2. Generates Kustomize manifests: `operator-sdk generate kustomize manifests -q` |
| 68 | +3. Produces the OLM bundle: `kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION)` |
| 69 | +4. Validates the bundle structure with `operator-sdk bundle validate` |
| 70 | + |
| 71 | +### Bundle structure |
| 72 | + |
| 73 | +``` |
| 74 | +bundle/ |
| 75 | +├── manifests/ |
| 76 | +│ └── stellar-operator.clusterserviceversion.yaml # ClusterServiceVersion |
| 77 | +└── metadata/ |
| 78 | + └── annotations.yaml # Bundle annotations |
| 79 | +``` |
| 80 | + |
| 81 | +### Customizing bundle metadata |
| 82 | + |
| 83 | +Edit these files directly (they are **not** auto-generated): |
| 84 | + |
| 85 | +| File | Purpose | |
| 86 | +|---|---| |
| 87 | +| `bundle/metadata/annotations.yaml` | Channel, package name, mediatype | |
| 88 | +| `config/manifests/bases/stellar-operator.clusterserviceversion.yaml` | CSV base (descriptor, icon, maintainer) | |
| 89 | + |
| 90 | +After editing, run `make bundle` to regenerate the full CSV. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## Regenerating the Helm Chart |
| 95 | + |
| 96 | +The Helm chart in `charts/stellar-operator/` is **hand-written** for the most part, but some components are derived from code: |
| 97 | + |
| 98 | +### Chart templates that are hand-written |
| 99 | + |
| 100 | +| Template | Description | |
| 101 | +|---|---| |
| 102 | +| `deployment.yaml` | Operator Deployment spec | |
| 103 | +| `rbac.yaml` | ClusterRole, ClusterRoleBinding, Role, RoleBinding | |
| 104 | +| `service.yaml` | Service definition | |
| 105 | +| `serviceaccount.yaml` | ServiceAccount | |
| 106 | +| `secret.yaml` | Kubernetes Secret | |
| 107 | +| `externalsecret.yaml` | External Secrets Operator integration | |
| 108 | +| `configmap.yaml` | Operator ConfigMap | |
| 109 | +| `webhook.yaml` | Admission webhook configuration | |
| 110 | +| `pdb.yaml` | PodDisruptionBudget | |
| 111 | +| `hpa-*.yaml` | Horizontal Pod Autoscalers | |
| 112 | +| `otel-collector.yaml` | OpenTelemetry sidecar | |
| 113 | +| `scp-kafka-sidecar.yaml` | SCP Kafka sidecar | |
| 114 | +| `byzantine-watcher.yaml` | Byzantine monitoring | |
| 115 | +| `fork-detector.yaml` | Fork detection | |
| 116 | +| `network-isolation.yaml` | Network policies | |
| 117 | + |
| 118 | +### Testing chart changes |
| 119 | + |
| 120 | +After modifying any template or `values.yaml`: |
| 121 | + |
| 122 | +```bash |
| 123 | +# Lint the chart |
| 124 | +make helm-lint |
| 125 | + |
| 126 | +# Validate against JSON schema |
| 127 | +helm lint charts/stellar-operator --strict |
| 128 | + |
| 129 | +# Render and inspect output |
| 130 | +helm template stellar-operator charts/stellar-operator > /tmp/rendered.yaml |
| 131 | + |
| 132 | +# Run Helm unit tests |
| 133 | +helm unittest charts/stellar-operator --strict --color |
| 134 | +``` |
| 135 | + |
| 136 | +### Updating Chart.yaml |
| 137 | + |
| 138 | +| Field | Source | When to update | |
| 139 | +|---|---|---| |
| 140 | +| `version` | Manual | On each release / breaking chart change | |
| 141 | +| `appVersion` | Manual | When the operator image version changes | |
| 142 | +| `dependencies` | Manual | When adding new chart dependencies | |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## Regenerating API Reference Docs |
| 147 | + |
| 148 | +```bash |
| 149 | +make generate-api-docs |
| 150 | +``` |
| 151 | + |
| 152 | +This regenerates `docs/api-reference.md` from the CRD schema. The CI job `api-docs` in `.github/workflows/ci.yml` will fail if this file is stale. |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## Testing Generated Assets in CI |
| 157 | + |
| 158 | +The CI pipeline automatically validates generated files: |
| 159 | + |
| 160 | +1. **CRD freshness** — the `api-docs` job regenerates `docs/api-reference.md` and fails if `git diff` shows changes |
| 161 | +2. **Helm chart correctness** — `helm-lint` and `helm-test` jobs validate chart syntax and run unit tests |
| 162 | +3. **Bundle validity** — `make bundle` validates with `operator-sdk bundle validate` |
| 163 | + |
| 164 | +When making PR changes, always run: |
| 165 | + |
| 166 | +```bash |
| 167 | +make crd-gen # Regenerate CRDs if Rust types changed |
| 168 | +make bundle # Regenerate OLM bundle if bases changed |
| 169 | +make generate-api-docs # Regenerate API docs if CRD schema changed |
| 170 | +make helm-lint # Validate Helm chart |
| 171 | +``` |
| 172 | + |
| 173 | +Commit all regenerated files in the same PR as the source change. |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +## Troubleshooting |
| 178 | + |
| 179 | +### `operator-sdk` not found |
| 180 | + |
| 181 | +```bash |
| 182 | +# Install operator-sdk (Linux / macOS / WSL2) |
| 183 | +export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; esac) |
| 184 | +export OS=$(uname | awk '{print tolower($0)}') |
| 185 | +export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.42.0 |
| 186 | +curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH} |
| 187 | +chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk |
| 188 | +``` |
| 189 | + |
| 190 | +### `kustomize` not found |
| 191 | + |
| 192 | +```bash |
| 193 | +# Install kustomize |
| 194 | +curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash |
| 195 | +sudo mv kustomize /usr/local/bin/ |
| 196 | +``` |
| 197 | + |
| 198 | +### Bundle validation fails |
| 199 | + |
| 200 | +```bash |
| 201 | +# Check the specific validation errors |
| 202 | +operator-sdk bundle validate ./bundle --verbose |
| 203 | + |
| 204 | +# Common fixes: |
| 205 | +# - Ensure CRD YAML files exist in bundle/manifests/ |
| 206 | +# - Verify CSV metadata (displayName, description, installModes) |
| 207 | +# - Check that all referenced images are valid |
| 208 | +``` |
| 209 | + |
| 210 | +### Helm unit tests fail |
| 211 | + |
| 212 | +```bash |
| 213 | +# Install helm-unittest plugin |
| 214 | +helm plugin install https://github.com/helm-unittest/helm-unittest.git |
| 215 | + |
| 216 | +# Run with verbose output |
| 217 | +helm unittest charts/stellar-operator --strict --color -v |
| 218 | +``` |
0 commit comments