github.com/kubewharf/katalyst-core@v0.5.3/pkg/config/agent/metaserver/agent.go (about) 1 /* 2 Copyright 2022 The Katalyst Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package metaserver 18 19 import ( 20 "time" 21 22 "golang.org/x/time/rate" 23 ) 24 25 const ( 26 MetricProvisionerMalachite = "malachite" 27 MetricProvisionerCgroup = "cgroup" 28 MetricProvisionerKubelet = "kubelet" 29 MetricProvisionerRodan = "rodan" 30 ) 31 32 type MetricConfiguration struct { 33 MetricInsurancePeriod time.Duration 34 MetricProvisions []string 35 36 DefaultInterval time.Duration 37 ProvisionerIntervals map[string]time.Duration 38 39 *MalachiteMetricConfiguration 40 *CgroupMetricConfiguration 41 *KubeletMetricConfiguration 42 *RodanMetricConfiguration 43 } 44 45 type MalachiteMetricConfiguration struct{} 46 47 type CgroupMetricConfiguration struct{} 48 49 type KubeletMetricConfiguration struct{} 50 51 type RodanMetricConfiguration struct { 52 RodanServerPort int 53 } 54 55 type PodConfiguration struct { 56 KubeletPodCacheSyncPeriod time.Duration 57 KubeletPodCacheSyncMaxRate rate.Limit 58 KubeletPodCacheSyncBurstBulk int 59 60 RuntimePodCacheSyncPeriod time.Duration 61 } 62 63 type NodeConfiguration struct{} 64 65 type CNRConfiguration struct { 66 CNRCacheTTL time.Duration 67 } 68 69 type CNCConfiguration struct { 70 CustomNodeConfigCacheTTL time.Duration 71 } 72 73 type AgentConfiguration struct { 74 *MetricConfiguration 75 *PodConfiguration 76 *NodeConfiguration 77 *CNRConfiguration 78 *CNCConfiguration 79 80 EnableMetricsFetcher bool 81 EnableCNCFetcher bool 82 } 83 84 func NewAgentConfiguration() *AgentConfiguration { 85 return &AgentConfiguration{ 86 MetricConfiguration: &MetricConfiguration{ 87 ProvisionerIntervals: make(map[string]time.Duration), 88 MalachiteMetricConfiguration: &MalachiteMetricConfiguration{}, 89 CgroupMetricConfiguration: &CgroupMetricConfiguration{}, 90 KubeletMetricConfiguration: &KubeletMetricConfiguration{}, 91 RodanMetricConfiguration: &RodanMetricConfiguration{}, 92 }, 93 PodConfiguration: &PodConfiguration{}, 94 NodeConfiguration: &NodeConfiguration{}, 95 CNRConfiguration: &CNRConfiguration{}, 96 CNCConfiguration: &CNCConfiguration{}, 97 } 98 }