Skip to content

Commit b21ddd8

Browse files
author
Sedef
committed
ClusterResourceSet feature
1 parent 99cb87a commit b21ddd8

27 files changed

+1693
-2
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ generate-go-core: $(CONTROLLER_GEN) $(CONVERSION_GEN)
222222
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
223223
paths=./api/... \
224224
paths=./$(EXP_DIR)/api/... \
225+
paths=./$(EXP_DIR)/clusterresourceset/api/... \
225226
paths=./cmd/clusterctl/...
226227
$(CONVERSION_GEN) \
227228
--input-dirs=./api/v1alpha2 \
@@ -275,6 +276,8 @@ generate-core-manifests: $(CONTROLLER_GEN) ## Generate manifests for the core pr
275276
paths=./controllers/... \
276277
paths=./$(EXP_DIR)/api/... \
277278
paths=./$(EXP_DIR)/controllers/... \
279+
paths=./$(EXP_DIR)/clusterresourceset/api/... \
280+
paths=./$(EXP_DIR)/clusterresourceset/controllers/... \
278281
crd:crdVersions=v1 \
279282
rbac:roleName=manager-role \
280283
output:crd:dir=./config/crd/bases \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.2.9
8+
creationTimestamp: null
9+
name: clusterresourcesetbindings.clusterresourceset.cluster.x-k8s.io
10+
spec:
11+
group: clusterresourceset.cluster.x-k8s.io
12+
names:
13+
categories:
14+
- cluster-api
15+
kind: ClusterResourceSetBinding
16+
listKind: ClusterResourceSetBindingList
17+
plural: clusterresourcesetbindings
18+
singular: clusterresourcesetbinding
19+
scope: Namespaced
20+
versions:
21+
- name: v1alpha3
22+
schema:
23+
openAPIV3Schema:
24+
description: ClusterResourceSetBinding lists all matching ClusterResourceSets
25+
with the cluster it belongs to.
26+
properties:
27+
apiVersion:
28+
description: 'APIVersion defines the versioned schema of this representation
29+
of an object. Servers should convert recognized schemas to the latest
30+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
31+
type: string
32+
clusterresourcesetmap:
33+
additionalProperties:
34+
description: ResourcesInClusterResourceSet keeps info on all of the
35+
resources in a ClusterResourceSet.
36+
properties:
37+
resources:
38+
additionalProperties:
39+
description: ClusterResourceSetResourceStatus keeps status of
40+
a resource that is applied to the cluster that ClusterResourceSetBinding
41+
belongs to.
42+
properties:
43+
hash:
44+
description: Hash is the hash of a resource's data. This can
45+
be used to decide if a resource is changed. For "ApplyOnce"
46+
ClusterResourceSet.spec.mode, this is no-op as that mode
47+
do not act on change.
48+
type: string
49+
lastAppliedTime:
50+
description: LastAppliedTime identifies when this resource
51+
was last applied to the cluster.
52+
format: date-time
53+
type: string
54+
successful:
55+
description: Successful is to track if a resource is successfully
56+
applied to the cluster or not.
57+
type: boolean
58+
type: object
59+
description: 'Resources is a map of Secrets/ConfigMaps and their
60+
ClusterResourceSetResourceStatus. The map''s key is a concatenated
61+
string of form: <resource-type>/<resource-name>.'
62+
type: object
63+
type: object
64+
description: ClusterResourceSetMap is a map of ClusterResourceSet and
65+
its resources which is also a map.
66+
type: object
67+
kind:
68+
description: 'Kind is a string value representing the REST resource this
69+
object represents. Servers may infer this from the endpoint the client
70+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
71+
type: string
72+
metadata:
73+
type: object
74+
type: object
75+
served: true
76+
storage: true
77+
subresources:
78+
status: {}
79+
status:
80+
acceptedNames:
81+
kind: ""
82+
plural: ""
83+
conditions: []
84+
storedVersions: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.2.9
8+
creationTimestamp: null
9+
name: clusterresourcesets.clusterresourceset.cluster.x-k8s.io
10+
spec:
11+
group: clusterresourceset.cluster.x-k8s.io
12+
names:
13+
categories:
14+
- cluster-api
15+
kind: ClusterResourceSet
16+
listKind: ClusterResourceSetList
17+
plural: clusterresourcesets
18+
singular: clusterresourceset
19+
scope: Namespaced
20+
versions:
21+
- name: v1alpha3
22+
schema:
23+
openAPIV3Schema:
24+
description: ClusterResourceSet is the Schema for the clusterresourcesets
25+
API
26+
properties:
27+
apiVersion:
28+
description: 'APIVersion defines the versioned schema of this representation
29+
of an object. Servers should convert recognized schemas to the latest
30+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
31+
type: string
32+
kind:
33+
description: 'Kind is a string value representing the REST resource this
34+
object represents. Servers may infer this from the endpoint the client
35+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: ClusterResourceSetSpec defines the desired state of ClusterResourceSet
41+
properties:
42+
clusterSelector:
43+
description: Label selector for Clusters. The Clusters that are selected
44+
by this will be the ones affected by this ClusterResourceSet. It
45+
must match the Cluster labels.
46+
properties:
47+
matchExpressions:
48+
description: matchExpressions is a list of label selector requirements.
49+
The requirements are ANDed.
50+
items:
51+
description: A label selector requirement is a selector that
52+
contains values, a key, and an operator that relates the key
53+
and values.
54+
properties:
55+
key:
56+
description: key is the label key that the selector applies
57+
to.
58+
type: string
59+
operator:
60+
description: operator represents a key's relationship to
61+
a set of values. Valid operators are In, NotIn, Exists
62+
and DoesNotExist.
63+
type: string
64+
values:
65+
description: values is an array of string values. If the
66+
operator is In or NotIn, the values array must be non-empty.
67+
If the operator is Exists or DoesNotExist, the values
68+
array must be empty. This array is replaced during a strategic
69+
merge patch.
70+
items:
71+
type: string
72+
type: array
73+
required:
74+
- key
75+
- operator
76+
type: object
77+
type: array
78+
matchLabels:
79+
additionalProperties:
80+
type: string
81+
description: matchLabels is a map of {key,value} pairs. A single
82+
{key,value} in the matchLabels map is equivalent to an element
83+
of matchExpressions, whose key field is "key", the operator
84+
is "In", and the values array contains only "value". The requirements
85+
are ANDed.
86+
type: object
87+
type: object
88+
mode:
89+
description: Mode is the mode to be used during applying resources.
90+
Defaults to ClusterResourceSetModeApplyOnce.
91+
type: string
92+
resources:
93+
description: Resources is a list of Secrets/ConfigMaps where each
94+
contains 1 or more resources to be applied to remote clusters.
95+
items:
96+
description: ClusterResourceSetResource specifies a resource.
97+
properties:
98+
kind:
99+
description: 'Kind of the resource. Supported kinds are: Secrets
100+
and ConfigMaps.'
101+
type: string
102+
name:
103+
description: Name of the resource that is in the same namespace
104+
with ClusterResourceSet object.
105+
type: string
106+
type: object
107+
type: array
108+
required:
109+
- clusterSelector
110+
type: object
111+
status:
112+
description: ClusterResourceSetStatus defines the observed state of ClusterResourceSet
113+
properties:
114+
lastUpdated:
115+
description: LastUpdated identifies when the ClusterResourceSet last
116+
updated.
117+
format: date-time
118+
type: string
119+
type: object
120+
type: object
121+
served: true
122+
storage: true
123+
subresources:
124+
status: {}
125+
status:
126+
acceptedNames:
127+
kind: ""
128+
plural: ""
129+
conditions: []
130+
storedVersions: []

config/crd/kustomization.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ resources:
77
- bases/cluster.x-k8s.io_machinesets.yaml
88
- bases/cluster.x-k8s.io_machinedeployments.yaml
99
- bases/exp.cluster.x-k8s.io_machinepools.yaml
10+
- bases/clusterresourceset.cluster.x-k8s.io_clusterresourcesets.yaml
11+
- bases/clusterresourceset.cluster.x-k8s.io_clusterresourcesetbindings.yaml
1012
- bases/cluster.x-k8s.io_machinehealthchecks.yaml
1113
# +kubebuilder:scaffold:crdkustomizeresource
1214

config/rbac/role.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,34 @@ rules:
118118
- patch
119119
- update
120120
- watch
121+
- apiGroups:
122+
- clusterresourceset.cluster.x-k8s.io
123+
resources:
124+
- '*'
125+
verbs:
126+
- create
127+
- delete
128+
- get
129+
- list
130+
- patch
131+
- update
132+
- watch
133+
- apiGroups:
134+
- clusterresourceset.cluster.x-k8s.io
135+
resources:
136+
- clusterresourcesets/status
137+
verbs:
138+
- get
139+
- patch
140+
- update
141+
- apiGroups:
142+
- ""
143+
resources:
144+
- configmaps
145+
verbs:
146+
- get
147+
- list
148+
- watch
121149
- apiGroups:
122150
- ""
123151
resources:

config/webhook/manifests.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ webhooks:
126126
resources:
127127
- machinepools
128128
sideEffects: None
129+
- clientConfig:
130+
caBundle: Cg==
131+
service:
132+
name: webhook-service
133+
namespace: system
134+
path: /mutate-exp-cluster-x-k8s-io-v1alpha3-clusterresourceset
135+
failurePolicy: Fail
136+
matchPolicy: Equivalent
137+
name: default.clusterresourceset.exp.cluster.x-k8s.io
138+
rules:
139+
- apiGroups:
140+
- exp.cluster.x-k8s.io
141+
apiVersions:
142+
- v1alpha3
143+
operations:
144+
- CREATE
145+
- UPDATE
146+
resources:
147+
- clusterresourcesets
148+
sideEffects: None
129149

130150
---
131151
apiVersion: admissionregistration.k8s.io/v1beta1
@@ -254,3 +274,23 @@ webhooks:
254274
resources:
255275
- machinepools
256276
sideEffects: None
277+
- clientConfig:
278+
caBundle: Cg==
279+
service:
280+
name: webhook-service
281+
namespace: system
282+
path: /validate-exp-cluster-x-k8s-io-v1alpha3-clusterresourceset
283+
failurePolicy: Fail
284+
matchPolicy: Equivalent
285+
name: validation.clusterresourceset.exp.cluster.x-k8s.io
286+
rules:
287+
- apiGroups:
288+
- exp.cluster.x-k8s.io
289+
apiVersions:
290+
- v1alpha3
291+
operations:
292+
- CREATE
293+
- UPDATE
294+
resources:
295+
- clusterresourcesets
296+
sideEffects: None

exp/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ This subrepository holds experimental code and API types.
66

77
In short, code in this subrepository is not subject to any compatibility or deprecation promise.
88

9-
TODO: Write policy around graduation and timelines.
9+
Experiments follow a strict lifecycle: Alpha -> Beta prior to Graduation.
10+
11+
For more information on graduation criteria, see: [Contributing Guidelines](https://github.com/kubernetes-sigs/cluster-api/blob/aa6acaac25ef923be874d31f4834d293625abb57/CONTRIBUTING.md#experiments)
12+
13+
## Active Features
14+
MachinePool (alpha)
15+
16+
ClusterResourceSet (alpha)

exp/clusterresourceset/PROJECT

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
domain: cluster.x-k8s.io
2+
repo: sigs.k8s.io/cluster-api
3+
resources:
4+
- group: clusterresourceset
5+
kind: ClusterResourceSet
6+
version: v1alpha3
7+
version: "2"

exp/clusterresourceset/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# clusterresourceset
2+
3+
This subrepository holds experimental ClusterResourceSet API types.
4+
5+
**Warning**: Packages here are experimental and unreliable. Some may one day be promoted to the main repository, or they may be modified arbitrarily or even disappear altogether.
6+
7+
In short, code in this subrepository is not subject to any compatibility or deprecation promise.

0 commit comments

Comments
 (0)