Repository navigation
config: Add versioned operator configuration through a CRD - #203
HarshwardhanPatil07 wants to merge 14 commits into
Conversation
|
I personally prefer a new CRD over a configmap. Mostly for 2 reasons, first it is versioned, secondly eventually we could use the crd status for reporting the operator status. The second point right now isn't used so the motivation isn't that strong. I'd love also @cheesesashimi's opinion |
3f7612f to
abb529e
Compare
16f3e66 to
19361d9
Compare
|
updated PTAL |
|
We should also probably generate a cr as part of the release with some good defaults. This is at least how kubevirt is doing it |
bfbeb93 to
e2740b9
Compare
|
PTAL |
|
@HarshwardhanPatil07 it looks great many thanks for doing this. Few last comment and this requires a rebase |
e2740b9 to
7a4ebda
Compare
Parallel E2E tests create daemon pods on other managed nodes. Restrict the membership lookup to its own node so unrelated pods do not cause the exactly-one assertion to time out. Refs: bootc-dev#226 Refs: bootc-dev#203 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
7a4ebda to
898117e
Compare
|
I'm still not quite sure about the helm manifest generation, I will give it a try tomorrow. IMO, helm should install the resources in the right order. If not, we might have a bug in our charts |
662d748 to
1287839
Compare
|
PTAL @alicefr |
|
@HarshwardhanPatil07 if you don't mind, I'd like to test this with #232 . In this way, we can see if the CRDs correctly upgrade |
Give administrators a typed cluster-scoped API for controller and daemon settings without editing workloads. Keep naming flexible; startup selection enforces that only one instance is used. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Prove API-server defaulting and rejection of invalid period, type, and field values before the startup path depends on the resource. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Preserve existing CLI behavior while allowing administrators to supply defaults through the resource. Explicit false values and fractional CLI durations continue to take precedence. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Read the administrator resource before informer caches exist. Treat missing CRDs, permission failures, API errors, and multiple instances as actionable startup errors while an absent instance keeps defaults. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Exercise absent, custom-named, updated, conflicting, and missing-CRD resources through envtest so the loader behavior is covered beyond mocked HTTP responses. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Make registry policy and tag resolution configurable on controller startup without changing explicit CLI overrides. Grant its service account only the list permission needed to select the singleton. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Let each daemon load the same administrator-owned resource at startup while preserving explicit CLI overrides. Give the daemon service account the list permission needed for the read. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Bink now installs the operator through Helm. Apply the local registry configuration after the chart creates the CRD, then restart the controller so it reads the settings and refreshes the development image. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
The release upgrade test temporarily removes current CRDs, which also deletes configuration. Snapshot and restore the optional resource during cleanup and restart workloads so later tests observe the original settings. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Give administrators a concrete example and document the single-instance rule, CLI precedence, manual restarts, and upgrade-safe ownership before they adopt the new API. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Connect Helm installation to optional administrator configuration and clarify its deletion during default uninstall. Follow the CRD subchart lifecycle introduced by bootc-dev#234, removing the obsolete generated CRD directory so existing checkouts do not package duplicate definitions. Refs: bootc-dev#92 Refs: bootc-dev#234 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Provide an editable example without putting an administrator-owned instance into install.yaml, so routine installs and upgrades cannot overwrite configuration. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Keep the downloadable example aligned with API defaults and ensure install.yaml ships the CRD without creating a configuration instance. Run the checks on every PR. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Make the versioned API discoverable alongside each release. Validate both assets before publishing and direct administrators to check for an existing instance before applying the example. Refs: bootc-dev#92 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
1287839 to
173c221
Compare
|
rebase |
|
@alicefr we have added the upgrade test here let's see if ci is happy here |
| if c := cfg.Spec.Controller; c != nil { | ||
| if c.AllowInsecureRegistry != nil { | ||
| if err := set( | ||
| "allow-insecure-registry", |
There was a problem hiding this comment.
can we define some constant for the flag name and reuse it here and in the main.go. Same for the other flags
| c, err := client.New(bootstrap, client.Options{Scheme: scheme, Mapper: mapper}) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("create client for BootcOperatorConfig: %w", err) | ||
| } |
There was a problem hiding this comment.
| } | |
| defer httpClient.CloseIdleConnections() |
To avoid leaking the connection
| #!/usr/bin/env bash | ||
| # Configure the operator after make deploy-bink installs its Helm chart. | ||
| set -euo pipefail | ||
|
|
||
| : "${KUBECONFIG:?must be set}" "${YQ:?must be set}" | ||
| : "${KUBECTL:=kubectl}" | ||
| cd "$(dirname "${BASH_SOURCE[0]}")/.." | ||
|
|
||
| "$KUBECTL" --kubeconfig "$KUBECONFIG" wait --for=condition=Established \ | ||
| crd/bootcoperatorconfigs.node.bootc.dev --timeout=1m | ||
| if ! configs_json=$("$KUBECTL" --kubeconfig "$KUBECONFIG" get bootcoperatorconfigs -o json); then | ||
| printf 'Cannot list BootcOperatorConfig resources in the bink cluster.\n' >&2 | ||
| exit 1 | ||
| fi | ||
| if ! config_count=$(jq -r '.items | length' <<< "$configs_json") || \ | ||
| ! configs=$(jq -r '[.items[].metadata.name] | join(", ")' <<< "$configs_json"); then | ||
| printf 'Cannot read BootcOperatorConfig names from the bink cluster response.\n' >&2 | ||
| exit 1 | ||
| fi | ||
| if (( config_count > 1 )); then | ||
| printf 'Bink requires at most one BootcOperatorConfig; found: %s\n' "$configs" >&2 | ||
| exit 1 | ||
| fi | ||
| if (( config_count == 0 )); then | ||
| "$KUBECTL" --kubeconfig "$KUBECONFIG" create -f config/bink/operator-config.yaml | ||
| else | ||
| patch=$("$YQ" -o=json '{"spec": .spec}' config/bink/operator-config.yaml) | ||
| "$KUBECTL" --kubeconfig "$KUBECONFIG" patch bootcoperatorconfig "$configs" \ | ||
| --type=merge --patch "$patch" | ||
| fi |
There was a problem hiding this comment.
Is this logic really necessary? I mean the bootcconfig is defined by us and if there are more then one the operator should error out
| // The released image predates BootcOperatorConfig and needs bink's | ||
| // registry settings through its command-line flags. | ||
| releasedArgs := append([]string{ | ||
| "--allow-insecure-registry", "--tag-resolution-interval=10s", |
There was a problem hiding this comment.
can we get the default from the deployment and the daemonset definition?
|
The PR looks good but I'm a bit afraid about the helm usage. Since, we install directly the crds and the operator in one helm operator, there is no room for the cluster admin to configure the bootcconfig at installation time. They always need to restart the operator and the daemon manually which isn't that great. @cheesesashimi any thought? |
|
What we could, it is to document a 3 steps installation procedure, if the cluster admin isn't happy with the default. Like:
|
Administrators currently need to edit operator workload arguments to change settings and preserve those edits during upgrades. Add an optional, administrator-owned, cluster-scoped
BootcOperatorConfigusing the versionednode.bootc.dev/v1alpha1API. The resource may have any valid Kubernetes name, but the controller and daemon require at most one instance at startup.The API exposes controller insecure-registry policy and image-tag resolution period, plus the daemon fallback status-poll period. Kubernetes validates types and positive whole-second periods. Both processes make one bounded, uncached list request at startup: zero instances use existing defaults, one supplies settings, and multiple instances or API errors stop startup with a contextual error. Explicit CLI flags take precedence, including
falseand fractional durations. Changes require a manual restart of the affected workload. Both service accounts receive onlylistpermission for this resource.The bink workflow now installs the CRD, waits for it, creates or updates its local-registry configuration, and only then deploys workloads. Install and Helm manifests include the CRD and permissions without creating or overwriting administrator configuration. Releases publish an optional, editable
operator-config.yamlseparately frominstall.yaml. Documentation covers precedence, restarts, revert and upgrade behavior, and Helm CRD upgrade ordering. Live updates, operator status reporting, and feature gates from #181 remain deferred.Closes #92.