You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by zh...@apache.org on 2024/12/27 08:23:59 UTC

(dubbo-kubernetes) branch master updated: [operator] add admin charts logic

This is an automated email from the ASF dual-hosted git repository.

zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git


The following commit(s) were added to refs/heads/master by this push:
     new 183c8bc2 [operator] add admin charts logic
183c8bc2 is described below

commit 183c8bc28b1937cde4a01c6ebe38bded74156212
Author: mfordjody <11...@qq.com>
AuthorDate: Fri Dec 27 16:23:50 2024 +0800

    [operator] add admin charts logic
---
 manifests/profiles/default.yaml        |  9 +++++++--
 operator/pkg/apis/types.go             | 22 +++++++++++----------
 operator/pkg/component/component.go    | 21 ++++++++++++++++----
 operator/pkg/install/installer.go      |  3 +++
 operator/pkg/render/manifest.go        |  2 +-
 operator/pkg/util/progress/progress.go | 35 +++++++++++++++++++++++++++++++++-
 6 files changed, 74 insertions(+), 18 deletions(-)

diff --git a/manifests/profiles/default.yaml b/manifests/profiles/default.yaml
index 96d6699f..25cdb2b5 100644
--- a/manifests/profiles/default.yaml
+++ b/manifests/profiles/default.yaml
@@ -6,6 +6,11 @@ spec:
   components:
     base:
       enabled: true
+    admin:
+      enabled: true
   values:
-    global:
-      dubboNamespace: dubbo-system
+    base:
+      global:
+        dubboNamespace: dubbo-system
+    admin:
+      global: {}
diff --git a/operator/pkg/apis/types.go b/operator/pkg/apis/types.go
index ee72de17..e5c2f60a 100644
--- a/operator/pkg/apis/types.go
+++ b/operator/pkg/apis/types.go
@@ -34,29 +34,31 @@ type DubboOperator struct {
 }
 
 type DubboOperatorSpec struct {
-	Profile string `json:"profile,omitempty"`
-	Namespace string `json:"namespace,omitempty"`
-	Revision string                `json:"revision,omitempty"`
+	Profile    string              `json:"profile,omitempty"`
+	Namespace  string              `json:"namespace,omitempty"`
+	Revision   string              `json:"revision,omitempty"`
 	Components *DubboComponentSpec `json:"components,omitempty"`
-	Values json.RawMessage         `json:"values,omitempty"`
+	Values     json.RawMessage     `json:"values,omitempty"`
 }
 
 type DubboComponentSpec struct {
-	Base    *BaseComponentSpec `json:"base,omitempty"`
+	Base  *BaseComponentSpec  `json:"base,omitempty"`
+	Admin *ComponentSpec `json:"admin,omitempty"`
 }
 
 type BaseComponentSpec struct {
-	Enabled    *BoolValue           `json:"enabled,omitempty"`
+	Enabled *BoolValue `json:"enabled,omitempty"`
 }
+
 type ComponentSpec struct {
-	Enabled *BoolValue `json:"enabled,omitempty"`
-	Namespace string `json:"namespace,omitempty"`
-	Raw map[string]any `json:"-"`
+	Enabled   *BoolValue     `json:"enabled,omitempty"`
+	Namespace string         `json:"namespace,omitempty"`
+	Raw       map[string]any `json:"-"`
 }
 
 type MetadataCompSpec struct {
 	ComponentSpec
-	Name string `json:"name,omitempty"`
+	Name  string            `json:"name,omitempty"`
 	Label map[string]string `json:"label,omitempty"`
 }
 
diff --git a/operator/pkg/component/component.go b/operator/pkg/component/component.go
index 572a5cfb..37f0eae7 100644
--- a/operator/pkg/component/component.go
+++ b/operator/pkg/component/component.go
@@ -9,7 +9,8 @@ import (
 type Name string
 
 const (
-	BaseComponentName Name = "Base"
+	BaseComponentName  Name = "Base"
+	AdminComponentName Name = "Admin"
 )
 
 type Component struct {
@@ -18,6 +19,7 @@ type Component struct {
 	Default        bool
 	HelmSubDir     string
 	HelmTreeRoot   string
+	ResourceName   string
 	FlattenValues  bool
 }
 
@@ -27,16 +29,27 @@ var AllComponents = []Component{
 		SpecName:       "base",
 		Default:        true,
 		HelmSubDir:     "base",
-		HelmTreeRoot:   "global",
+		HelmTreeRoot:   "base.global",
+	},
+	{
+		UserFacingName: AdminComponentName,
+		SpecName:       "admin",
+		Default:        true,
+		ResourceName:   "admin",
+		HelmSubDir:     "admin",
+		HelmTreeRoot:   "admin.global",
 	},
 }
 
 var (
 	userFacingCompNames = map[Name]string{
-		BaseComponentName: "Dubbo Core",
+		BaseComponentName:  "Dubbo Core",
+		AdminComponentName: "Dubbo Dashboard or Control Plane",
 	}
+
 	Icons = map[Name]string{
-		BaseComponentName: "🛸",
+		BaseComponentName:  "🛸",
+		AdminComponentName: "🛰 ✗📡",
 	}
 )
 
diff --git a/operator/pkg/install/installer.go b/operator/pkg/install/installer.go
index 9cadbbd4..80d7f034 100644
--- a/operator/pkg/install/installer.go
+++ b/operator/pkg/install/installer.go
@@ -202,6 +202,9 @@ func (i Installer) prune(manifests []manifest.ManifestSet) error {
 
 var componentDependencies = map[component.Name][]component.Name{
 	component.BaseComponentName: {},
+	component.AdminComponentName: {
+		component.BaseComponentName,
+	},
 }
 
 func dependenciesChs() map[component.Name]chan struct{} {
diff --git a/operator/pkg/render/manifest.go b/operator/pkg/render/manifest.go
index 2da100a5..8d678edd 100644
--- a/operator/pkg/render/manifest.go
+++ b/operator/pkg/render/manifest.go
@@ -111,7 +111,7 @@ func readBuiltinProfile(path, profile string) (values.Map, error) {
 	return values.MapFromYAML(pb)
 }
 
-func GenerateManifest(files []string, setFlags []string, logger clog.Logger, client kube.Client) ([]manifest.ManifestSet, values.Map, error) {
+func GenerateManifest(files []string, setFlags []string, logger clog.Logger, _ kube.Client) ([]manifest.ManifestSet, values.Map, error) {
 	merged, err := MergeInputs(files, setFlags)
 	if err != nil {
 		return nil, nil, fmt.Errorf("merge inputs: %v %v", err)
diff --git a/operator/pkg/util/progress/progress.go b/operator/pkg/util/progress/progress.go
index 9ec7ab69..b7e6235d 100644
--- a/operator/pkg/util/progress/progress.go
+++ b/operator/pkg/util/progress/progress.go
@@ -5,6 +5,8 @@ import (
 	"github.com/apache/dubbo-kubernetes/operator/pkg/component"
 	"github.com/cheggaaa/pb/v3"
 	"io"
+	"sort"
+	"strings"
 	"sync"
 )
 
@@ -34,6 +36,30 @@ func NewInfo() *Info {
 	}
 }
 
+func (i *Info) createStatus(maxWidth int) string {
+	comps := make([]string, 0, len(i.components))
+	wait := make([]string, 0, len(i.components))
+	for c, l := range i.components {
+		comps = append(comps, component.UserFacingCompName(component.Name(c)))
+		wait = append(wait, l.waitingResources()...)
+	}
+	sort.Strings(comps)
+	sort.Strings(wait)
+	msg := fmt.Sprintf(`Processing resources for %s.`, strings.Join(comps, ", "))
+	if len(wait) > 0 {
+		msg += fmt.Sprintf(` Waiting for %s`, strings.Join(wait, ", "))
+	}
+	prefix := inProgress
+	if !i.bar.GetBool(pb.Terminal) {
+		prefix = `{{ yellow "-" }} `
+	}
+	maxWidth -= 2
+	if maxWidth > 0 && len(msg) > maxWidth {
+		return prefix + msg[:maxWidth-3] + "..."
+	}
+	return prefix + msg
+}
+
 func (i *Info) NewComponent(comp string) *ManifestInfo {
 	mi := &ManifestInfo{
 		report: i.reportProgress(comp),
@@ -54,7 +80,7 @@ func (i *Info) reportProgress(componentName string) func() {
 		finished := comp.finished
 		compErr := comp.err
 		comp.mu.Unlock()
-		successIcon := "🎉"
+		successIcon := "✅"
 		if icon, found := component.Icons[compName]; found {
 			successIcon = icon
 		}
@@ -68,6 +94,7 @@ func (i *Info) reportProgress(componentName string) func() {
 			i.bar = createBar()
 			return
 		}
+		i.SetMessage(i.createStatus(i.bar.Width()), false)
 	}
 }
 
@@ -146,3 +173,9 @@ func (mi *ManifestInfo) ReportError(err string) {
 	mi.mu.Unlock()
 	mi.report()
 }
+
+func (p *ManifestInfo) waitingResources() []string {
+	p.mu.Lock()
+	defer p.mu.Unlock()
+	return p.waiting
+}