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 all 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)
}
3 changes: 3 additions & 0 deletions cmd/kuscia/modules/metricexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type metricExporterModule struct {
metricURLs map[string]string
nodeExportPort string
ssExportPort string
ktExportPort string
metricExportPort string
podManager pod.Manager
}
Expand Down Expand Up @@ -63,12 +64,14 @@ func NewMetricExporter(i *ModuleRuntimeConfigs) (Module, error) {
rootDir: i.RootDir,
nodeExportPort: i.NodeExportPort,
ssExportPort: i.SsExportPort,
ktExportPort: i.KtExportPort,
metricExportPort: i.MetricExportPort,
podManager: podManager,
metricURLs: map[string]string{
"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
4 changes: 3 additions & 1 deletion cmd/kuscia/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ 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)
mm.Regist("scheduler", modules.NewScheduler, autonomy, master)
mm.Regist("transport", modules.NewTransport, autonomy, lite)

Expand All @@ -104,7 +105,8 @@ 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")
mm.SetDependencies("metricexporter", "agent", "envoy", "ssexporter", "ktexporter", "nodeexporter")
mm.SetDependencies("transport", "envoy")
mm.SetDependencies("k3s", "coredns")

Expand Down
12 changes: 9 additions & 3 deletions docs/tutorial/run_scql_on_kuscia_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,12 @@ curl -X POST http://127.0.0.1:80/intra/project/create \
```bash
curl -X POST http://127.0.0.1:80/intra/project/list \
--header "host: scql-broker-intra.alice.svc" \
--header "kuscia-source: alice"
--header "kuscia-source: alice" \
-d '{
"ids": [
"demo"
]
}'
```

4.邀请 bob 加入到 "demo" 项目中
Expand All @@ -309,7 +314,8 @@ curl -X POST http://127.0.0.1:80/intra/member/invite \
```bash
curl -X POST http://127.0.0.1:80/intra/invitation/list \
--header "host: scql-broker-intra.alice.svc" \
--header "kuscia-source: alice"
--header "kuscia-source: alice" \
-d '{}'
```

#### Bob 接受邀请
Expand Down Expand Up @@ -699,4 +705,4 @@ ls /home/kuscia/var/stdout/pods
# 查看应用容器的日志,示例如下:
cat /home/kuscia/var/stdout/pods/alice_xxxx_engine_xxxx/secretflow/0.log
cat /home/kuscia/var/stdout/pods/alice_xxxx_broker_xxxx/secretflow/0.log
```
```
31 changes: 26 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/moby/sys/mount v0.3.3
github.com/moby/sys/mountinfo v0.7.1
github.com/olekukonko/tablewriter v0.0.5
github.com/opencontainers/image-spec v1.1.0-rc5
github.com/opencontainers/image-spec v1.1.0
github.com/opencontainers/runtime-spec v1.1.1-0.20230823135140-4fec88fd00a4
github.com/opencontainers/selinux v1.11.0
github.com/patrickmn/go-cache v2.1.0+incompatible
Expand Down Expand Up @@ -90,11 +90,14 @@ require (
require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.11.7 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
Expand All @@ -109,9 +112,19 @@ require (
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/cilium/ebpf v0.11.0 // indirect
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/containerd v1.7.24 // indirect
github.com/containerd/containerd/api v1.7.19 // indirect
github.com/containerd/continuity v0.4.2 // indirect
github.com/containerd/errdefs v0.3.0 // indirect
github.com/containerd/fifo v1.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/containerd/ttrpc v1.2.2 // indirect
github.com/containerd/ttrpc v1.2.5 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
Expand All @@ -120,8 +133,10 @@ require (
github.com/distribution/reference v0.6.0 // indirect
github.com/dnstap/golang-dnstap v0.4.0 // indirect
github.com/docker/cli v27.1.1+incompatible // indirect
github.com/docker/docker v27.1.1+incompatible // indirect
github.com/docker/docker v27.3.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
Expand Down Expand Up @@ -184,7 +199,12 @@ require (
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
github.com/moby/sys/user v0.3.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down Expand Up @@ -221,11 +241,12 @@ require (
github.com/xlab/treeprint v1.1.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/v2 v2.305.6 // indirect
go.etcd.io/etcd/client/v3 v3.5.6 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
Expand Down
Loading