From 175f1068befca8912093b9f7a671aa178c8e3699 Mon Sep 17 00:00:00 2001 From: szy0127 Date: Mon, 29 May 2023 11:12:55 +0800 Subject: [PATCH] feat: add capacity for kubelet --- cmd/kubelet.go | 2 ++ config/kubelet-config.yaml | 4 +++- pkg/kubelet/kubelet.go | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/kubelet.go b/cmd/kubelet.go index f962b27..1cc2d56 100644 --- a/cmd/kubelet.go +++ b/cmd/kubelet.go @@ -31,6 +31,8 @@ var KubeletConfig = kubelet.Config{ IP: "192.168.1.14", Labels: map[string]string{}, ListenAddr: "localhost:10250", + CPU: "2", + Memory: "3Gi", } func initConfig() { diff --git a/config/kubelet-config.yaml b/config/kubelet-config.yaml index 3ca21a3..b98d30d 100644 --- a/config/kubelet-config.yaml +++ b/config/kubelet-config.yaml @@ -8,4 +8,6 @@ FlannelSubnet : 10.2.9.1/24 IP : 192.168.1.14 Labels : - resource : gpu -ListenAddr : 192.168.1.14:10250 \ No newline at end of file +ListenAddr : 192.168.1.14:10250 +CPU: "2" +Memory: "3Gi" diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index d2a7510..83b0003 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -20,6 +20,8 @@ type Kubelet struct { IP string //host ip Labels map[string]string // for nodeSelector ListenAddr string //MetricsServer listen for auto-scaling + CPU string + Memory string Server *metricsserver.MetricsServer } @@ -30,6 +32,8 @@ func NewKubelet(config Config) *Kubelet { IP: config.IP, Labels: config.Labels, ListenAddr: config.ListenAddr, + CPU: config.CPU, + Memory: config.Memory, Server: metricsserver.NewMetricsServer(), } } @@ -48,6 +52,10 @@ func (kl *Kubelet) register() { PodCIDR: kl.FlannelSubnet, }, Status: apiobject.NodeStatus{ + Capability:map[string]string{ + "cpu":kl.CPU, + "memory":kl.Memory, + } Addresses: []apiobject.Address{ { Type: "InternalIP",