Skip to content

Commit

Permalink
refine implementation for metaserver configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
waynepeking348 committed Feb 20, 2024
1 parent b1c5c1b commit 4034a49
Show file tree
Hide file tree
Showing 26 changed files with 235 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package global
package metaserver

import (
"time"

"golang.org/x/time/rate"
cliflag "k8s.io/component-base/cli/flag"

"github.com/kubewharf/katalyst-core/pkg/config/agent/global"
"github.com/kubewharf/katalyst-core/pkg/config/agent/metaserver"
)

const (
Expand Down Expand Up @@ -172,7 +172,7 @@ func (o *MetaServerOptions) AddFlags(fss *cliflag.NamedFlagSets) {
}

// ApplyTo fills up config with options
func (o *MetaServerOptions) ApplyTo(c *global.MetaServerConfiguration) error {
func (o *MetaServerOptions) ApplyTo(c *metaserver.MetaServerConfiguration) error {
c.CNRCacheTTL = o.CNRCacheTTL
c.CustomNodeConfigCacheTTL = o.CustomNodeConfigCacheTTL
c.ServiceProfileCacheTTL = o.ServiceProfileCacheTTL
Expand All @@ -181,9 +181,9 @@ func (o *MetaServerOptions) ApplyTo(c *global.MetaServerConfiguration) error {
c.ConfigSkipFailedInitialization = o.ConfigSkipFailedInitialization
c.ConfigCheckpointGraceTime = o.ConfigCheckpointGraceTime
c.KubeletReadOnlyPort = o.KubeletReadOnlyPort
c.EnableKubeletSecurePort = o.EnableKubeletSecurePort
c.KubeletSecurePortEnabled = o.EnableKubeletSecurePort
c.KubeletSecurePort = o.KubeletSecurePort
c.RemoteRuntimeEndpoint = o.RemoteRuntimeEndpoint
c.RuntimeEndpoint = o.RemoteRuntimeEndpoint
c.KubeletPodCacheSyncPeriod = o.KubeletPodCacheSyncPeriod
c.RuntimePodCacheSyncPeriod = o.RuntimePodCacheSyncPeriod
c.KubeletPodCacheSyncMaxRate = rate.Limit(o.KubeletPodCacheSyncMaxRate)
Expand Down
5 changes: 3 additions & 2 deletions cmd/katalyst-agent/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package options

import (
"github.com/kubewharf/katalyst-core/cmd/katalyst-agent/app/options/metaserver"
"k8s.io/apimachinery/pkg/util/errors"
cliflag "k8s.io/component-base/cli/flag"

Expand All @@ -40,7 +41,7 @@ type Options struct {
// those are options used by all the katalyst agents
*global.BaseOptions
*global.PluginManagerOptions
*global.MetaServerOptions
*metaserver.MetaServerOptions
*global.QRMAdvisorOptions

// the below are options used by all each individual katalyst module/plugin
Expand All @@ -65,7 +66,7 @@ func NewOptions() *Options {
GenericOptions: options.NewGenericOptions(),
DynamicOptions: dynamic.NewDynamicOptions(),
BaseOptions: global.NewBaseOptions(),
MetaServerOptions: global.NewMetaServerOptions(),
MetaServerOptions: metaserver.NewMetaServerOptions(),
PluginManagerOptions: global.NewPluginManagerOptions(),
QRMAdvisorOptions: global.NewQRMAdvisorOptions(),

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/evictionmanager/podkiller/killer.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ type ContainerKiller struct {
}

func NewContainerKiller(conf *config.Configuration, _ kubernetes.Interface, recorder events.EventRecorder, emitter metrics.MetricEmitter) (Killer, error) {
remoteRuntimeService, err := remote.NewRemoteRuntimeService(conf.RemoteRuntimeEndpoint, 2*time.Minute)
remoteRuntimeService, err := remote.NewRemoteRuntimeService(conf.RuntimeEndpoint, 2*time.Minute)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/resourcemanager/fetcher/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package fetcher

import (
"context"
"github.com/kubewharf/katalyst-core/pkg/config/agent/metaserver"
"io/ioutil"
"os"
"testing"
Expand All @@ -38,7 +39,6 @@ import (
"github.com/kubewharf/katalyst-core/pkg/agent/resourcemanager/reporter"
katalystconfig "github.com/kubewharf/katalyst-core/pkg/config"
"github.com/kubewharf/katalyst-core/pkg/config/agent"
"github.com/kubewharf/katalyst-core/pkg/config/agent/global"
reporterconfig "github.com/kubewharf/katalyst-core/pkg/config/agent/reporter"
"github.com/kubewharf/katalyst-core/pkg/metrics"
"github.com/kubewharf/katalyst-core/pkg/util/general"
Expand Down Expand Up @@ -71,7 +71,7 @@ func generateTestConfiguration(dir string) *katalystconfig.Configuration {
return &katalystconfig.Configuration{
AgentConfiguration: &agent.AgentConfiguration{
GenericAgentConfiguration: &agent.GenericAgentConfiguration{
MetaServerConfiguration: &global.MetaServerConfiguration{CheckpointManagerDir: dir},
MetaServerConfiguration: &metaserver.MetaServerConfiguration{CheckpointManagerDir: dir},
GenericReporterConfiguration: &reporterconfig.GenericReporterConfiguration{
CollectInterval: 5 * time.Second,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import (
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/metric"
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/node"
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/pod"
dynamicconfig "github.com/kubewharf/katalyst-core/pkg/metaserver/config"
dynamicconfig "github.com/kubewharf/katalyst-core/pkg/metaserver/kcc"
"github.com/kubewharf/katalyst-core/pkg/metrics"
metricspool "github.com/kubewharf/katalyst-core/pkg/metrics/metrics-pool"
metricutil "github.com/kubewharf/katalyst-core/pkg/util/metric"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent"
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/cnr"
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/node"
dynamicconfig "github.com/kubewharf/katalyst-core/pkg/metaserver/config"
dynamicconfig "github.com/kubewharf/katalyst-core/pkg/metaserver/kcc"
"github.com/kubewharf/katalyst-core/pkg/metrics"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/metric"
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/node"
"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/pod"
dynamicconfig "github.com/kubewharf/katalyst-core/pkg/metaserver/config"
dynamicconfig "github.com/kubewharf/katalyst-core/pkg/metaserver/kcc"
"github.com/kubewharf/katalyst-core/pkg/metrics"
metricspool "github.com/kubewharf/katalyst-core/pkg/metrics/metrics-pool"
metricutil "github.com/kubewharf/katalyst-core/pkg/util/metric"
Expand Down
5 changes: 3 additions & 2 deletions pkg/config/agent/agent_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic"
"github.com/kubewharf/katalyst-core/pkg/config/agent/eviction"
"github.com/kubewharf/katalyst-core/pkg/config/agent/global"
"github.com/kubewharf/katalyst-core/pkg/config/agent/metaserver"
"github.com/kubewharf/katalyst-core/pkg/config/agent/orm"
"github.com/kubewharf/katalyst-core/pkg/config/agent/qrm"
"github.com/kubewharf/katalyst-core/pkg/config/agent/reporter"
Expand Down Expand Up @@ -48,7 +49,7 @@ type GenericAgentConfiguration struct {
// be shared by all agent components.
*global.BaseConfiguration
*global.PluginManagerConfiguration
*global.MetaServerConfiguration
*metaserver.MetaServerConfiguration
*global.QRMAdvisorConfiguration

*eviction.GenericEvictionConfiguration
Expand All @@ -69,7 +70,7 @@ func NewGenericAgentConfiguration() *GenericAgentConfiguration {
return &GenericAgentConfiguration{
BaseConfiguration: global.NewBaseConfiguration(),
PluginManagerConfiguration: global.NewPluginManagerConfiguration(),
MetaServerConfiguration: global.NewMetaServerConfiguration(),
MetaServerConfiguration: metaserver.NewMetaServerConfiguration(),
QRMAdvisorConfiguration: global.NewQRMAdvisorConfiguration(),
GenericEvictionConfiguration: eviction.NewGenericEvictionConfiguration(),
GenericReporterConfiguration: reporter.NewGenericReporterConfiguration(),
Expand Down
58 changes: 0 additions & 58 deletions pkg/config/agent/global/metaserver.go

This file was deleted.

84 changes: 84 additions & 0 deletions pkg/config/agent/metaserver/agent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
Copyright 2022 The Katalyst 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 metaserver

import (
"time"

"golang.org/x/time/rate"
)

type MetricConfiguration struct {
MetricInsurancePeriod time.Duration
}

type KubeletConfiguration struct {
KubeletReadOnlyPort int
KubeletSecurePort int
KubeletSecurePortEnabled bool

KubeletConfigEndpoint string
KubeletPodsEndpoint string
KubeletSummaryEndpoint string

APIAuthTokenFile string
}

type RuntimeConfiguration struct {
RuntimeEndpoint string
}

type PodConfiguration struct {
KubeletPodCacheSyncPeriod time.Duration
KubeletPodCacheSyncMaxRate rate.Limit
KubeletPodCacheSyncBurstBulk int

RuntimePodCacheSyncPeriod time.Duration
}

type NodeConfiguration struct {
}

type CNRConfiguration struct {
CNRCacheTTL time.Duration
}

type CNCConfiguration struct {
CustomNodeConfigCacheTTL time.Duration
}

type AgentConfiguration struct {
*MetricConfiguration
*KubeletConfiguration
*RuntimeConfiguration
*PodConfiguration
*NodeConfiguration
*CNRConfiguration
*CNCConfiguration
}

func NewAgentConfiguration() *AgentConfiguration {
return &AgentConfiguration{
MetricConfiguration: &MetricConfiguration{},
KubeletConfiguration: &KubeletConfiguration{},
RuntimeConfiguration: &RuntimeConfiguration{},
PodConfiguration: &PodConfiguration{},
NodeConfiguration: &NodeConfiguration{},
CNRConfiguration: &CNRConfiguration{},
CNCConfiguration: &CNCConfiguration{},
}
}
23 changes: 23 additions & 0 deletions pkg/config/agent/metaserver/external.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2022 The Katalyst 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 metaserver

type ExternalConfiguration struct{}

func NewExternalConfiguration() *ExternalConfiguration {
return &ExternalConfiguration{}
}
30 changes: 30 additions & 0 deletions pkg/config/agent/metaserver/kcc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2022 The Katalyst 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 metaserver

import "time"

type KCCConfiguration struct {
ConfigCacheTTL time.Duration
ConfigCheckpointGraceTime time.Duration
ConfigSkipFailedInitialization bool
ConfigDisableDynamic bool
}

func NewKCCConfiguration() *KCCConfiguration {
return &KCCConfiguration{}
}
38 changes: 38 additions & 0 deletions pkg/config/agent/metaserver/metaserver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright 2022 The Katalyst 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 metaserver

type MetaServerConfiguration struct {
*KCCConfiguration
*SPDConfiguration
*ExternalConfiguration
*AgentConfiguration

EnableMetricsFetcher bool
EnableCNCFetcher bool

CheckpointManagerDir string
}

func NewMetaServerConfiguration() *MetaServerConfiguration {
return &MetaServerConfiguration{
KCCConfiguration: NewKCCConfiguration(),
SPDConfiguration: NewSPDConfiguration(),
ExternalConfiguration: NewExternalConfiguration(),
AgentConfiguration: NewAgentConfiguration(),
}
}
Loading

0 comments on commit 4034a49

Please sign in to comment.