Skip to content

Commit 62f0d28

Browse files
authored
interface: add the new CR-based envelope API [Experimental] (#35)
* Added experimental CR-based envelope API Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Dropped the status field Signed-off-by: michaelawyu <chenyu1@microsoft.com> --------- Signed-off-by: michaelawyu <chenyu1@microsoft.com>
1 parent 981e0fb commit 62f0d28

File tree

10 files changed

+381
-6
lines changed

10 files changed

+381
-6
lines changed

apis/cluster/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Copyright 2025 The KubeFleet Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/apimachinery/pkg/runtime"
22+
)
23+
24+
// +genclient
25+
// +genclient:nonNamespaced
26+
// +kubebuilder:object:root=true
27+
// +kubebuilder:resource:scope="Cluster",categories={fleet,fleet-placement}
28+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
29+
30+
// ClusterResourceEnvelope wraps cluster-scoped resources for placement.
31+
type ClusterResourceEnvelope struct {
32+
metav1.TypeMeta `json:",inline"`
33+
metav1.ObjectMeta `json:"metadata,omitempty"`
34+
35+
// The desired state of ClusterResourceEnvelope.
36+
// +kubebuilder:validation:Required
37+
Spec EnvelopeSpec `json:"spec"`
38+
}
39+
40+
// EnvelopeSpec helps wrap resources for placement.
41+
type EnvelopeSpec struct {
42+
// A map of wrapped manifests.
43+
//
44+
// Each manifest is uniquely identified by a string key, typically a filename that represents
45+
// the manifest.
46+
// +kubebuilder:validation:Required
47+
// +kubebuilder:validation:MinProperties=1
48+
// +kubebuilder:validation:MaxProperties=50
49+
Manifests map[string]Manifest `json:"manifests"`
50+
}
51+
52+
// Manifest is a wrapped resource.
53+
type Manifest struct {
54+
// The resource data.
55+
// +kubebuilder:validation:Required
56+
// +kubebuilder:validation:EmbeddedResource
57+
// +kubebuilder:pruning:PreserveUnknownFields
58+
Data runtime.RawExtension `json:"data"`
59+
}
60+
61+
// +genclient
62+
// +genclient:Namespaced
63+
// +kubebuilder:object:root=true
64+
// +kubebuilder:resource:scope="Namespaced",categories={fleet,fleet-placement}
65+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
66+
type ResourceEnvelope struct {
67+
metav1.TypeMeta `json:",inline"`
68+
metav1.ObjectMeta `json:"metadata,omitempty"`
69+
70+
// The desired state of ResourceEnvelope.
71+
// +kubebuilder:validation:Required
72+
Spec EnvelopeSpec `json:"spec"`
73+
}

apis/placement/v1alpha1/zz_generated.deepcopy.go

Lines changed: 92 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/placement/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.0
7+
name: clusterresourceenvelopes.placement.kubernetes-fleet.io
8+
spec:
9+
group: placement.kubernetes-fleet.io
10+
names:
11+
categories:
12+
- fleet
13+
- fleet-placement
14+
kind: ClusterResourceEnvelope
15+
listKind: ClusterResourceEnvelopeList
16+
plural: clusterresourceenvelopes
17+
singular: clusterresourceenvelope
18+
scope: Cluster
19+
versions:
20+
- name: v1alpha1
21+
schema:
22+
openAPIV3Schema:
23+
description: ClusterResourceEnvelope wraps cluster-scoped resources for placement.
24+
properties:
25+
apiVersion:
26+
description: |-
27+
APIVersion defines the versioned schema of this representation of an object.
28+
Servers should convert recognized schemas to the latest internal value, and
29+
may reject unrecognized values.
30+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
31+
type: string
32+
kind:
33+
description: |-
34+
Kind is a string value representing the REST resource this object represents.
35+
Servers may infer this from the endpoint the client submits requests to.
36+
Cannot be updated.
37+
In CamelCase.
38+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
39+
type: string
40+
metadata:
41+
type: object
42+
spec:
43+
description: The desired state of ClusterResourceEnvelope.
44+
properties:
45+
manifests:
46+
additionalProperties:
47+
description: Manifest is a wrapped resource.
48+
properties:
49+
data:
50+
description: The resource data.
51+
type: object
52+
x-kubernetes-embedded-resource: true
53+
x-kubernetes-preserve-unknown-fields: true
54+
required:
55+
- data
56+
type: object
57+
description: |-
58+
A map of wrapped manifests.
59+
60+
Each manifest is uniquely identified by a string key, typically a filename that represents
61+
the manifest.
62+
maxProperties: 50
63+
minProperties: 1
64+
type: object
65+
required:
66+
- manifests
67+
type: object
68+
required:
69+
- spec
70+
type: object
71+
served: true
72+
storage: true
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.0
7+
name: resourceenvelopes.placement.kubernetes-fleet.io
8+
spec:
9+
group: placement.kubernetes-fleet.io
10+
names:
11+
categories:
12+
- fleet
13+
- fleet-placement
14+
kind: ResourceEnvelope
15+
listKind: ResourceEnvelopeList
16+
plural: resourceenvelopes
17+
singular: resourceenvelope
18+
scope: Namespaced
19+
versions:
20+
- name: v1alpha1
21+
schema:
22+
openAPIV3Schema:
23+
properties:
24+
apiVersion:
25+
description: |-
26+
APIVersion defines the versioned schema of this representation of an object.
27+
Servers should convert recognized schemas to the latest internal value, and
28+
may reject unrecognized values.
29+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
30+
type: string
31+
kind:
32+
description: |-
33+
Kind is a string value representing the REST resource this object represents.
34+
Servers may infer this from the endpoint the client submits requests to.
35+
Cannot be updated.
36+
In CamelCase.
37+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
38+
type: string
39+
metadata:
40+
type: object
41+
spec:
42+
description: The desired state of ResourceEnvelope.
43+
properties:
44+
manifests:
45+
additionalProperties:
46+
description: Manifest is a wrapped resource.
47+
properties:
48+
data:
49+
description: The resource data.
50+
type: object
51+
x-kubernetes-embedded-resource: true
52+
x-kubernetes-preserve-unknown-fields: true
53+
required:
54+
- data
55+
type: object
56+
description: |-
57+
A map of wrapped manifests.
58+
59+
Each manifest is uniquely identified by a string key, typically a filename that represents
60+
the manifest.
61+
maxProperties: 50
62+
minProperties: 1
63+
type: object
64+
required:
65+
- manifests
66+
type: object
67+
required:
68+
- spec
69+
type: object
70+
served: true
71+
storage: true

0 commit comments

Comments
 (0)