Repository navigation
Add conversion webhook infrastructure for openstack-operator CRDs #2133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stuggi
wants to merge
4
commits into
openstack-k8s-operators:main
Choose a base branch
from
stuggi:crd_update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
819c038
Enable conversion webhook activation in the bindata pipeline
stuggi 138fdda
Enable conversion webhook plumbing for openstack-operator CRDs
stuggi 211e078
Rewrite CRD namespace fields and preserve cert-manager caBundle
stuggi 1e023a9
Add conversion webhook kuttl test (Phase-1 milestone gate)
stuggi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| name: Check CRD Webhook Coverage | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'config/crd/bases/**' | ||
| - 'config/crd/patches/**' | ||
| - 'config/crd/kustomization.yaml' | ||
|
|
||
| jobs: | ||
| check-webhook-patches: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Check all CRDs have conversion webhook patches | ||
| run: | | ||
| set -e | ||
|
|
||
| echo "Checking that all openstack-operator CRDs have webhook + CA-injection patches..." | ||
|
|
||
| MISSING_PATCHES=0 | ||
|
|
||
| # Check each CRD in config/crd/bases/ | ||
| for crd_file in config/crd/bases/*.yaml; do | ||
| # Skip if not a file or if it's the commented-out openstacks.yaml | ||
| [[ ! -f "$crd_file" ]] && continue | ||
| basename=$(basename "$crd_file") | ||
| [[ "$basename" == "operator.openstack.org_openstacks.yaml" ]] && continue | ||
|
|
||
| # Extract CRD name (e.g., "core.openstack.org_openstackcontrolplanes") | ||
| crd_name="${basename%.yaml}" | ||
|
|
||
| # Check for webhook patch | ||
| webhook_patch="config/crd/patches/webhook_in_${crd_name}.yaml" | ||
| if [[ ! -f "$webhook_patch" ]]; then | ||
| echo "ERROR: Missing webhook patch for $basename" | ||
| echo " Expected: $webhook_patch" | ||
| MISSING_PATCHES=1 | ||
| fi | ||
|
|
||
| # Check for CA injection patch | ||
| cainjection_patch="config/crd/patches/cainjection_in_${crd_name}.yaml" | ||
| if [[ ! -f "$cainjection_patch" ]]; then | ||
| echo "ERROR: Missing CA injection patch for $basename" | ||
| echo " Expected: $cainjection_patch" | ||
| MISSING_PATCHES=1 | ||
| fi | ||
|
|
||
| # Check that patches are referenced in kustomization.yaml (and not commented out) | ||
| if ! grep -q "^- path: patches/webhook_in_${crd_name}.yaml" config/crd/kustomization.yaml; then | ||
| echo "ERROR: Webhook patch for $basename not referenced (or commented out) in kustomization.yaml" | ||
| MISSING_PATCHES=1 | ||
| fi | ||
|
|
||
| if ! grep -q "^- path: patches/cainjection_in_${crd_name}.yaml" config/crd/kustomization.yaml; then | ||
| echo "ERROR: CA injection patch for $basename not referenced (or commented out) in kustomization.yaml" | ||
| MISSING_PATCHES=1 | ||
| fi | ||
| done | ||
|
|
||
| if [[ $MISSING_PATCHES -eq 1 ]]; then | ||
| echo "" | ||
| echo "One or more CRDs are missing conversion webhook patches." | ||
| echo "For each CRD in config/crd/bases/, you must create:" | ||
| echo " 1. config/crd/patches/webhook_in_<crd>.yaml" | ||
| echo " 2. config/crd/patches/cainjection_in_<crd>.yaml" | ||
| echo " 3. Reference both in config/crd/kustomization.yaml" | ||
| echo "" | ||
| echo "See existing patches for examples." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✓ All CRDs have conversion webhook patches" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_assistant.openstack.org_openstackassistants.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackassistants.assistant.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackassistants.assistant.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_backup.openstack.org_openstackbackupconfigs.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackbackupconfigs.backup.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackbackupconfigs.backup.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_client.openstack.org_openstackclients.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackclients.client.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackclients.client.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_core.openstack.org_openstackcontrolplanes.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackcontrolplanes.core.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackcontrolplanes.core.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_core.openstack.org_openstackversions.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackversions.core.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackversions.core.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_dataplane.openstack.org_openstackdataplanedeployments.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackdataplanedeployments.dataplane.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackdataplanedeployments.dataplane.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_dataplane.openstack.org_openstackdataplanenodesets.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackdataplanenodesets.dataplane.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackdataplanenodesets.dataplane.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_dataplane.openstack.org_openstackdataplaneservices.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Adds the cert-manager CA-injection annotation to the openstackdataplaneservices.dataplane.openstack.org CRD so | ||
| # the conversion webhook's clientConfig.caBundle is populated at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackdataplaneservices.dataplane.openstack.org | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: '{{ .OperatorNamespace }}/openstack-operator-serving-cert' |
18 changes: 18 additions & 0 deletions
18
config/crd/patches/webhook_in_assistant.openstack.org_openstackassistants.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Enables the conversion webhook for the openstackassistants.assistant.openstack.org CRD. | ||
| # Stays dormant while the CRD has a single served version; activates automatically | ||
| # once a second version is added. Namespace is resolved at deploy time. | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: openstackassistants.assistant.openstack.org | ||
| spec: | ||
| conversion: | ||
| strategy: Webhook | ||
| webhook: | ||
| clientConfig: | ||
| service: | ||
| namespace: '{{ .OperatorNamespace }}' | ||
| name: openstack-operator-webhook-service | ||
| path: /convert | ||
| conversionReviewVersions: | ||
| - v1 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.