Skip to content

Commit

Permalink
Add leaf node generate rules
Browse files Browse the repository at this point in the history
Signed-off-by: wuyingjun <[email protected]>

fix manifest crds bug

Signed-off-by: wuyingjun <[email protected]>
  • Loading branch information
wuyingjun-lucky committed Nov 1, 2023
1 parent 880bd8c commit 7be5c5e
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 5 deletions.
74 changes: 74 additions & 0 deletions deploy/crds/kosmos.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,60 @@ spec:
enable:
default: true
type: boolean
leafSelector:
description: LeafSelector provide an api to arrange the member
cluster with some rules to pretend one or more leaf node
properties:
labelSelector:
description: LabelSelector is a filter to select member cluster
nodes to pretend a leaf node in clusterTree by labels. If
non-nil and non-empty, the hole member cluster nodes will
pretend one leaf node.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In, NotIn,
Exists and DoesNotExist.
type: string
values:
description: values is an array of string values.
If the operator is In or NotIn, the values array
must be non-empty. If the operator is Exists or
DoesNotExist, the values array must be empty.
This array is replaced during a strategic merge
patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs.
A single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field is
"key", the operator is "In", and the values array contains
only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
type: object
imageRepository:
type: string
Expand All @@ -128,6 +182,7 @@ spec:
description: Status describes the current status of a cluster.
properties:
clusterLinkStatus:
description: ClusterLinkStatus contain the cluster network information
properties:
podCIDRs:
items:
Expand All @@ -138,6 +193,25 @@ spec:
type: string
type: array
type: object
clusterTreeStatus:
description: ClusterTreeStatus contain the member cluster leafNode
end status
properties:
leafNodeItems:
description: LeafNodeItems represents list of the leaf node Items
calculating in each member cluster.
items:
properties:
leafNodeName:
description: LeafNodeName represents the leaf node name
generate by controller. suggest name format like cluster-shortLabel-number
like member-az1-1
type: string
required:
- leafNodeName
type: object
type: array
type: object
type: object
required:
- spec
Expand Down
12 changes: 12 additions & 0 deletions docs/proposals/leafnodegenerate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Kosmos ClusterTree leaf node generate rules

## Summary
Provide a member cluster to pretend one or more Leaf Nodes in clusterTree by some rules like Node labelSelector

## Motivation & User Stories
1、Some products can provide idle resources Nodes to join Kosmos
2、Some products want an easy way to make a second pod schedule in their member clusters.

## Design Details
### Architecture
![leaf_node_rules](img/leaf-nodes.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hack/update-crds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export PATH=$PATH:$GOPATH/bin

controller-gen crd paths=./pkg/apis/kosmos/... output:crd:dir="${REPO_ROOT}/deploy/crds"

go run "${REPO_ROOT}/hack/generate/generate.go"
#go run "${REPO_ROOT}/hack/generate/generate.go"
30 changes: 30 additions & 0 deletions pkg/apis/kosmos/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ type ClusterSpec struct {
}

type ClusterStatus struct {
// ClusterLinkStatus contain the cluster network information
// +optional
ClusterLinkStatus ClusterLinkStatus `json:"clusterLinkStatus,omitempty"`

// ClusterTreeStatus contain the member cluster leafNode end status
// +optional
ClusterTreeStatus ClusterTreeStatus `json:"clusterTreeStatus,omitempty"`
}

type ClusterLinkOptions struct {
Expand Down Expand Up @@ -90,6 +96,17 @@ type ClusterTreeOptions struct {
// +kubebuilder:default=true
// +optional
Enable bool `json:"enable"`

// LeafSelector provide an api to arrange the member cluster with some rules to pretend one or more leaf node
// +optional
LeafSelector LeafSelector `json:"leafSelector,omitempty"`
}

type LeafSelector struct {
// LabelSelector is a filter to select member cluster nodes to pretend a leaf node in clusterTree by labels.
// If non-nil and non-empty, the hole member cluster nodes will pretend one leaf node.
// +optional
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
}

type ClusterLinkStatus struct {
Expand All @@ -99,6 +116,19 @@ type ClusterLinkStatus struct {
ServiceCIDRs []string `json:"serviceCIDRs,omitempty"`
}

type ClusterTreeStatus struct {
// LeafNodeItems represents list of the leaf node Items calculating in each member cluster.
// +optional
LeafNodeItems []LeafNodeItem `json:"leafNodeItems,omitempty"`
}

type LeafNodeItem struct {
// LeafNodeName represents the leaf node name generate by controller.
// suggest name format like cluster-shortLabel-number like member-az1-1
// +required
LeafNodeName string `json:"leafNodeName"`
}

type VxlanCIDRs struct {
IP string `json:"ip"`
IP6 string `json:"ip6"`
Expand Down
62 changes: 61 additions & 1 deletion pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7be5c5e

Please sign in to comment.