-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81d21b7
commit ff928df
Showing
17 changed files
with
1,651 additions
and
280 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
charts/yurt-manager/crds/apps.openyurt.io_nodebuckets.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,77 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.7.0 | ||
creationTimestamp: null | ||
name: nodebuckets.apps.openyurt.io | ||
spec: | ||
group: apps.openyurt.io | ||
names: | ||
categories: | ||
- all | ||
kind: NodeBucket | ||
listKind: NodeBucketList | ||
plural: nodebuckets | ||
shortNames: | ||
- nb | ||
singular: nodebucket | ||
scope: Cluster | ||
versions: | ||
- additionalPrinterColumns: | ||
- description: NumNodes represents the number of nodes in the NodeBucket. | ||
jsonPath: .numNodes | ||
name: NUM-NODES | ||
type: integer | ||
- description: CreationTimestamp is a timestamp representing the server time when | ||
this object was created. It is not guaranteed to be set in happens-before | ||
order across separate operations. Clients may not set this value. It is represented | ||
in RFC3339 form and is in UTC. | ||
jsonPath: .metadata.creationTimestamp | ||
name: AGE | ||
type: date | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: NodeBucket is the Schema for the samples API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
nodes: | ||
description: Nodes represents a subset nodes in the nodepool | ||
items: | ||
description: Node represents a specified node in the nodepool | ||
properties: | ||
name: | ||
description: Name is the name of node | ||
type: string | ||
type: object | ||
type: array | ||
numNodes: | ||
description: NumNodes represents the number of nodes in the nodebucket | ||
format: int32 | ||
type: integer | ||
required: | ||
- nodes | ||
- numNodes | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,70 @@ | ||
/* | ||
Copyright 2023 The OpenYurt Authors. | ||
Licensed under the Apache License, Version 2.0 (the License); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an AS IS BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package options | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/pflag" | ||
|
||
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodebucket/config" | ||
) | ||
|
||
type NodeBucketControllerOptions struct { | ||
*config.NodeBucketControllerConfiguration | ||
} | ||
|
||
func NewNodeBucketControllerOptions() *NodeBucketControllerOptions { | ||
return &NodeBucketControllerOptions{ | ||
&config.NodeBucketControllerConfiguration{ | ||
MaxNodesPerBucket: 100, | ||
}, | ||
} | ||
} | ||
|
||
// AddFlags adds flags related to nodebucket for yurt-manager to the specified FlagSet. | ||
func (n *NodeBucketControllerOptions) AddFlags(fs *pflag.FlagSet) { | ||
if n == nil { | ||
return | ||
} | ||
|
||
fs.Int32Var(&n.MaxNodesPerBucket, "max-nodes-per-bucket", n.MaxNodesPerBucket, "The maximum number of nodes that will be added to a NodeBucket. More nodes per bucket will result in less node buckets, but larger resources. Defaults to 100.") | ||
} | ||
|
||
// ApplyTo fills up nodebucket config with options. | ||
func (o *NodeBucketControllerOptions) ApplyTo(cfg *config.NodeBucketControllerConfiguration) error { | ||
if o == nil { | ||
return nil | ||
} | ||
|
||
cfg.MaxNodesPerBucket = o.MaxNodesPerBucket | ||
|
||
return nil | ||
} | ||
|
||
// Validate checks validation of NodeBucketControllerOptions. | ||
func (o *NodeBucketControllerOptions) Validate() []error { | ||
if o == nil { | ||
return nil | ||
} | ||
|
||
errs := []error{} | ||
if o.MaxNodesPerBucket <= 0 { | ||
errs = append(errs, fmt.Errorf("max-nodes-per-bucket(%d) is invalid, should greater than 0", o.MaxNodesPerBucket)) | ||
} | ||
return errs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,60 @@ | ||
/* | ||
Copyright 2023 The OpenYurt Authors. | ||
Licensed under the Apache License, Version 2.0 (the License); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an AS IS BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// Node represents a specified node in the nodepool | ||
type Node struct { | ||
// Name is the name of node | ||
Name string `json:"name,omitempty"` | ||
} | ||
|
||
// genclient | ||
// k8s:openapi-gen=true | ||
// kubebuilder:object:root=true | ||
// kubebuilder:subresource:status | ||
// kubebuilder:resource:scope=Cluster,path=nodebuckets,shortName=nb,categories=all | ||
// kubebuilder:printcolumn:name="NUM-NODES",type="integer",JSONPath=".numNodes",description="NumNodes represents the number of nodes in the NodeBucket." | ||
// kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC." | ||
|
||
// NodeBucket is the Schema for the samples API | ||
type NodeBucket struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// NumNodes represents the number of nodes in the nodebucket | ||
NumNodes int32 `json:"numNodes"` | ||
|
||
// Nodes represents a subset nodes in the nodepool | ||
Nodes []Node `json:"nodes"` | ||
} | ||
|
||
// kubebuilder:object:root=true | ||
|
||
// NodeBucketList contains a list of NodeBucket | ||
type NodeBucketList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NodeBucket `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NodeBucket{}, &NodeBucketList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.