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

[OSCP]KusciaTask 系统资源指标采集、暴露及统一导出 #454

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c229e97
feat:add kuscia task Related observational indicators
renji555 Oct 26, 2024
0235d82
Merge branch 'main' of https://github.com/renji555/kuscia
renji555 Nov 7, 2024
991d190
Update config_test.go
renji555 Nov 7, 2024
5fa1e34
Update export.go
renji555 Nov 7, 2024
7095e62
Standardized config.go
renji555 Nov 7, 2024
3ae5946
Standardized the format
renji555 Nov 7, 2024
42ac790
check something
renji555 Nov 7, 2024
aa46d7a
delete something
renji555 Nov 7, 2024
cfee428
merge export.go
renji555 Nov 7, 2024
f59717c
try merge ssmetrics and ktmetrics
renji555 Nov 7, 2024
0790224
restore
renji555 Nov 7, 2024
2fc39cb
merge domain
renji555 Nov 7, 2024
3bb9e74
改名
renji555 Nov 7, 2024
c3dedad
finish
renji555 Nov 7, 2024
5695343
check
renji555 Nov 8, 2024
447bf52
os instead ioutil
renji555 Nov 8, 2024
cd3cb01
Update ktmetrics.go
renji555 Nov 8, 2024
d034fdc
check something
renji555 Nov 8, 2024
d578958
split ktmetrics
renji555 Nov 8, 2024
13f4ed8
remerge ktmetrics(over)
renji555 Nov 8, 2024
b1ced4a
Merge branch 'main' of https://github.com/renji555/kuscia
renji555 Nov 12, 2024
06d22a6
Update start.go
renji555 Nov 12, 2024
ba09974
change
renji555 Nov 13, 2024
5d65341
resolve repeat
renji555 Nov 15, 2024
94bc7e2
check error
renji555 Nov 15, 2024
f7f4f61
update
renji555 Nov 30, 2024
1fabd33
check
renji555 Nov 30, 2024
515db0b
others‘ change
renji555 Nov 30, 2024
046e6df
yes
renji555 Nov 30, 2024
6517ed9
still use 404
renji555 Nov 30, 2024
1a01a86
change GetTaskIDToContainerID
renji555 Dec 1, 2024
835837a
框架over
renji555 Dec 1, 2024
d8dada4
get CPU&memory
renji555 Dec 2, 2024
f30c4ba
kt部分使用说明
renji555 Dec 2, 2024
a4a2c36
gain containerPID through containerd
renji555 Dec 2, 2024
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
56 changes: 56 additions & 0 deletions cmd/kuscia/modules/ktexporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2023 Ant Group Co., Ltd.
//
// 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 modules

import (
"context"
"fmt"
"time"

pkgcom "github.com/secretflow/kuscia/pkg/common"
"github.com/secretflow/kuscia/pkg/ktexporter"
"github.com/secretflow/kuscia/pkg/utils/readyz"
)

type ktExporterModule struct {
renji555 marked this conversation as resolved.
Show resolved Hide resolved
moduleRuntimeBase
runMode pkgcom.RunModeType
domainID string
rootDir string
metricUpdatePeriod uint
ktExportPort string
}

func NewKtExporter(i *ModuleRuntimeConfigs) (Module, error) {
readyURI := fmt.Sprintf("http://127.0.0.1:%s", i.KtExportPort)
return &ktExporterModule{
moduleRuntimeBase: moduleRuntimeBase{
name: "ktexporter",
readyTimeout: 60 * time.Second,
rdz: readyz.NewHTTPReadyZ(readyURI, 404, func(_ []byte) error {
renji555 marked this conversation as resolved.
Show resolved Hide resolved
return nil
}),
},
runMode: i.RunMode,
domainID: i.DomainID,
rootDir: i.RootDir,
metricUpdatePeriod: i.MetricUpdatePeriod,
ktExportPort: i.KtExportPort,
}, nil
}

func (exporter *ktExporterModule) Run(ctx context.Context) error {
return ktexporter.KtExporter(ctx, exporter.runMode, exporter.domainID, exporter.metricUpdatePeriod, exporter.ktExportPort)
}
1 change: 1 addition & 0 deletions cmd/kuscia/modules/metricexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func NewMetricExporter(i *ModuleRuntimeConfigs) (Module, error) {
"node-exporter": "http://localhost:" + i.NodeExportPort + "/metrics",
"envoy": envoyexporter.GetEnvoyMetricURL(),
"ss": "http://localhost:" + i.SsExportPort + "/ssmetrics",
"kt": "http://localhost:" + i.KtExportPort + "/ktmetrics",
},
}
return exporter, nil
Expand Down
2 changes: 2 additions & 0 deletions cmd/kuscia/modules/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ModuleRuntimeConfigs struct {
TransportPort int
InterConnSchedulerPort int
SsExportPort string
KtExportPort string
NodeExportPort string
MetricExportPort string
KusciaKubeConfig string
Expand Down Expand Up @@ -190,6 +191,7 @@ func NewModuleRuntimeConfigs(ctx context.Context, kusciaConf confloader.KusciaCo
}

// init exporter ports
dependencies.KtExportPort = "9093"
dependencies.SsExportPort = "9092"
dependencies.NodeExportPort = "9100"
dependencies.MetricExportPort = "9091"
Expand Down
16 changes: 15 additions & 1 deletion cmd/kuscia/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ func Start(ctx context.Context, configFile string) error {
mm.Regist("metricexporter", modules.NewMetricExporter, autonomy, lite, master)
mm.Regist("nodeexporter", modules.NewNodeExporter, autonomy, lite, master)
mm.Regist("ssexporter", modules.NewSsExporter, autonomy, lite, master)
mm.Regist("ktexporter", modules.NewKtExporter, autonomy, lite, master)
if err := mm.Regist("ktexporter", modules.NewKtExporter, autonomy, lite, master); err != nil {
// 处理错误
renji555 marked this conversation as resolved.
Show resolved Hide resolved
nlog.Fatal(err) // 例如记录错误并终止程序,或者进行其他适当的错误处理
}
mm.Regist("scheduler", modules.NewScheduler, autonomy, master)
mm.Regist("transport", modules.NewTransport, autonomy, lite)

Expand All @@ -104,7 +109,16 @@ func Start(ctx context.Context, configFile string) error {
mm.SetDependencies("kusciaapi", "k3s", "config", "domainroute")
mm.SetDependencies("scheduler", "k3s")
mm.SetDependencies("ssexporter", "envoy")
mm.SetDependencies("metricexporter", "agent", "envoy", "ssexporter", "nodeexporter")
mm.SetDependencies("ktexporter", "envoy")
if err := mm.SetDependencies("ktexporter", "envoy"); err != nil {
renji555 marked this conversation as resolved.
Show resolved Hide resolved
// 处理错误
nlog.Fatal(err)
}
mm.SetDependencies("metricexporter", "agent", "envoy", "ssexporter", "ktexporter", "nodeexporter")
if err := mm.SetDependencies("metricexporter", "agent", "envoy", "ssexporter", "ktexporter", "nodeexporter"); err != nil {
// 处理错误
nlog.Fatal(err)
}
mm.SetDependencies("transport", "envoy")
mm.SetDependencies("k3s", "coredns")

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ require (
)

replace (
github.com/secretflow/kuscia/pkg/utils/calculate => ./pkg/utils/calculate
github.com/agiledragon/gomonkey => github.com/agiledragon/gomonkey/v2 v2.2.0
k8s.io/api => k8s.io/api v0.26.11
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.11
Expand Down
Loading