Skip to content

Commit 13b7d38

Browse files
committed
Adding managed namespace field in the managedclusterset
Signed-off-by: Jian Qiu <[email protected]>
1 parent c0d6364 commit 13b7d38

7 files changed

+201
-12
lines changed

cluster/v1/0000_00_clusters.open-cluster-management.io_managedclusters.crd.yaml

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ spec:
165165
- type: string
166166
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
167167
x-kubernetes-int-or-string: true
168-
description: Allocatable represents the total allocatable resources
168+
description: allocatable represents the total allocatable resources
169169
on the managed cluster.
170170
type: object
171171
capacity:
@@ -176,12 +176,12 @@ spec:
176176
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
177177
x-kubernetes-int-or-string: true
178178
description: |-
179-
Capacity represents the total resource capacity from all nodeStatuses
179+
capacity represents the total resource capacity from all nodeStatuses
180180
on the managed cluster.
181181
type: object
182182
clusterClaims:
183183
description: |-
184-
ClusterClaims represents cluster information that a managed cluster claims,
184+
clusterClaims represents cluster information that a managed cluster claims,
185185
for example a unique cluster identifier (id.k8s.io) and kubernetes version
186186
(kubeversion.open-cluster-management.io). They are written from the managed
187187
cluster. The set of claims is not uniform across a fleet, some claims can be
@@ -205,7 +205,7 @@ spec:
205205
type: object
206206
type: array
207207
conditions:
208-
description: Conditions contains the different condition statuses
208+
description: conditions contains the different condition statuses
209209
for this managed cluster.
210210
items:
211211
description: Condition contains details for one aspect of the current
@@ -262,8 +262,89 @@ spec:
262262
- type
263263
type: object
264264
type: array
265+
managedNamespaces:
266+
description: |-
267+
managedNamespaces are a list of namespaces managed by the clustersets the
268+
cluster belongs to.
269+
items:
270+
properties:
271+
clusterSet:
272+
description: clusterSet represents the name of the cluster set.
273+
type: string
274+
conditions:
275+
description: conditions are the status conditions of the managed
276+
namespace
277+
items:
278+
description: Condition contains details for one aspect of
279+
the current state of this API Resource.
280+
properties:
281+
lastTransitionTime:
282+
description: |-
283+
lastTransitionTime is the last time the condition transitioned from one status to another.
284+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
285+
format: date-time
286+
type: string
287+
message:
288+
description: |-
289+
message is a human readable message indicating details about the transition.
290+
This may be an empty string.
291+
maxLength: 32768
292+
type: string
293+
observedGeneration:
294+
description: |-
295+
observedGeneration represents the .metadata.generation that the condition was set based upon.
296+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
297+
with respect to the current state of the instance.
298+
format: int64
299+
minimum: 0
300+
type: integer
301+
reason:
302+
description: |-
303+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
304+
Producers of specific condition types may define expected values and meanings for this field,
305+
and whether the values are considered a guaranteed API.
306+
The value should be a CamelCase string.
307+
This field may not be empty.
308+
maxLength: 1024
309+
minLength: 1
310+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
311+
type: string
312+
status:
313+
description: status of the condition, one of True, False,
314+
Unknown.
315+
enum:
316+
- "True"
317+
- "False"
318+
- Unknown
319+
type: string
320+
type:
321+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
322+
maxLength: 316
323+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
324+
type: string
325+
required:
326+
- lastTransitionTime
327+
- message
328+
- reason
329+
- status
330+
- type
331+
type: object
332+
type: array
333+
name:
334+
description: name is the name of the namespace.
335+
maxLength: 63
336+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
337+
type: string
338+
required:
339+
- clusterSet
340+
- name
341+
type: object
342+
type: array
343+
x-kubernetes-list-map-keys:
344+
- clusterSet
345+
x-kubernetes-list-type: map
265346
version:
266-
description: Version represents the kubernetes version of the managed
347+
description: version represents the kubernetes version of the managed
267348
cluster.
268349
properties:
269350
kubernetes:

cluster/v1/types.go

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,26 +144,33 @@ const (
144144

145145
// ManagedClusterStatus represents the current status of joined managed cluster.
146146
type ManagedClusterStatus struct {
147-
// Conditions contains the different condition statuses for this managed cluster.
147+
// conditions contains the different condition statuses for this managed cluster.
148148
Conditions []metav1.Condition `json:"conditions"`
149149

150-
// Capacity represents the total resource capacity from all nodeStatuses
150+
// capacity represents the total resource capacity from all nodeStatuses
151151
// on the managed cluster.
152152
Capacity ResourceList `json:"capacity,omitempty"`
153153

154-
// Allocatable represents the total allocatable resources on the managed cluster.
154+
// allocatable represents the total allocatable resources on the managed cluster.
155155
Allocatable ResourceList `json:"allocatable,omitempty"`
156156

157-
// Version represents the kubernetes version of the managed cluster.
157+
// version represents the kubernetes version of the managed cluster.
158158
Version ManagedClusterVersion `json:"version,omitempty"`
159159

160-
// ClusterClaims represents cluster information that a managed cluster claims,
160+
// clusterClaims represents cluster information that a managed cluster claims,
161161
// for example a unique cluster identifier (id.k8s.io) and kubernetes version
162162
// (kubeversion.open-cluster-management.io). They are written from the managed
163163
// cluster. The set of claims is not uniform across a fleet, some claims can be
164164
// vendor or version specific and may not be included from all managed clusters.
165165
// +optional
166166
ClusterClaims []ManagedClusterClaim `json:"clusterClaims,omitempty"`
167+
168+
// managedNamespaces are a list of namespaces managed by the clustersets the
169+
// cluster belongs to.
170+
// +optional
171+
// +listType=map
172+
// +listMapKey=clusterSet
173+
ManagedNamespaces []ClusterSetManagedNamespaceConfig `json:"managedNamespaces,omitempty"`
167174
}
168175

169176
// ManagedClusterVersion represents version information about the managed cluster.
@@ -188,6 +195,27 @@ type ManagedClusterClaim struct {
188195
Value string `json:"value,omitempty"`
189196
}
190197

198+
// managedNamespaces defines a namespace on the managedclusters across the
199+
// clusterset to be managed by this clusterset.
200+
type ManagedNamespaceConfig struct {
201+
// name is the name of the namespace.
202+
// +required
203+
// +kubebuilder:validation:MaxLength=63
204+
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
205+
Name string `json:"name"`
206+
}
207+
208+
type ClusterSetManagedNamespaceConfig struct {
209+
ManagedNamespaceConfig `json:",inline"`
210+
211+
// clusterSet represents the name of the cluster set.
212+
// +required
213+
ClusterSet string `json:"clusterSet"`
214+
215+
// conditions are the status conditions of the managed namespace
216+
Conditions []metav1.Condition `json:"conditions,omitempty"`
217+
}
218+
191219
const (
192220
// ManagedClusterConditionJoined means the managed cluster has successfully joined the hub.
193221
ManagedClusterConditionJoined string = "ManagedClusterJoined"

cluster/v1/zz_generated.deepcopy.go

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

cluster/v1beta2/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ spec:
127127
required:
128128
- selectorType
129129
type: object
130+
managedNamespaces:
131+
description: |-
132+
managedNamespaces defines the list of namespace on the managedclusters
133+
across the clusterset to be managed.
134+
items:
135+
description: |-
136+
managedNamespaces defines a namespace on the managedclusters across the
137+
clusterset to be managed by this clusterset.
138+
properties:
139+
name:
140+
description: name is the name of the namespace.
141+
maxLength: 63
142+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
143+
type: string
144+
required:
145+
- name
146+
type: object
147+
type: array
148+
x-kubernetes-list-map-keys:
149+
- name
150+
x-kubernetes-list-type: map
130151
type: object
131152
status:
132153
description: Status represents the current status of the ManagedClusterSet

cluster/v1beta2/types_managedclusterset.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v1beta2
33

44
import (
55
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
v1 "open-cluster-management.io/api/cluster/v1"
67
)
78

89
// ExclusiveClusterSetLabel LabelKey
@@ -48,6 +49,13 @@ type ManagedClusterSetSpec struct {
4849
// +optional
4950
// +kubebuilder:default:={selectorType: ExclusiveClusterSetLabel}
5051
ClusterSelector ManagedClusterSelector `json:"clusterSelector,omitempty"`
52+
53+
// managedNamespaces defines the list of namespace on the managedclusters
54+
// across the clusterset to be managed.
55+
// +optional
56+
// +listType=map
57+
// +listMapKey=name
58+
ManagedNamespaces []v1.ManagedNamespaceConfig `json:"managedNamespaces,omitempty"`
5159
}
5260

5361
// ManagedClusterSelector represents a selector of ManagedClusters

cluster/v1beta2/zz_generated.deepcopy.go

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

hack/update-copyright.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ fi
3535

3636
COMMUNITY_COPY_HEADER_STRING=$(cat $COMMUNITY_COPY_HEADER_FILE | sed 's#^// ##')
3737

38-
echo "Desired copyright header is: $COMMUNITY_COPY_HEADER_STRING"
39-
4038
# NOTE: Only use one newline or javascript and typescript linter/prettier will complain about the extra blank lines
4139
NEWLINE="\n"
4240

0 commit comments

Comments
 (0)