From 54c19bc02fc657ac6cc56de456b883119856c48f Mon Sep 17 00:00:00 2001 From: Rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Sat, 11 Sep 2021 10:18:34 +0800 Subject: [PATCH] Print more cluster info when setting multi-cluster (#121) --- kubectl-plugin/common/installer.go | 28 +++++++++++++++++----------- kubectl-plugin/config/cluster.go | 5 ++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/kubectl-plugin/common/installer.go b/kubectl-plugin/common/installer.go index a97b73c..10ef8d0 100644 --- a/kubectl-plugin/common/installer.go +++ b/kubectl-plugin/common/installer.go @@ -10,17 +10,23 @@ type KSInstallerSpec struct { Version string ImageNamespace string - Servicemesh ComponentStatus - Openpitrix ComponentStatus - Notification ComponentStatus - NetworkPolicy ComponentStatus - MetricsServer ComponentStatus - Logging ComponentStatus - Events ComponentStatus - DevOps ComponentStatus - Auditing ComponentStatus - Alerting ComponentStatus - Multicluster Multicluster `yaml:"multicluster"` + Authentication Authentication `yaml:"authentication"` + Servicemesh ComponentStatus + Openpitrix ComponentStatus + Notification ComponentStatus + NetworkPolicy ComponentStatus + MetricsServer ComponentStatus + Logging ComponentStatus + Events ComponentStatus + DevOps ComponentStatus + Auditing ComponentStatus + Alerting ComponentStatus + Multicluster Multicluster `yaml:"multicluster"` +} + +// Authentication represents the Authentication of KubeSphere +type Authentication struct { + JwtSecret string `yaml:"jwtSecret"` } // ComponentStatus is a common status diff --git a/kubectl-plugin/config/cluster.go b/kubectl-plugin/config/cluster.go index fd86c67..a80c5ef 100644 --- a/kubectl-plugin/config/cluster.go +++ b/kubectl-plugin/config/cluster.go @@ -105,6 +105,9 @@ func (o *clusterOption) showClusterRole() (err error) { installer := common.KSInstaller{} if err = yaml.Unmarshal(yamlData, &installer); err == nil { fmt.Printf("cluster role: %s\n", installer.Spec.Multicluster.ClusterRole) + if installer.Spec.Multicluster.ClusterRole == "member" { + fmt.Printf("host cluster jwtSecret: %s\n", installer.Spec.Authentication.JwtSecret) + } } } @@ -117,7 +120,7 @@ func (o *clusterOption) showClusterRole() (err error) { cfg := kubeSphereConfig{} if err = yaml.Unmarshal([]byte(fmt.Sprintf("%v", kubeSphereCfg)), &cfg); err == nil { - fmt.Printf("jwtSecret: %s\n", cfg.Authentication.JwtSecret) + fmt.Printf("current jwtSecret: %s\n", cfg.Authentication.JwtSecret) } } return