Skip to content

Conversation

@michaelawyu
Copy link
Collaborator

Description of your changes

This PR adds an experimental design of the proposed CR-based envelope API.

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

N/A

Special notes for your reviewer

  • Please see the comments for additional details.

Signed-off-by: michaelawyu <chenyu1@microsoft.com>
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinProperties=1
// +kubebuilder:validation:MaxProperties=50
Manifests map[string]Manifest `json:"manifests"`
Copy link
Collaborator Author

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"`
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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.

Copy link
Contributor

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

Copy link
Collaborator Author

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 👌

@ryanzhang-oss ryanzhang-oss requested a review from Copilot April 28, 2025 20:08
Copy link
Contributor

Copilot AI left a 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.

@ryanzhang-oss ryanzhang-oss requested a review from Copilot April 29, 2025 00:04
Copy link
Contributor

Copilot AI left a 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
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 0% with 59 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apis/placement/v1alpha1/zz_generated.deepcopy.go 0.00% 59 Missing ⚠️

📢 Thoughts on this report? Let us know!

@michaelawyu michaelawyu merged commit 62f0d28 into kubefleet-dev:main Apr 29, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants