Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade nodepool crd to v1beta2 #2266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions charts/yurt-manager/crds/apps.openyurt.io_nodepools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,195 @@ spec:
storage: true
subresources:
status: {}
- additionalPrinterColumns:
- description: The type of nodepool
jsonPath: .spec.type
name: Type
type: string
- description: The number of ready nodes in the pool
jsonPath: .status.readyNodeNum
name: ReadyNodes
type: integer
- jsonPath: .status.unreadyNodeNum
name: NotReadyNodes
type: integer
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1beta2
schema:
openAPIV3Schema:
description: NodePool is the Schema for the nodepools 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
spec:
description: NodePoolSpec defines the desired state of NodePool
properties:
annotations:
additionalProperties:
type: string
description: |-
If specified, the Annotations will be added to all nodes.
NOTE: existing labels with samy keys on the nodes will be overwritten.
type: object
hostNetwork:
description: |-
HostNetwork is used to specify that cni components(like flannel)
will not be installed on the nodes of this NodePool.
This means all pods on the nodes of this NodePool will use
HostNetwork and share network namespace with host machine.
type: boolean
interConnectivity:
description: |-
InterConnectivity represents all nodes in the NodePool can access with each other
through Layer 2 or Layer 3 network or not. If the field is true,
nodepool-level list/watch requests reuse can be applied for this nodepool.
otherwise, only node-level list/watch requests reuse can be applied for the nodepool.
This field cannot be changed after creation.
type: boolean
labels:
additionalProperties:
type: string
description: |-
If specified, the Labels will be added to all nodes.
NOTE: existing labels with samy keys on the nodes will be overwritten.
type: object
leaderElectionStrategy:
description: |-
LeaderElectionStrategy represents the policy how to elect a leader Yurthub in a nodepool.
random: select one ready node as leader at random.
mark: select one ready node as leader from nodes that are specified by labelselector.
More strategies will be supported according to user's new requirements.
type: string
leaderNodeLabelSelector:
additionalProperties:
type: string
description: |-
LeaderNodeLabelSelector is used only when LeaderElectionStrategy is mark. leader Yurhub will be
elected from nodes that filtered by this label selector.
type: object
poolScopeMetadata:
description: |-
PoolScopeMetadata is used for specifying resources which will be shared in the nodepool.
And it is supported to modify dynamically. and the default value is v1.Service and discovery.Endpointslice.
items:
description: |-
GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion
to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
properties:
group:
type: string
kind:
type: string
version:
type: string
required:
- group
- kind
- version
type: object
type: array
taints:
description: If specified, the Taints will be added to all nodes.
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:
description: The type of the NodePool
type: string
type: object
status:
description: NodePoolStatus defines the observed state of NodePool
properties:
conditions:
description: |-
Conditions represents the latest available observations of a NodePool's
current state that includes LeaderHubElection status.
items:
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status to another.
format: date-time
type: string
message:
description: A human readable message indicating details about the transition.
type: string
reason:
description: The reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of NodePool condition.
type: string
type: object
type: array
leaderEndpoints:
description: LeaderEndpoints is used for storing the address of Leader Yurthub.
items:
type: string
type: array
nodes:
description: The list of nodes' names in the pool
items:
type: string
type: array
readyNodeNum:
description: Total number of ready nodes in the pool.
format: int32
type: integer
unreadyNodeNum:
description: Total number of unready nodes in the pool.
format: int32
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}
conversion:
strategy: Webhook
webhook:
Expand Down
42 changes: 42 additions & 0 deletions charts/yurt-manager/templates/yurt-manager-auto-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,26 @@ webhooks:
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta2
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /mutate-apps-openyurt-io-v1beta2-nodepool
failurePolicy: Fail
name: m.v1beta2.nodepool.kb.io
rules:
- apiGroups:
- apps.openyurt.io
apiVersions:
- v1beta2
operations:
- CREATE
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -1710,6 +1730,28 @@ webhooks:
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta2
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /validate-apps-openyurt-io-v1beta2-nodepool
failurePolicy: Fail
name: v.v1beta2.nodepool.kb.io
rules:
- apiGroups:
- apps.openyurt.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
- DELETE
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down
26 changes: 26 additions & 0 deletions pkg/apis/addtoscheme_apps_v1beta2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
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 apis

import (
version "github.com/openyurtio/openyurt/pkg/apis/apps/v1beta2"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, version.SchemeBuilder.AddToScheme)
}
26 changes: 26 additions & 0 deletions pkg/apis/apps/v1beta2/default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2024 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 v1beta2

// SetDefaultsNodePool set default values for NodePool.
func SetDefaultsNodePool(obj *NodePool) {

Check warning on line 20 in pkg/apis/apps/v1beta2/default.go

View check run for this annotation

Codecov / codecov/patch

pkg/apis/apps/v1beta2/default.go#L20

Added line #L20 was not covered by tests
// example for set default value for NodePool
if obj.Annotations == nil {
obj.Annotations = make(map[string]string)

Check warning on line 23 in pkg/apis/apps/v1beta2/default.go

View check run for this annotation

Codecov / codecov/patch

pkg/apis/apps/v1beta2/default.go#L22-L23

Added lines #L22 - L23 were not covered by tests
}

}
17 changes: 17 additions & 0 deletions pkg/apis/apps/v1beta2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2024 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 v1beta2
44 changes: 44 additions & 0 deletions pkg/apis/apps/v1beta2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2024 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 v1beta2

// Package v1beta2 contains API Schema definitions for the apps v1beta2API group
// +kubebuilder:object:generate=true
// +groupName=apps.openyurt.io

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "apps.openyurt.io", Version: "v1beta2"}

SchemeGroupVersion = GroupVersion

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// Resource is required by pkg/client/listers/...
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()

Check warning on line 43 in pkg/apis/apps/v1beta2/groupversion_info.go

View check run for this annotation

Codecov / codecov/patch

pkg/apis/apps/v1beta2/groupversion_info.go#L42-L43

Added lines #L42 - L43 were not covered by tests
}
26 changes: 26 additions & 0 deletions pkg/apis/apps/v1beta2/nodepool_conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2024 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 v1beta2

/*
Implementing the hub method is pretty easy -- we just have to add an empty
method called `Hub()` to serve as a
[marker](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/conversion?tab=doc#Hub).
*/

// Hub marks this type as a conversion hub.
func (*NodePool) Hub() {}

Check warning on line 26 in pkg/apis/apps/v1beta2/nodepool_conversion.go

View check run for this annotation

Codecov / codecov/patch

pkg/apis/apps/v1beta2/nodepool_conversion.go#L26

Added line #L26 was not covered by tests
Loading
Loading