From 3f2f9aca56db56f86074c4026435b386e042cb5a Mon Sep 17 00:00:00 2001 From: ffforest Date: Thu, 21 Mar 2024 10:40:43 +0800 Subject: [PATCH] feat: add resource patching in operator mode --- models/generators/monitoring/monitoring.go | 12 ++++++++++++ models/schema/v1/app_configuration.k | 4 ---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/models/generators/monitoring/monitoring.go b/models/generators/monitoring/monitoring.go index edaa6f0..ad607d4 100644 --- a/models/generators/monitoring/monitoring.go +++ b/models/generators/monitoring/monitoring.go @@ -45,8 +45,14 @@ func (g *MonitoringModule) Generate(_ context.Context, request *module.Generator if err != nil { return nil, err } + patcher := &v1.Patcher{ + Labels: map[string]string{ + "kusion_monitoring_appname": request.App, + }, + } return &module.GeneratorResponse{ Resources: []v1.Resource{*resource}, + Patchers: []v1.Patcher{*patcher}, }, nil } else if g.MonitorType == PodMonitorType { // Create PodMonitor if MonitorType is Pod @@ -59,8 +65,14 @@ func (g *MonitoringModule) Generate(_ context.Context, request *module.Generator if err != nil { return nil, err } + patcher := &v1.Patcher{ + Labels: map[string]string{ + "kusion_monitoring_appname": request.App, + }, + } return &module.GeneratorResponse{ Resources: []v1.Resource{*resource}, + Patchers: []v1.Patcher{*patcher}, }, nil } else { return nil, fmt.Errorf("MonitorType should either be service or pod %s", g.MonitorType) diff --git a/models/schema/v1/app_configuration.k b/models/schema/v1/app_configuration.k index 388aa28..81243b8 100644 --- a/models/schema/v1/app_configuration.k +++ b/models/schema/v1/app_configuration.k @@ -1,8 +1,4 @@ import models.schema.v1.workload as wl -import models.schema.v1.trait as t -import models.schema.v1.monitoring as m -import models.schema.v1.accessories.mysql -import models.schema.v1.accessories.postgres schema AppConfiguration: """ AppConfiguration is a developer-centric definition that describes how to run an Application.