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

add pool service controller. #2010

Merged
merged 1 commit into from
Apr 12, 2024
Merged
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
46 changes: 2 additions & 44 deletions charts/yurt-manager/templates/yurt-manager-auto-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ rules:
- patch
- update
- apiGroups:
- net.openyurt.io
- network.openyurt.io
resources:
- poolservices
verbs:
Expand All @@ -512,7 +512,7 @@ rules:
- update
- watch
- apiGroups:
- net.openyurt.io
- network.openyurt.io
resources:
- poolservices/status
verbs:
Expand Down Expand Up @@ -756,27 +756,6 @@ webhooks:
resources:
- yurtstaticsets
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /mutate-net-openyurt-io-poolservice
failurePolicy: Fail
name: mutate.net.v1alpha1.poolservice.openyurt.io
rules:
- apiGroups:
- net.openyurt.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- poolservices
sideEffects: None
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
Expand Down Expand Up @@ -951,24 +930,3 @@ webhooks:
resources:
- yurtstaticsets
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: yurt-manager-webhook-service
namespace: {{ .Release.Namespace }}
path: /validate-net-openyurt-io-poolservice
failurePolicy: Fail
name: validate.net.v1alpha1.poolservice.openyurt.io
rules:
- apiGroups:
- net.openyurt.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- poolservices
sideEffects: None
64 changes: 64 additions & 0 deletions cmd/yurt-manager/app/options/loadbalancersetcontroller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
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 (
"github.com/spf13/pflag"

"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/loadbalancerset/loadbalancerset/config"
)

type LoadBalancerSetControllerOptions struct {
*config.LoadBalancerSetControllerConfiguration
}

func NewLoadBalancerSetControllerOptions() *LoadBalancerSetControllerOptions {
return &LoadBalancerSetControllerOptions{
&config.LoadBalancerSetControllerConfiguration{
ConcurrentLoadBalancerSetWorkers: 3,
},
}
}

// AddFlags adds flags related to poolservice for yurt-manager to the specified FlagSet.
func (n *LoadBalancerSetControllerOptions) AddFlags(fs *pflag.FlagSet) {
if n == nil {
return
}

fs.Int32Var(&n.ConcurrentLoadBalancerSetWorkers, "concurrent-load-balancer-set-workers", n.ConcurrentLoadBalancerSetWorkers, "The number of load-balancer-set service objects that are allowed to reconcile concurrently. Larger number = more responsive load-balancer-set services, but more CPU (and network) load")
}

// ApplyTo fills up poolservice config with options.
func (o *LoadBalancerSetControllerOptions) ApplyTo(cfg *config.LoadBalancerSetControllerConfiguration) error {
if o == nil {
return nil
}

cfg.ConcurrentLoadBalancerSetWorkers = o.ConcurrentLoadBalancerSetWorkers

return nil
}

// Validate checks validation of LoadBalancerSetControllerOptions.
func (o *LoadBalancerSetControllerOptions) Validate() []error {
if o == nil {
return nil
}
errs := []error{}
return errs
}
7 changes: 7 additions & 0 deletions cmd/yurt-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type YurtManagerOptions struct {
YurtAppOverriderController *YurtAppOverriderControllerOptions
NodeLifeCycleController *NodeLifecycleControllerOptions
NodeBucketController *NodeBucketControllerOptions
LoadBalancerSetController *LoadBalancerSetControllerOptions
}

// NewYurtManagerOptions creates a new YurtManagerOptions with a default config.
Expand All @@ -59,6 +60,7 @@ func NewYurtManagerOptions() (*YurtManagerOptions, error) {
YurtAppOverriderController: NewYurtAppOverriderControllerOptions(),
NodeLifeCycleController: NewNodeLifecycleControllerOptions(),
NodeBucketController: NewNodeBucketControllerOptions(),
LoadBalancerSetController: NewLoadBalancerSetControllerOptions(),
}

return &s, nil
Expand All @@ -79,6 +81,7 @@ func (y *YurtManagerOptions) Flags(allControllers, disabledByDefaultControllers
y.YurtAppOverriderController.AddFlags(fss.FlagSet("yurtappoverrider controller"))
y.NodeLifeCycleController.AddFlags(fss.FlagSet("nodelifecycle controller"))
y.NodeBucketController.AddFlags(fss.FlagSet("nodebucket controller"))
y.LoadBalancerSetController.AddFlags(fss.FlagSet("loadbalancerset controller"))
return fss
}

Expand All @@ -98,6 +101,7 @@ func (y *YurtManagerOptions) Validate(allControllers []string, controllerAliases
errs = append(errs, y.YurtAppOverriderController.Validate()...)
errs = append(errs, y.NodeLifeCycleController.Validate()...)
errs = append(errs, y.NodeBucketController.Validate()...)
errs = append(errs, y.LoadBalancerSetController.Validate()...)
return utilerrors.NewAggregate(errs)
}

Expand Down Expand Up @@ -142,6 +146,9 @@ func (y *YurtManagerOptions) ApplyTo(c *config.Config, controllerAliases map[str
if err := y.NodeBucketController.ApplyTo(&c.ComponentConfig.NodeBucketController); err != nil {
return err
}
if err := y.LoadBalancerSetController.ApplyTo(&c.ComponentConfig.LoadBalancerSetController); err != nil {
return err
}
return nil
}

Expand Down
60 changes: 0 additions & 60 deletions cmd/yurt-manager/app/options/poolservicecontroller.go

This file was deleted.

3 changes: 2 additions & 1 deletion cmd/yurt-manager/names/controller_names.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
GatewayDNSController = "gateway-dns-controller"
NodeLifeCycleController = "node-life-cycle-controller"
NodeBucketController = "node-bucket-controller"
PoolServiceController = "pool-service-controller"
LoadBalancerSetController = "load-balancer-set-controller"
)

func YurtManagerControllerAliases() map[string]string {
Expand All @@ -61,5 +61,6 @@ func YurtManagerControllerAliases() map[string]string {
"gatewaydns": GatewayDNSController,
"nodelifecycle": NodeLifeCycleController,
"nodebucket": NodeBucketController,
"loadbalancerset": LoadBalancerSetController,
}
}
4 changes: 2 additions & 2 deletions pkg/apis/network/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.

package v1alpha1

// Package v1alpha1 contains API Schema definitions for the net v1alpha1API group
// Package v1alpha1 contains API Schema definitions for the network v1alpha1API group
// +kubebuilder:object:generate=true
// +groupName=net.openyurt.io
// +groupName=network.openyurt.io

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/network/v1alpha1/poolservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type PoolServiceSpec struct {
// PoolServiceStatus defines the observed state of PoolService
type PoolServiceStatus struct {
// LoadBalancer contains the current status of the load-balancer in the current nodepool
LoadBalancer *v1.LoadBalancerStatus `json:"loadBalancer,omitempty"`
LoadBalancer v1.LoadBalancerStatus `json:"loadBalancer,omitempty"`

// Current poolService state
Conditions []metav1.Condition `json:"conditions,omitempty"`
Expand Down
13 changes: 4 additions & 9 deletions pkg/apis/network/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 3 additions & 3 deletions pkg/yurtmanager/controller/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (

csrapproverconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/csrapprover/config"
daemonpodupdaterconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/daemonpodupdater/config"
loadbalancersetconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/loadbalancerset/loadbalancerset/config"
nodebucketconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodebucket/config"
nodepoolconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodepool/config"
platformadminconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/platformadmin/config"
poolserviceconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/poolservice/config"
gatewaypickupconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewaypickup/config"
yurtappdaemonconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/yurtappdaemon/config"
yurtappoverriderconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/yurtappoverrider/config"
Expand Down Expand Up @@ -79,8 +79,8 @@ type YurtManagerConfiguration struct {
// NodeBucketController holds configuration for NodeBucketController related features.
NodeBucketController nodebucketconfig.NodeBucketControllerConfiguration

// PoolServiceController holds configuration for PoolServiceController related features.
PoolServiceController poolserviceconfig.PoolServiceControllerConfiguration
// LoadBalancerSetController holds configuration for LoadBalancerSetController related features.
LoadBalancerSetController loadbalancersetconfig.LoadBalancerSetControllerConfiguration
}

type GenericConfiguration struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/yurtmanager/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/openyurtio/openyurt/cmd/yurt-manager/names"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/csrapprover"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/daemonpodupdater"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/loadbalancerset/loadbalancerset"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodebucket"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodelifecycle"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodepool"
Expand Down Expand Up @@ -97,6 +98,7 @@ func NewControllerInitializers() map[string]InitFunc {
register(names.GatewayPublicServiceController, gatewaypublicservice.Add)
register(names.NodeLifeCycleController, nodelifecycle.Add)
register(names.NodeBucketController, nodebucket.Add)
register(names.LoadBalancerSetController, loadbalancerset.Add)

return controllers
}
Expand Down
Loading
Loading