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]>
  • Loading branch information
wuyingjun-lucky committed Nov 1, 2023
1 parent 880bd8c commit f53c66a
Show file tree
Hide file tree
Showing 7 changed files with 395 additions and 5 deletions.
119 changes: 119 additions & 0 deletions deploy/crds/kosmos.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,105 @@ spec:
enable:
default: true
type: boolean
leafModel:
description: LeafModel provide an api to arrange the member cluster
with some rules to pretend one or more leaf node
items:
properties:
labelSelector:
description: LabelSelector is a filter to select member
cluster nodes to pretend a leaf node in clusterTree by
labels. If nil or 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
labels:
additionalProperties:
type: string
description: Labels that will be setting in the pretended
Node labels
type: object
leafNodeName:
description: LeafNodeName defines leaf name If nil or empty,
the leaf node name will generate by controller and fill
in cluster link status
type: string
taints:
description: Taints attached to the leaf pretended Node.
If nil or empty, controller will set the default no-schedule
taint
items:
description: The node this Taint is attached to has the
"effect" on any pod that does not tolerate the Taint.
properties:
effect:
description: Required. The effect of the taint on
pods that do not tolerate the taint. Valid effects
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Required. The taint key to be applied
to a node.
type: string
timeAdded:
description: TimeAdded represents the time at which
the taint was added. It is only written for NoExecute
taints.
format: date-time
type: string
value:
description: The taint value corresponding to the
taint key.
type: string
required:
- effect
- key
type: object
type: array
type: object
type: array
type: object
imageRepository:
type: string
Expand All @@ -128,6 +227,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 +238,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"
45 changes: 45 additions & 0 deletions pkg/apis/kosmos/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -42,7 +43,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 +97,31 @@ type ClusterTreeOptions struct {
// +kubebuilder:default=true
// +optional
Enable bool `json:"enable"`

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

type LeafModel struct {
// LeafNodeName defines leaf name
// If nil or empty, the leaf node name will generate by controller and fill in cluster link status
// +optional
LeafNodeName string `json:"leafNodeName,omitempty"`

// Labels that will be setting in the pretended Node labels
// +optional
Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"`

// Taints attached to the leaf pretended Node.
// If nil or empty, controller will set the default no-schedule taint
// +optional
Taints []corev1.Taint `json:"taints,omitempty"`

// LabelSelector is a filter to select member cluster nodes to pretend a leaf node in clusterTree by labels.
// If nil or 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 +131,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
83 changes: 82 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 f53c66a

Please sign in to comment.