diff --git a/api/swagger/docs.go b/api/swagger/docs.go index 68d13e11..89f1284e 100644 --- a/api/swagger/docs.go +++ b/api/swagger/docs.go @@ -12226,7 +12226,8 @@ const docTemplate = `{ "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.Match" }, "matchYaml": { - "type": "string" + "type": "string", + "example": "namespaces:\r\n- testns1" }, "parameters": { "type": "string", diff --git a/api/swagger/swagger.json b/api/swagger/swagger.json index 9fa4a0f9..751a13e4 100644 --- a/api/swagger/swagger.json +++ b/api/swagger/swagger.json @@ -12220,7 +12220,8 @@ "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.Match" }, "matchYaml": { - "type": "string" + "type": "string", + "example": "namespaces:\r\n- testns1" }, "parameters": { "type": "string", diff --git a/api/swagger/swagger.yaml b/api/swagger/swagger.yaml index 8656e906..d5ae8da5 100644 --- a/api/swagger/swagger.yaml +++ b/api/swagger/swagger.yaml @@ -2231,6 +2231,7 @@ definitions: match: $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.Match' matchYaml: + example: "namespaces:\r\n- testns1" type: string parameters: example: '{"labels":{"key":"owner","allowedRegex":"test*"}' diff --git a/internal/delivery/http/organization.go b/internal/delivery/http/organization.go index f1a1bba1..d5fe5d2d 100644 --- a/internal/delivery/http/organization.go +++ b/internal/delivery/http/organization.go @@ -128,6 +128,14 @@ func (h *OrganizationHandler) Admin_CreateOrganization(w http.ResponseWriter, r } organization.AdminId = &admin.ID + // Default systemNotificationRules 생성 + err = h.usecase.MakeDefaultSystemNotificationRules(r.Context(), organizationId, &organization) + if err != nil { + log.Errorf(r.Context(), "error is :%s(%T)", err.Error(), err) + ErrorJSON(w, r, err) + return + } + var out domain.CreateOrganizationResponse if err = serializer.Map(r.Context(), organization, &out); err != nil { log.Error(r.Context(), err) diff --git a/internal/model/system-notification-rule.go b/internal/model/system-notification-rule.go index 76a277ff..49d9ddbf 100644 --- a/internal/model/system-notification-rule.go +++ b/internal/model/system-notification-rule.go @@ -28,6 +28,7 @@ type SystemNotificationRule struct { Description string OrganizationId string Organization Organization `gorm:"foreignKey:OrganizationId"` + IsSystem bool `gorm:"default:false"` SystemNotificationTemplate SystemNotificationTemplate `gorm:"foreignKey:SystemNotificationTemplateId"` SystemNotificationTemplateId string SystemNotificationConditions []SystemNotificationCondition `gorm:"foreignKey:SystemNotificationRuleId;constraint:OnUpdate:RESTRICT,OnDelete:RESTRICT"` @@ -36,6 +37,7 @@ type SystemNotificationRule struct { MessageTitle string MessageContent string MessageActionProposal string + Status domain.SystemNotificationRuleStatus CreatorId *uuid.UUID `gorm:"type:uuid"` Creator *User `gorm:"foreignKey:CreatorId"` UpdatorId *uuid.UUID `gorm:"type:uuid"` diff --git a/internal/model/system-notification-template.go b/internal/model/system-notification-template.go index eabf2dd5..7639442b 100644 --- a/internal/model/system-notification-template.go +++ b/internal/model/system-notification-template.go @@ -20,6 +20,7 @@ type SystemNotificationTemplate struct { ID uuid.UUID `gorm:"primarykey"` Name string `gorm:"index:idx_name,unique"` + IsSystem bool `gorm:"default:false"` Organizations []Organization `gorm:"many2many:system_notification_template_organizations;constraint:OnUpdate:RESTRICT,OnDelete:RESTRICT"` OrganizationIds []string `gorm:"-:all"` Description string diff --git a/internal/policy-template/tkscluster.go b/internal/policy-template/tkscluster.go index e4ce4a93..0fb2fa7f 100644 --- a/internal/policy-template/tkscluster.go +++ b/internal/policy-template/tkscluster.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/openinfradev/tks-api/internal/kubernetes" + "github.com/openinfradev/tks-api/pkg/kubernetes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" ) diff --git a/internal/policy-template/tkspolicy.go b/internal/policy-template/tkspolicy.go index d0999720..9c32892f 100644 --- a/internal/policy-template/tkspolicy.go +++ b/internal/policy-template/tkspolicy.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" - "github.com/openinfradev/tks-api/internal/kubernetes" "github.com/openinfradev/tks-api/pkg/domain" + "github.com/openinfradev/tks-api/pkg/kubernetes" "gopkg.in/yaml.v3" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" diff --git a/internal/policy-template/tkspolicytemplate.go b/internal/policy-template/tkspolicytemplate.go index ed22103f..a561fb32 100644 --- a/internal/policy-template/tkspolicytemplate.go +++ b/internal/policy-template/tkspolicytemplate.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strings" - "github.com/openinfradev/tks-api/internal/kubernetes" + "github.com/openinfradev/tks-api/pkg/kubernetes" "gopkg.in/yaml.v3" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" diff --git a/internal/repository/system-notification-rule.go b/internal/repository/system-notification-rule.go index 44266e0d..b5da7c88 100644 --- a/internal/repository/system-notification-rule.go +++ b/internal/repository/system-notification-rule.go @@ -18,6 +18,7 @@ type ISystemNotificationRuleRepository interface { Fetch(ctx context.Context, pg *pagination.Pagination) ([]model.SystemNotificationRule, error) FetchWithOrganization(ctx context.Context, organizationId string, pg *pagination.Pagination) (out []model.SystemNotificationRule, err error) Create(ctx context.Context, dto model.SystemNotificationRule) (systemNotificationRuleId uuid.UUID, err error) + Creates(ctx context.Context, dto []model.SystemNotificationRule) (err error) Update(ctx context.Context, dto model.SystemNotificationRule) (err error) Delete(ctx context.Context, dto model.SystemNotificationRule) (err error) } @@ -86,6 +87,15 @@ func (r *SystemNotificationRuleRepository) Create(ctx context.Context, dto model return dto.ID, nil } +func (r *SystemNotificationRuleRepository) Creates(ctx context.Context, rules []model.SystemNotificationRule) (err error) { + res := r.db.WithContext(ctx).Create(&rules) + if res.Error != nil { + return res.Error + } + + return nil +} + func (r *SystemNotificationRuleRepository) Update(ctx context.Context, dto model.SystemNotificationRule) (err error) { var m model.SystemNotificationRule res := r.db.WithContext(ctx).Preload(clause.Associations).First(&m, "id = ?", dto.ID) diff --git a/internal/usecase/app-serve-app.go b/internal/usecase/app-serve-app.go index 4fb12686..28e76385 100644 --- a/internal/usecase/app-serve-app.go +++ b/internal/usecase/app-serve-app.go @@ -13,13 +13,13 @@ import ( "github.com/spf13/viper" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/openinfradev/tks-api/internal/kubernetes" "github.com/openinfradev/tks-api/internal/model" "github.com/openinfradev/tks-api/internal/pagination" "github.com/openinfradev/tks-api/internal/repository" argowf "github.com/openinfradev/tks-api/pkg/argo-client" "github.com/openinfradev/tks-api/pkg/domain" "github.com/openinfradev/tks-api/pkg/httpErrors" + "github.com/openinfradev/tks-api/pkg/kubernetes" "github.com/openinfradev/tks-api/pkg/log" ) diff --git a/internal/usecase/cloud-account.go b/internal/usecase/cloud-account.go index 33c9ceae..9cf649f4 100644 --- a/internal/usecase/cloud-account.go +++ b/internal/usecase/cloud-account.go @@ -16,7 +16,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/servicequotas" "github.com/aws/aws-sdk-go-v2/service/sts" "github.com/google/uuid" - "github.com/openinfradev/tks-api/internal/kubernetes" "github.com/openinfradev/tks-api/internal/middleware/auth/request" "github.com/openinfradev/tks-api/internal/model" "github.com/openinfradev/tks-api/internal/pagination" @@ -24,6 +23,7 @@ import ( argowf "github.com/openinfradev/tks-api/pkg/argo-client" "github.com/openinfradev/tks-api/pkg/domain" "github.com/openinfradev/tks-api/pkg/httpErrors" + "github.com/openinfradev/tks-api/pkg/kubernetes" "github.com/openinfradev/tks-api/pkg/log" "github.com/pkg/errors" "gorm.io/gorm" diff --git a/internal/usecase/cluster.go b/internal/usecase/cluster.go index a2b04912..2300b8dc 100644 --- a/internal/usecase/cluster.go +++ b/internal/usecase/cluster.go @@ -10,7 +10,6 @@ import ( "github.com/google/uuid" "github.com/openinfradev/tks-api/internal/helper" - "github.com/openinfradev/tks-api/internal/kubernetes" "github.com/openinfradev/tks-api/internal/middleware/auth/request" "github.com/openinfradev/tks-api/internal/model" "github.com/openinfradev/tks-api/internal/pagination" @@ -19,6 +18,7 @@ import ( argowf "github.com/openinfradev/tks-api/pkg/argo-client" "github.com/openinfradev/tks-api/pkg/domain" "github.com/openinfradev/tks-api/pkg/httpErrors" + "github.com/openinfradev/tks-api/pkg/kubernetes" "github.com/openinfradev/tks-api/pkg/log" gcache "github.com/patrickmn/go-cache" "github.com/pkg/errors" diff --git a/internal/usecase/dashboard.go b/internal/usecase/dashboard.go index 82cf8c93..67337c0a 100644 --- a/internal/usecase/dashboard.go +++ b/internal/usecase/dashboard.go @@ -10,12 +10,12 @@ import ( "github.com/google/uuid" "github.com/openinfradev/tks-api/internal/helper" - "github.com/openinfradev/tks-api/internal/kubernetes" "github.com/openinfradev/tks-api/internal/model" "github.com/openinfradev/tks-api/internal/repository" "github.com/openinfradev/tks-api/internal/serializer" "github.com/openinfradev/tks-api/pkg/domain" "github.com/openinfradev/tks-api/pkg/httpErrors" + "github.com/openinfradev/tks-api/pkg/kubernetes" "github.com/openinfradev/tks-api/pkg/log" thanos "github.com/openinfradev/tks-api/pkg/thanos-client" gcache "github.com/patrickmn/go-cache" diff --git a/internal/usecase/organization.go b/internal/usecase/organization.go index ea794543..80565f39 100644 --- a/internal/usecase/organization.go +++ b/internal/usecase/organization.go @@ -28,29 +28,30 @@ type IOrganizationUsecase interface { UpdatePrimaryClusterId(ctx context.Context, organizationId string, clusterId string) (err error) ChangeAdminId(ctx context.Context, organizationId string, adminId uuid.UUID) error Delete(ctx context.Context, organizationId string, accessToken string) error + MakeDefaultSystemNotificationRules(ctx context.Context, organizationId string, organization *model.Organization) (err error) } type OrganizationUsecase struct { - repo repository.IOrganizationRepository - userRepo repository.IUserRepository - roleRepo repository.IRoleRepository - clusterRepo repository.IClusterRepository - stackTemplateRepo repository.IStackTemplateRepository - systemNotificationTemplateRepo repository.ISystemNotificationTemplateRepository - argo argowf.ArgoClient - kc keycloak.IKeycloak + repo repository.IOrganizationRepository + userRepo repository.IUserRepository + roleRepo repository.IRoleRepository + clusterRepo repository.IClusterRepository + stackTemplateRepo repository.IStackTemplateRepository + systemNotificationRuleRepo repository.ISystemNotificationRuleRepository + argo argowf.ArgoClient + kc keycloak.IKeycloak } func NewOrganizationUsecase(r repository.Repository, argoClient argowf.ArgoClient, kc keycloak.IKeycloak) IOrganizationUsecase { return &OrganizationUsecase{ - repo: r.Organization, - userRepo: r.User, - roleRepo: r.Role, - clusterRepo: r.Cluster, - stackTemplateRepo: r.StackTemplate, - systemNotificationTemplateRepo: r.SystemNotificationTemplate, - argo: argoClient, - kc: kc, + repo: r.Organization, + userRepo: r.User, + roleRepo: r.Role, + clusterRepo: r.Cluster, + stackTemplateRepo: r.StackTemplate, + systemNotificationRuleRepo: r.SystemNotificationRule, + argo: argoClient, + kc: kc, } } @@ -218,3 +219,14 @@ func (u *OrganizationUsecase) ChangeAdminId(ctx context.Context, organizationId return nil } + +func (u *OrganizationUsecase) MakeDefaultSystemNotificationRules(ctx context.Context, organizationId string, dto *model.Organization) error { + var rules []model.SystemNotificationRule + + err := u.systemNotificationRuleRepo.Creates(ctx, rules) + if err != nil { + return err + } + + return nil +} diff --git a/internal/usecase/project.go b/internal/usecase/project.go index 4fbc4382..51b0b524 100644 --- a/internal/usecase/project.go +++ b/internal/usecase/project.go @@ -8,13 +8,13 @@ import ( "github.com/google/uuid" "github.com/openinfradev/tks-api/internal/keycloak" - "github.com/openinfradev/tks-api/internal/kubernetes" "github.com/openinfradev/tks-api/internal/model" "github.com/openinfradev/tks-api/internal/pagination" "github.com/openinfradev/tks-api/internal/repository" "github.com/openinfradev/tks-api/internal/serializer" argowf "github.com/openinfradev/tks-api/pkg/argo-client" "github.com/openinfradev/tks-api/pkg/domain" + "github.com/openinfradev/tks-api/pkg/kubernetes" "github.com/openinfradev/tks-api/pkg/log" "github.com/pkg/errors" "gopkg.in/yaml.v3" diff --git a/internal/usecase/stack.go b/internal/usecase/stack.go index 00a2e6c9..7c9bd129 100644 --- a/internal/usecase/stack.go +++ b/internal/usecase/stack.go @@ -9,7 +9,6 @@ import ( "github.com/google/uuid" "github.com/openinfradev/tks-api/internal/helper" - "github.com/openinfradev/tks-api/internal/kubernetes" "github.com/openinfradev/tks-api/internal/middleware/auth/request" "github.com/openinfradev/tks-api/internal/model" "github.com/openinfradev/tks-api/internal/pagination" @@ -18,6 +17,7 @@ import ( argowf "github.com/openinfradev/tks-api/pkg/argo-client" "github.com/openinfradev/tks-api/pkg/domain" "github.com/openinfradev/tks-api/pkg/httpErrors" + "github.com/openinfradev/tks-api/pkg/kubernetes" "github.com/openinfradev/tks-api/pkg/log" "github.com/pkg/errors" "github.com/spf13/viper" diff --git a/pkg/domain/system-notification-rule.go b/pkg/domain/system-notification-rule.go index a9c8abc4..25380f6a 100644 --- a/pkg/domain/system-notification-rule.go +++ b/pkg/domain/system-notification-rule.go @@ -4,6 +4,31 @@ import ( "time" ) +// enum +type SystemNotificationRuleStatus int32 + +const ( + SystemNotificationRuleStatus_PENDING SystemNotificationRuleStatus = iota + SystemNotificationRuleStatus_APPLYED + SystemNotificationRuleStatus_ERROR +) + +var systemNotificationRuleStatus = [...]string{ + "PENDING", + "APPLYED", + "ERROR", +} + +func (m SystemNotificationRuleStatus) String() string { return systemNotificationRuleStatus[(m)] } +func (m SystemNotificationRuleStatus) FromString(s string) SystemNotificationRuleStatus { + for i, v := range systemNotificationRuleStatus { + if v == s { + return SystemNotificationRuleStatus(i) + } + } + return SystemNotificationRuleStatus_PENDING +} + type SystemNotificationRuleResponse struct { ID string `json:"id"` Name string `json:"name"` diff --git a/pkg/domain/system-notification.go b/pkg/domain/system-notification.go index 6d875aa6..2d35b9ab 100644 --- a/pkg/domain/system-notification.go +++ b/pkg/domain/system-notification.go @@ -68,7 +68,7 @@ type CreateSystemNotificationRequest struct { Version string `json:"version"` GroupKey string `json:"groupKey"` TruncateSystemNotifications int `json:"truncateSystemNotifications"` - SystemNotifications []SystemNotification `json:"systemNotifications"` + SystemNotifications []SystemNotification `json:"alerts"` GroupLabels struct { SystemNotificationname string `json:"systemNotificationname"` } `json:"groupLabels"` diff --git a/internal/kubernetes/kubernetes.go b/pkg/kubernetes/kubernetes.go similarity index 100% rename from internal/kubernetes/kubernetes.go rename to pkg/kubernetes/kubernetes.go diff --git a/internal/kubernetes/kubernetes_test.go b/pkg/kubernetes/kubernetes_test.go similarity index 99% rename from internal/kubernetes/kubernetes_test.go rename to pkg/kubernetes/kubernetes_test.go index 4a7d6bf8..647d57a1 100644 --- a/internal/kubernetes/kubernetes_test.go +++ b/pkg/kubernetes/kubernetes_test.go @@ -2,11 +2,12 @@ package kubernetes_test import ( "context" - "github.com/openinfradev/tks-api/internal/kubernetes" - "gopkg.in/yaml.v3" "os" "reflect" "testing" + + "github.com/openinfradev/tks-api/pkg/kubernetes" + "gopkg.in/yaml.v3" ) const path = "/Users/1113433/local_vm_kube/kubeconfig" diff --git a/scripts/init_postgres.sql b/scripts/init_postgres.sql index 98eb2b77..f57b52a8 100644 --- a/scripts/init_postgres.sql +++ b/scripts/init_postgres.sql @@ -1,3 +1,4 @@ +## Roles insert into roles ( id, name, description, created_at, updated_at ) values ( '2ea4415c-9748-493f-91ba-4a64506b7be8', 'tks-admin', 'tks-admin', now(), now() ); insert into roles ( id, name, description, created_at, updated_at ) values ( 'b2b689f0-ceeb-46c2-b280-0bc06896acd1', 'admin', 'admin', now(), now() ); insert into roles ( id, name, description, created_at, updated_at ) values ( 'd3015140-2b12-487a-9516-cdeed7c17735', 'project-leader', 'project-leader', now(), now() ); @@ -5,6 +6,7 @@ insert into roles ( id, name, description, created_at, updated_at ) values ( 'f6 insert into roles ( id, name, description, created_at, updated_at ) values ( 'b7ac7e7d-d8bc-470d-b6b2-3e0cc8ba55cc', 'project-viewer', 'project-viewer', now(), now() ); insert into roles ( id, name, description, created_at, updated_at ) values ( 'ff4187a2-f3c1-46b3-8448-03a4b5e132e7', 'user', 'user', now(), now() ); +## Policies insert into policies ( role_id, name, description, c, create_priviledge, u, update_priviledge, r, read_priviledge, d, delete_priviledge, creator, created_at, updated_at ) values ( '2ea4415c-9748-493f-91ba-4a64506b7be8', 'organization', 'organization', 't', '', 't', '', 't', '', 't', '', '', now(), now() ); insert into policies ( role_id, name, description, c, create_priviledge, u, update_priviledge, r, read_priviledge, d, delete_priviledge, creator, created_at, updated_at ) values ( '2ea4415c-9748-493f-91ba-4a64506b7be8', 'project', 'project', 't', '', 't', '', 't', '', 't', '', '', now(), now() ); insert into policies ( role_id, name, description, c, create_priviledge, u, update_priviledge, r, read_priviledge, d, delete_priviledge, creator, created_at, updated_at ) values ( '2ea4415c-9748-493f-91ba-4a64506b7be8', 'user', 'user', 't', '', 't', '', 't', '', 't', '', '', now(), now() ); @@ -12,9 +14,13 @@ insert into policies ( role_id, name, description, c, create_priviledge, u, upda insert into policies ( role_id, name, description, c, create_priviledge, u, update_priviledge, r, read_priviledge, d, delete_priviledge, creator, created_at, updated_at ) values ( '2ea4415c-9748-493f-91ba-4a64506b7be8', 'service', 'service', 't', '', 't', '', 't', '', 't', '', '', now(), now() ); insert into policies ( role_id, name, description, c, create_priviledge, u, update_priviledge, r, read_priviledge, d, delete_priviledge, creator, created_at, updated_at ) values ( '2ea4415c-9748-493f-91ba-4a64506b7be8', 'k8s_resources', 'resources of k8s', 'f', '', 'f', '', 'f', '', 'f', '', '', now(), now() ); +## Organizations insert into organizations ( id, name, description, created_at, updated_at ) values ( 'master', 'master', 'tks', now(), now() ); + +## Users insert into users ( id, account_id, name, password, organization_id, role_id, created_at, updated_at ) values ( 'bf67de40-ce15-4dc0-b6c2-17f053ca504f', 'admin', 'admin', '$2a$10$Akf03nbLHk93sTtozm35XuINXkJeNX7A1T9o/Pxpg9R2B2PToBPOO', 'master', 'b2b689f0-ceeb-46c2-b280-0bc06896acd1', now(), now() ); +## StackTemplates insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services ) values ( '49901092-be76-4d4f-94e9-b84525f560b5', 'master', 'AWS Standard (x86)', 'included LMA', 'v1', 'AWS', 'x86', 'aws-reference', 'STANDARD', 'v1.25', 'AWS', now(), now(), '[{"name": "Logging,Monitoring,Alerting", "type": "LMA", "applications": [{"name": "prometheus-stack", "version": "v.44.3.1", "description": "통계데이터 제공을 위한 backend 플랫폼"}, {"name": "elastic-system", "version": "v1.8.0", "description": "로그 데이터 적재를 위한 Storage"}, {"name": "alertmanager", "version": "v0.23.0", "description": "Alert 관리를 위한 backend 서비스"}, {"name": "grafana", "version": "v6.50.7", "description": "모니터링 통합 포탈"}]}]' ); insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services ) @@ -31,7 +37,6 @@ insert into stack_templates ( id, organization_id, name, description, version, c values ( '5678bf11-256f-4d2c-a673-f2fedb82de5b', 'master', 'BYOH Standard', 'included LMA', 'v1', 'AWS', 'x86', 'eks-reference', 'STANDARD', 'v1.25', 'AWS', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' ); insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services ) values ( '92f5e5ce-7ffd-4c3e-aff6-9b7fb03dd881', 'master', 'BYOH MSA Standard', 'included LMA, SERVICE MESH', 'v1', 'AWS', 'x86', 'eks-msa-reference', 'MSA', 'v1.25', 'AWS', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]},{"name":"MSA","type":"SERVICE_MESH","applications":[{"name":"istio","version":"v1.17.2","description":"MSA 플랫폼"},{"name":"jagger","version":"1.35.0","description":"분산 서비스간 트랜잭션 추적을 위한 플랫폼"},{"name":"kiali","version":"v1.63.0","description":"MSA 구조 및 성능을 볼 수 있는 Dashboard"},{"name":"k8ssandra","version":"1.6.0","description":"분산 서비스간 호출 로그를 저장하는 스토리지"}]}]' ); - # BTV insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services ) values ( '2526ec49-28a2-4be9-8d18-2c39fc0993fd', 'master', 'BYOH Admin Standard (BTV)', 'included LMA', 'v1', 'BYOH', 'x86', 'tks-admin', 'STANDARD', 'v1.25', 'BYOH', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' ); @@ -39,14 +44,26 @@ insert into stack_templates ( id, organization_id, name, description, version, c values ( 'a76b5c97-7d55-46d8-9248-9952bfaff62c', 'master', 'BYOH MSA Standard (BTV SSU)', 'included LMA', 'v1', 'BYOH', 'x86', 'byoh-ssu-reference', 'MSA', 'v1.25', 'BYOH', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' ); insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services ) values ( 'b5bbd6ea-5bf3-4d88-bb06-4a4c64c73c15', 'master', 'BYOH MSA Standard (BTV SUY)', 'included LMA', 'v1', 'BYOH', 'x86', 'byoh-suy-reference', 'MSA', 'v1.25', 'BYOH', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' ); - # PSNM insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services ) values ( 'c3396c68-03ec-4d41-991c-69e4a2ac16aa', 'master', 'psnm-backend-reference', 'included LMA', 'v1', 'AWS', 'x86', 'psnm-backend-reference', 'STANDARD', 'v1.25', 'EKS', now(), now(), '[{"name": "Logging,Monitoring,Alerting", "type": "LMA", "applications": [{"name": "prometheus-stack", "version": "v.44.3.1", "description": "통계데이터 제공을 위한 backend 플랫폼"}, {"name": "elastic-system", "version": "v1.8.0", "description": "로그 데이터 적재를 위한 Storage"}, {"name": "alertmanager", "version": "v0.23.0", "description": "Alert 관리를 위한 backend 서비스"}, {"name": "grafana", "version": "v6.50.7", "description": "모니터링 통합 포탈"}]}]' ); insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services ) values ( '23b07a65-1cb3-4609-9bba-e88c15e2e192', 'master', 'psnm-frontend-reference', 'included LMA', 'v1', 'AWS', 'x86', 'psnm-frontend-reference', 'STANDARD', 'v1.25', 'EKS', now(), now(), '[{"name": "Logging,Monitoring,Alerting", "type": "LMA", "applications": [{"name": "prometheus-stack", "version": "v.44.3.1", "description": "통계데이터 제공을 위한 backend 플랫폼"}, {"name": "elastic-system", "version": "v1.8.0", "description": "로그 데이터 적재를 위한 Storage"}, {"name": "alertmanager", "version": "v0.23.0", "description": "Alert 관리를 위한 backend 서비스"}, {"name": "grafana", "version": "v6.50.7", "description": "모니터링 통합 포탈"}]}]' ); -# PROJECT +## Projects insert into project_roles ( id, name, description, created_at, updated_at ) values ( 'f4358b4e-adc3-447a-8ad9-c111c4b9a974', 'project-leader', 'project-leader', now(), now() ); insert into project_roles ( id, name, description, created_at, updated_at ) values ( '2071bd6f-26b3-4c1a-a3ab-439bc89f0011', 'project-member', 'project-member', now(), now() ); -insert into project_roles ( id, name, description, created_at, updated_at ) values ( 'f62c16e1-316c-4d7f-9cfa-dbe4ed7dfa17', 'project-viewer', 'project-viewer', now(), now() ); \ No newline at end of file +insert into project_roles ( id, name, description, created_at, updated_at ) values ( 'f62c16e1-316c-4d7f-9cfa-dbe4ed7dfa17', 'project-viewer', 'project-viewer', now(), now() ); + +## SystemNotificationTemplates +insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at ) +values ('d42d716f-dd2e-429b-897d-b602f6382790', 'node-cpu-high-load', 'node-cpu-high-load', true, '(avg by (taco_cluster, instance) (rate(node_cpu_seconds_total{mode="idle"}[60s]))) < 0', null, null, now(), now() ); +insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at ) +values ('f11eefa4-5a16-44fc-8dae-4662e7fba023', 'node-memory-high-utilization', true, 'node-memory-high-utilization', '(node_memory_MemAvailable_bytes/node_memory_MemTotal_bytes) < 0.2', null, null, now(), now() ); +insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at ) +values ('1ec08b58-2fe1-49c5-bbab-3544ec8ce330', 'node-disk-full', 'node-disk-full', true, 'predict_linear(node_filesystem_free_bytes{mountpoint="/"}[6h], 24*3600) < 0', null, null, now(), now() ); +insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at ) +values ('68dcb92d-91cc-47d0-9b2f-2285d74f157f', 'pvc-full', 'pvc-full', true, 'predict_linear(kubelet_volume_stats_available_bytes[6h], 24*3600) < 0', null, null, now(), now() ); +insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at ) +values ('46e9e216-364a-4a3f-9182-85b2c4c34f77', 'pod-restart-frequently', true, 'pod-restart-frequently', 'increase(kube_pod_container_status_restarts_total{namespace!="kube-system"}[60m:]) > 2', null, null, now(), now() ); +