diff --git a/components/dependencies/openstack-operator/README.md b/components/dependencies/openstack-operator/README.md new file mode 100644 index 0000000..b0b5b73 --- /dev/null +++ b/components/dependencies/openstack-operator/README.md @@ -0,0 +1,125 @@ +# openstack-operator deployment component + +Deploys the Red Hat OpenStack Services on OpenShift (RHOSO) `openstack-operator` +through a plain OLM `Subscription`, **without pinning a CatalogSource image to a +specific OpenShift version** and **without pinning the operator CSV** +(`spec.startingCSV` is intentionally absent). + +## Requirements + +- An **entitled/subscribed OpenShift cluster** with a healthy built-in + `redhat-operators` CatalogSource in the `openshift-marketplace` namespace: + + ```bash + oc get catalogsource redhat-operators -n openshift-marketplace + ``` + +- On **disconnected** clusters, the mirror of `redhat-operators` must include + the `openstack-operator` package (see the RHOSO documentation on mirroring + operator catalogs for restricted networks). + +Because the component references the cluster's own `redhat-operators` catalog, +the operator version resolved by OLM always matches what the cluster's catalog +offers for the `stable-v1.0` channel — there is no `redhat-operator-index:vX.Y` +image reference to drift from the cluster version. + +## What it deploys + +| Resource | Notes | +|----------|-------| +| `Namespace/openstack-operators` | OLM namespace for the Subscription | +| `Namespace/openstack` | `privileged` pod security, no label sync | +| `OperatorGroup/openstack` | AllNamespaces install mode | +| `Subscription/openstack` | channel `stable-v1.0`, `installPlanApproval: Manual`, **no `startingCSV`** | + +Note: `installPlanApproval: Manual` means InstallPlans must be approved — either +manually or with the `components/utilities/approve-installplan` component (as +`example/openstack-operator` does). + +When consumed through the [rhoso-gitops validated pattern][rhoso-gitops], the +pattern's overrides delete the Namespaces and the OperatorGroup from this +component (they are managed by the pattern's ClusterGroup chart and by OLM's +AllNamespaces mode respectively) — only the Subscription survives. + +## Usage + +From a sibling path in this repository (as `example/openstack-operator` does): + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +components: + - ../../components/dependencies/openstack-operator +``` + +Or remotely, pinned to a ref of this repository: + +```yaml +components: + - https://github.com/openstack-k8s-operators/gitops/components/dependencies/openstack-operator?ref=v0.3.5 +``` + +## Patching + +### Pin the operator version + +This component is unpinned by design. To pin to a specific CSV, add a patch +targeting the Subscription instead of re-introducing the former +`pin-version`/`olm-values` machinery: + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +components: + - ../../components/dependencies/openstack-operator +patches: + - target: + kind: Subscription + name: openstack + patch: |- + - op: add + path: /spec/startingCSV + value: "openstack-operator.v1.0.16" +``` + +Remember that `spec.startingCSV` is a **floor, not a ceiling**: if the catalog +contains a newer CSV in the same channel, OLM resolves to the newer one. + +### Use a different catalog or channel + +Same mechanism — patch the Subscription fields: + +```yaml +patches: + - target: + kind: Subscription + name: openstack + patch: |- + - op: replace + path: /spec/channel + value: "alpha" + - op: replace + path: /spec/source + value: "my-mirrored-catalog" + - op: replace + path: /spec/sourceNamespace + value: "openshift-marketplace" +``` + +### Local overlay + +For more involved changes (extra resources, different approval mode), create a +local overlay that composes this component instead of copying it, so upstream +fixes still flow in: + +``` +my-overlay/ +├── kustomization.yaml # components: ../components/dependencies/openstack-operator + patches +└── ... +``` + +Consumers deploying through ArgoCD can equivalently use the Application's +`spec.source.kustomize.patches` — that is how the rhoso-gitops validated +pattern adjusts this component's resources without forking. + +[rhoso-gitops]: https://github.com/validatedpatterns-sandbox/rhoso-gitops diff --git a/components/dependencies/openstack-operator/kustomization.yaml b/components/dependencies/openstack-operator/kustomization.yaml new file mode 100644 index 0000000..ee96064 --- /dev/null +++ b/components/dependencies/openstack-operator/kustomization.yaml @@ -0,0 +1,10 @@ +--- +# Deploys the openstack-operator Subscription, relying on the catalog that +# OpenShift ships on every subscribed cluster (redhat-operators). See README.md. +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - namespaces.yaml + - operatorgroup.yaml + - subscription.yaml diff --git a/components/dependencies/openstack-operator/namespaces.yaml b/components/dependencies/openstack-operator/namespaces.yaml new file mode 100644 index 0000000..6895a0f --- /dev/null +++ b/components/dependencies/openstack-operator/namespaces.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: openstack-operators +--- +apiVersion: v1 +kind: Namespace +metadata: + name: openstack + labels: + pod-security.kubernetes.io/enforce: privileged + security.openshift.io/scc.podSecurityLabelSync: "false" diff --git a/components/dependencies/openstack-operator/operatorgroup.yaml b/components/dependencies/openstack-operator/operatorgroup.yaml new file mode 100644 index 0000000..894ac84 --- /dev/null +++ b/components/dependencies/openstack-operator/operatorgroup.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: operators.coreos.com/v1 +kind: OperatorGroup +metadata: + name: openstack + namespace: openstack-operators diff --git a/components/dependencies/openstack-operator/subscription.yaml b/components/dependencies/openstack-operator/subscription.yaml new file mode 100644 index 0000000..b1918c5 --- /dev/null +++ b/components/dependencies/openstack-operator/subscription.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: openstack + namespace: openstack-operators +spec: + channel: stable-v1.0 + installPlanApproval: Manual + name: openstack-operator + # Rely on the catalog OpenShift ships on subscribed clusters instead of + # pinning a CatalogSource image to a specific OCP version. See README.md. + source: redhat-operators + sourceNamespace: openshift-marketplace diff --git a/example/openstack-operator/catalog/kustomization.yaml b/example/openstack-operator/catalog/kustomization.yaml deleted file mode 100644 index 58bd586..0000000 --- a/example/openstack-operator/catalog/kustomization.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - values.yaml diff --git a/example/openstack-operator/catalog/values.yaml b/example/openstack-operator/catalog/values.yaml deleted file mode 100644 index 33b65bf..0000000 --- a/example/openstack-operator/catalog/values.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# local-config: referenced, but not emitted by kustomize ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: olm-values - annotations: - config.kubernetes.io/local-config: 'true' -data: - openstack-operator-subscription-namespace: "openstack-operators" - openstack-operator-channel: "stable-v1.0" - openstack-operator-installplanapproval: "Manual" - # --- CatalogSource Settings --- - openstack-operator-catalog-source: "redhat-operators" - openstack-catalog-namespace: "openshift-marketplace" - openstack-operator-image: "registry.redhat.io/redhat/redhat-operator-index:v4.18" - openstack-operator-display-name: "Red Hat Operators" - openstack-operator-publisher: "Red Hat" diff --git a/example/openstack-operator/kustomization.yaml b/example/openstack-operator/kustomization.yaml index a6a8229..5cb2d5d 100644 --- a/example/openstack-operator/kustomization.yaml +++ b/example/openstack-operator/kustomization.yaml @@ -2,15 +2,11 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -resources: - - catalog - -# pin-version must run before the remote OLM component (olm-values feeds replacements). -# approve-installplan must run after the remote component so the Subscription exists for the sync-wave patch. +# openstack-operator is deployed from the cluster's own redhat-operators +# catalog (no pinned CatalogSource image, no pinned CSV), see +# ../../components/dependencies/openstack-operator/README.md. +# approve-installplan must run after the Subscription exists (it patches +# the Subscription sync-wave). components: - - pin-version - - https://github.com/openstack-k8s-operators/architecture/lib/olm-openstack-subscriptions/overlays/default?ref=7da5f2e1dc2bfce99e269b0017783679ca405d8c - # TODO: replace the local path with a git HTTPS URI, e.g. - # https://github.com/openstack-k8s-operators/gitops/components/utilities/approve-installplan?ref=v0.3.1 - # once that tag includes this component (same pattern as other example overlays). + - ../../components/dependencies/openstack-operator - ../../components/utilities/approve-installplan diff --git a/example/openstack-operator/pin-version/kustomization.yaml b/example/openstack-operator/pin-version/kustomization.yaml deleted file mode 100644 index 1011495..0000000 --- a/example/openstack-operator/pin-version/kustomization.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# Patches olm-values with a pinned ClusterServiceVersion for spec.startingCSV on the Subscription. -apiVersion: kustomize.config.k8s.io/v1alpha1 -kind: Component -patches: - - path: patch.yaml - target: - kind: ConfigMap - name: olm-values diff --git a/example/openstack-operator/pin-version/patch.yaml b/example/openstack-operator/pin-version/patch.yaml deleted file mode 100644 index 16e1b9c..0000000 --- a/example/openstack-operator/pin-version/patch.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- op: add - path: /data/openstack-operator-version - value: "openstack-operator.v1.0.16"