-
Notifications
You must be signed in to change notification settings - Fork 20
interface: add the new CR-based envelope API [Experimental] #35
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
interface: add the new CR-based envelope API [Experimental] #35
Conversation
Signed-off-by: michaelawyu <chenyu1@microsoft.com>
| // +kubebuilder:validation:Required | ||
| // +kubebuilder:validation:MinProperties=1 | ||
| // +kubebuilder:validation:MaxProperties=50 | ||
| Manifests map[string]Manifest `json:"manifests"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: a map is used here to make sure that each manifest is uniquely identified with a key, which can later be used in status reporting.
|
|
||
| // The desired state of ClusterResourceEnvelope. | ||
| // +kubebuilder:validation:Required | ||
| Spec EnvelopeSpec `json:"spec"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we keep the spec field here just as a common practice; if necessary we could expose the inner object directly to reduce nesting.
| } | ||
|
|
||
| // Manifest is a wrapped resource. | ||
| type Manifest struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could put the YAML content directly as the map value; it is now wrapped in a struct just in case we might need to add some resource-specific options in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, in earlier discussions we have received requests regarding the possibility of doing API server validation on wrapped resources as an extra layer of defense -> if implemented, we might need to have a bypassValidation option here to allow wrapping of resources that are expected to fail API server validation (e.g., the corresponding API is only available on the member cluster side, or a mutating webhook is expected to modify the object on the member cluster side).
| } | ||
|
|
||
| // ClusterResourceEnvelopeStatus is the observed status of a ClusterResourceEnvelope. | ||
| type ClusterResourceEnvelopeStatus struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The status fields are added just in case in the future we might want to implement additional checks for wrapped resources. In the initial stage this might not be necessary, and it should be safe for us to drop these fields at first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not add status now as we can always add them later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will drop the status field 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an experimental CR-based envelope API for wrapping and placing Kubernetes resources.
- Provides examples for both namespaced and cluster-scoped envelopes.
- Adds new CustomResourceDefinitions along with the necessary API types and generated deepcopy functions.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| examples/envelopes/namespacescoped.yaml | Adds example for a namespaced ResourceEnvelope with ConfigMap and Deployment manifests. |
| examples/envelopes/clusterscoped.yaml | Adds example for a ClusterResourceEnvelope with webhook and ClusterRole manifests. |
| config/crd/bases/placement.kubernetes-fleet.io_resourceenvelopes.yaml | Introduces CRD for namespaced ResourceEnvelopes. |
| config/crd/bases/placement.kubernetes-fleet.io_clusterresourceenvelopes.yaml | Introduces CRD for ClusterResourceEnvelopes. |
| apis/placement/v1alpha1/zz_generated.deepcopy.go | Updates generated deepcopy functions for new envelope types. |
| apis/placement/v1alpha1/envelope_types.go | Defines API types for both ClusterResourceEnvelope and ResourceEnvelope. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an experimental CR-based envelope API intended to wrap Kubernetes resources for advanced placement scenarios. Key changes include:
- New YAML examples demonstrating both namespaced and cluster-scoped envelope resources.
- The addition of two CRD definitions for ResourceEnvelope and ClusterResourceEnvelope.
- Auto-generated deepcopy functions and API types to support the envelope API.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| examples/envelopes/namespacescoped.yaml | Introduces a namespaced envelope example. |
| examples/envelopes/clusterscoped.yaml | Introduces a cluster-scoped envelope example. |
| config/crd/bases/placement.kubernetes-fleet.io_resourceenvelopes.yaml | Adds CRD for resource envelopes. |
| config/crd/bases/placement.kubernetes-fleet.io_clusterresourceenvelopes.yaml | Adds CRD for cluster resource envelopes. |
| apis/placement/v1alpha1/zz_generated.deepcopy.go | Adds deepcopy methods for new envelope types. |
| apis/placement/v1alpha1/envelope_types.go | Defines API types for envelope resources. |
Signed-off-by: michaelawyu <chenyu1@microsoft.com>
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Description of your changes
This PR adds an experimental design of the proposed CR-based envelope API.
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
N/A
Special notes for your reviewer