You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2023/05/04 10:42:53 UTC

[shardingsphere-on-cloud] branch main updated: refactor(operator): refactor configmap build serverconfig and tests (#335)

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

sunnianjun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git


The following commit(s) were added to refs/heads/main by this push:
     new 54a8b4b  refactor(operator): refactor configmap build serverconfig and tests (#335)
54a8b4b is described below

commit 54a8b4beabb33c6270dd1fb376fd4ef2944fcbaf
Author: liyao <ma...@126.com>
AuthorDate: Thu May 4 18:42:49 2023 +0800

    refactor(operator): refactor configmap build serverconfig and tests (#335)
    
    * refactor: update deployment builder with probe setting
    
    Signed-off-by: mlycore <ma...@126.com>
    
    * feat: add yaml omitempty tag to props
    
    Signed-off-by: mlycore <ma...@126.com>
    
    * feat: make defaultServerConfig as a constant
    
    Signed-off-by: mlycore <ma...@126.com>
    
    * chore: update unit test
    
    Signed-off-by: mlycore <ma...@126.com>
    
    * feat: update bootstrap config with omitempty tag
    
    Signed-off-by: mlycore <ma...@126.com>
    
    * feat: remove server cluster repo config from annotations
    
    Signed-off-by: mlycore <ma...@126.com>
    
    * refactor: update NewConfigMap func name
    
    Signed-off-by: mlycore <ma...@126.com>
    
    * refactor: update style
    
    Signed-off-by: mlycore <ma...@126.com>
    
    ---------
    
    Signed-off-by: mlycore <ma...@126.com>
---
 .../api/v1alpha1/compute_node_types.go             |  34 +-
 .../pkg/kubernetes/configmap/builder.go            | 116 +++----
 .../pkg/kubernetes/configmap/configmap.go          |   5 +-
 .../kubernetes/configmap/configmap_suite_test.go   |   1 +
 .../pkg/kubernetes/configmap/configmap_test.go     | 360 ++++++++++++++++++++-
 .../pkg/kubernetes/deployment/builder.go           |  23 +-
 6 files changed, 428 insertions(+), 111 deletions(-)

diff --git a/shardingsphere-operator/api/v1alpha1/compute_node_types.go b/shardingsphere-operator/api/v1alpha1/compute_node_types.go
index e980fcf..9013364 100644
--- a/shardingsphere-operator/api/v1alpha1/compute_node_types.go
+++ b/shardingsphere-operator/api/v1alpha1/compute_node_types.go
@@ -70,9 +70,10 @@ type ComputeNodeUser struct {
 
 // ComputeNodeAuth  is used to set up initial user to login compute node, and authority data of storage node.
 type ComputeNodeAuthority struct {
-	Users []ComputeNodeUser `json:"users"`
 	// +optional
-	Privilege ComputeNodePrivilege `json:"privilege"`
+	Users []ComputeNodeUser `json:"users,omitempty" yaml:"users,omitempty"`
+	// +optional
+	Privilege ComputeNodePrivilege `json:"privilege,omitempty" yaml:"privilege,omitempty"`
 }
 
 type RepositoryType string
@@ -89,8 +90,7 @@ type Repository struct {
 	Type RepositoryType `json:"type"`
 	// properties of metadata repository
 	// +optional
-	// Props ComputeNodeClusterProps `json:"props,omitempty"`
-	Props Properties `json:"props,omitempty"`
+	Props Properties `json:"props,omitempty" yaml:"props,omitempty"`
 }
 
 type ModeType string
@@ -103,17 +103,19 @@ const (
 // ComputeNodeServerMode is the mode for ShardingSphere Proxy
 type ComputeNodeServerMode struct {
 	// +optional
-	Repository Repository `json:"repository"`
-	Type       ModeType   `json:"type"`
+	Repository Repository `json:"repository,omitempty" yaml:"repository,omitempty"`
+	// +optional
+	Type ModeType `json:"type,omitempty" yaml:"type,omitempty"`
 }
 
 // ServerConfig defines the bootstrap config for a ShardingSphere Proxy
 type ServerConfig struct {
-	Authority ComputeNodeAuthority  `json:"authority"`
-	Mode      ComputeNodeServerMode `json:"mode"`
-	//+optional
-	// Props *ComputeNodeProps `json:"props,omitempty"`
-	Props Properties `json:"props,omitempty"`
+	// +optional
+	Authority ComputeNodeAuthority `json:"authority,omitempty" yaml:"authority,omitempty"`
+	// +optional
+	Mode ComputeNodeServerMode `json:"mode,omitempty" yaml:"mode,omitempty"`
+	// +optional
+	Props Properties `json:"props,omitempty" yaml:"props,omitempty"`
 }
 
 // LogbackConfig contains contents of the expected logback.xml
@@ -128,7 +130,7 @@ type LoggingFile struct {
 
 // PluginLogging defines the plugin for logging
 type PluginLogging struct {
-	File LoggingFile `json:"file,omitempty" yaml:"File"`
+	File LoggingFile `json:"file,omitempty" yaml:"File,omitempty"`
 }
 
 type Prometheus struct {
@@ -139,7 +141,7 @@ type Prometheus struct {
 
 // PluginMetrics defines the plugin for metrics
 type PluginMetrics struct {
-	Prometheus Prometheus `json:"prometheus,omitempty" yaml:"Prometheus"`
+	Prometheus Prometheus `json:"prometheus,omitempty" yaml:"Prometheus,omitempty"`
 }
 
 type OpenTelemetry struct {
@@ -153,9 +155,9 @@ type OpenTracing struct {
 // PluginTracing defines the plugin for tracing
 type PluginTracing struct {
 	// +optional
-	OpenTracing OpenTracing `json:"openTracing,omitempty" yaml:"OpenTracing"`
+	OpenTracing OpenTracing `json:"openTracing,omitempty" yaml:"OpenTracing,omitempty"`
 	// +optional
-	OpenTelemetry OpenTelemetry `json:"openTelemetry,omitempty" yaml:"OpenTelemetry"`
+	OpenTelemetry OpenTelemetry `json:"openTelemetry,omitempty" yaml:"OpenTelemetry,omitempty"`
 }
 
 // AgentPlugin defines a set of plugins for ShardingSphere Agent
@@ -170,7 +172,7 @@ type AgentPlugin struct {
 
 // AgentConfig defines the config for ShardingSphere-Agent, renderred as agent.yaml
 type AgentConfig struct {
-	Plugins AgentPlugin `json:"plugins,omitempty"`
+	Plugins AgentPlugin `json:"plugins,omitempty" yaml:"plugins,omitempty"`
 }
 
 // ServiceType defines the Service in Kubernetes of ShardingSphere-Proxy
diff --git a/shardingsphere-operator/pkg/kubernetes/configmap/builder.go b/shardingsphere-operator/pkg/kubernetes/configmap/builder.go
index fbde0c6..469c11d 100644
--- a/shardingsphere-operator/pkg/kubernetes/configmap/builder.go
+++ b/shardingsphere-operator/pkg/kubernetes/configmap/builder.go
@@ -18,7 +18,6 @@
 package configmap
 
 import (
-	"encoding/json"
 	"reflect"
 
 	"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/reconcile/common"
@@ -38,20 +37,52 @@ const (
 	// ConfigDataKeyForAgent refers to the configuration file name of agent
 	ConfigDataKeyForAgent = "agent.yaml"
 
-	// AnnoClusterRepoConfig refers to the content of cluster repo config in server config
-	AnnoClusterRepoConfig = "computenode.shardingsphere.org/server-config-mode-cluster"
 	// AnnoClusterRepoConfig refers to the content of logback.xml
 	AnnoLogbackConfig = "computenode.shardingsphere.org/logback"
+
+	// DefaultLogback contains the default logback config
+	DefaultLogback = `<?xml version="1.0"?>
+<configuration>
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <appender name="sqlConsole" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{database}] [%X{user}] [%X{host}] %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    
+    <logger name="ShardingSphere-SQL" level="info" additivity="false">
+        <appender-ref ref="sqlConsole" />
+    </logger>
+    <logger name="org.apache.shardingsphere" level="info" additivity="false">
+        <appender-ref ref="console" />
+    </logger>
+    
+    <logger name="com.zaxxer.hikari" level="error" />
+    
+    <logger name="com.atomikos" level="error" />
+    
+    <logger name="io.netty" level="error" />
+    
+    <root>
+        <level value="info" />
+        <appender-ref ref="console" />
+    </root>
+</configuration> 
+`
+	// DefaultServerConfig contains the default server config
+	DefaultServerConfig = "# Empty file is needed"
 )
 
-// NewCNConfigMap returns a new ConfigMap
-func NewCNConfigMap(cn *v1alpha1.ComputeNode) *v1.ConfigMap {
+// NewConfigMap returns a new ConfigMap
+func NewConfigMap(cn *v1alpha1.ComputeNode) *v1.ConfigMap {
 	builder := NewConfigMapBuilder(cn.GetObjectMeta(), cn.GetObjectKind().GroupVersionKind())
 	builder.SetName(cn.Name).SetNamespace(cn.Namespace).SetLabels(cn.Labels).SetAnnotations(cn.Annotations)
 
-	cluster := cn.Annotations[AnnoClusterRepoConfig]
 	logback := cn.Annotations[AnnoLogbackConfig]
-
 	if len(logback) > 0 {
 		builder.SetLogback(logback)
 	} else {
@@ -61,13 +92,11 @@ func NewCNConfigMap(cn *v1alpha1.ComputeNode) *v1.ConfigMap {
 	// NOTE: ShardingSphere Proxy 5.3.0 needs a server.yaml no matter if it is empty
 	if !reflect.DeepEqual(cn.Spec.Bootstrap.ServerConfig, v1alpha1.ServerConfig{}) {
 		servconf := cn.Spec.Bootstrap.ServerConfig.DeepCopy()
-		if y, err := updateConfigMapServerConf(cluster, servconf, cn); err == nil {
-			builder.SetServerConfig(y)
-		} else {
-			return &v1.ConfigMap{}
+		if y, err := yaml.Marshal(servconf); err == nil {
+			builder.SetServerConfig(string(y))
 		}
 	} else {
-		builder.SetServerConfig("# Empty file is needed")
+		builder.SetServerConfig(DefaultServerConfig)
 	}
 
 	// load java agent config to configmap if needed
@@ -81,14 +110,16 @@ func NewCNConfigMap(cn *v1alpha1.ComputeNode) *v1.ConfigMap {
 	return builder.Build()
 }
 
-func updateConfigMapServerConf(cluster string, servconf *v1alpha1.ServerConfig, cn *v1alpha1.ComputeNode) (string, error) {
-	if cn.Spec.Bootstrap.ServerConfig.Mode.Type == v1alpha1.ModeTypeCluster && len(cluster) > 0 {
-		if err := json.Unmarshal([]byte(cluster), &servconf.Mode.Repository); err != nil {
-			return "", err
-		}
-	}
-	y, err := yaml.Marshal(servconf)
-	return string(y), err
+// TODO: check if changed first, then decide if need to respawn the Pods
+// UpdateConfigMap returns a new ConfigMap
+func UpdateConfigMap(cn *v1alpha1.ComputeNode, cur *v1.ConfigMap) *v1.ConfigMap {
+	exp := &v1.ConfigMap{}
+	exp.ObjectMeta = cur.ObjectMeta
+	exp.ObjectMeta.ResourceVersion = ""
+	exp.Labels = cur.Labels
+	exp.Annotations = cur.Annotations
+	exp.Data = NewConfigMap(cn).Data
+	return exp
 }
 
 // CNConfigMapBuilder is a builder for ConfigMap by ComputeNode
@@ -145,48 +176,3 @@ func DefaultConfigMap(meta metav1.Object, gvk schema.GroupVersionKind) *v1.Confi
 		Data: map[string]string{},
 	}
 }
-
-// FIXME: check if changed first, then decide if need to respawn the Pods
-func UpdateConfigMap(cn *v1alpha1.ComputeNode, cur *v1.ConfigMap) *v1.ConfigMap {
-	exp := &v1.ConfigMap{}
-	exp.ObjectMeta = cur.ObjectMeta
-	exp.ObjectMeta.ResourceVersion = ""
-	exp.Labels = cur.Labels
-	exp.Annotations = cur.Annotations
-	exp.Data = NewCNConfigMap(cn).Data
-	return exp
-}
-
-// DefaultLogback contains the default logback config
-const DefaultLogback = `<?xml version="1.0"?>
-<configuration>
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
-        </encoder>
-    </appender>
-    <appender name="sqlConsole" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{database}] [%X{user}] [%X{host}] %logger{36} - %msg%n</pattern>
-        </encoder>
-    </appender>
-    
-    <logger name="ShardingSphere-SQL" level="info" additivity="false">
-        <appender-ref ref="sqlConsole" />
-    </logger>
-    <logger name="org.apache.shardingsphere" level="info" additivity="false">
-        <appender-ref ref="console" />
-    </logger>
-    
-    <logger name="com.zaxxer.hikari" level="error" />
-    
-    <logger name="com.atomikos" level="error" />
-    
-    <logger name="io.netty" level="error" />
-    
-    <root>
-        <level value="info" />
-        <appender-ref ref="console" />
-    </root>
-</configuration> 
-`
diff --git a/shardingsphere-operator/pkg/kubernetes/configmap/configmap.go b/shardingsphere-operator/pkg/kubernetes/configmap/configmap.go
index c48451d..79de803 100644
--- a/shardingsphere-operator/pkg/kubernetes/configmap/configmap.go
+++ b/shardingsphere-operator/pkg/kubernetes/configmap/configmap.go
@@ -21,13 +21,14 @@ import (
 	"context"
 
 	"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/api/v1alpha1"
+
 	corev1 "k8s.io/api/core/v1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/types"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 )
 
-// NewConfigMap creates a new ConfigMap
+// NewConfigMapClient returns a new ConfigMap client
 func NewConfigMapClient(c client.Client) ConfigMap {
 	return configmapClient{
 		builder: builder{},
@@ -104,5 +105,5 @@ type builder struct{}
 
 // Build returns a ConfigMap
 func (b builder) Build(ctx context.Context, cn *v1alpha1.ComputeNode) *corev1.ConfigMap {
-	return NewCNConfigMap(cn)
+	return NewConfigMap(cn)
 }
diff --git a/shardingsphere-operator/pkg/kubernetes/configmap/configmap_suite_test.go b/shardingsphere-operator/pkg/kubernetes/configmap/configmap_suite_test.go
index 75c70a3..595051b 100644
--- a/shardingsphere-operator/pkg/kubernetes/configmap/configmap_suite_test.go
+++ b/shardingsphere-operator/pkg/kubernetes/configmap/configmap_suite_test.go
@@ -28,6 +28,7 @@ import (
 	"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/configmap"
 	"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/deployment"
 	"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/service"
+
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
 	"k8s.io/client-go/kubernetes/scheme"
diff --git a/shardingsphere-operator/pkg/kubernetes/configmap/configmap_test.go b/shardingsphere-operator/pkg/kubernetes/configmap/configmap_test.go
index 994816a..80415eb 100644
--- a/shardingsphere-operator/pkg/kubernetes/configmap/configmap_test.go
+++ b/shardingsphere-operator/pkg/kubernetes/configmap/configmap_test.go
@@ -18,15 +18,20 @@
 package configmap_test
 
 import (
+	"context"
+	"fmt"
+
 	"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/api/v1alpha1"
 	"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/configmap"
+	"gopkg.in/yaml.v2"
+
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
-var _ = Describe("ConfigMap", func() {
+var _ = Describe("Default ConfigMap", func() {
 	var (
 		expect = &corev1.ConfigMap{}
 		cn     = &v1alpha1.ComputeNode{
@@ -36,10 +41,6 @@ var _ = Describe("ConfigMap", func() {
 				Labels: map[string]string{
 					"test_key": "test_value",
 				},
-				Annotations: map[string]string{
-					configmap.AnnoLogbackConfig:     "test_logback",
-					configmap.AnnoClusterRepoConfig: "test_cluster_repo_config",
-				},
 			},
 		}
 	)
@@ -51,12 +52,15 @@ var _ = Describe("ConfigMap", func() {
 			"test_key": "test_value",
 		}
 		expect.Data = map[string]string{}
-		expect.Data[configmap.ConfigDataKeyForLogback] = "test_logback"
-		expect.Data[configmap.ConfigDataKeyForServer] = "test_cluster_repo_config"
+		expect.Data[configmap.ConfigDataKeyForLogback] = configmap.DefaultLogback
+		expect.Data[configmap.ConfigDataKeyForServer] = configmap.DefaultServerConfig
+		expect.Data[configmap.ConfigDataKeyForAgent] = ""
 	})
 
 	Context("Assert ObjectMeta", func() {
-		cm := configmap.NewCNConfigMap(cn)
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+
 		It("name should be equal", func() {
 			Expect(expect.Name).To(Equal(cm.Name))
 		})
@@ -69,12 +73,344 @@ var _ = Describe("ConfigMap", func() {
 	})
 
 	Context("Assert Default Spec Data", func() {
-		cm := configmap.NewCNConfigMap(cn)
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+
+		It("default server config should be equal", func() {
+			Expect(expect.Data[configmap.ConfigDataKeyForServer]).To(Equal(cm.Data[configmap.ConfigDataKeyForServer]))
+		})
+		It("default logback should be equal", func() {
+			Expect(expect.Data[configmap.ConfigDataKeyForLogback]).To(Equal(cm.Data[configmap.ConfigDataKeyForLogback]))
+		})
+		It("default agent config should be equal", func() {
+			Expect(expect.Data[configmap.ConfigDataKeyForAgent]).To(Equal(cm.Data[configmap.ConfigDataKeyForAgent]))
+		})
+	})
+
+	Context("Assert Update Spec Data", func() {
+		cn.Spec.Bootstrap = v1alpha1.BootstrapConfig{
+			ServerConfig: v1alpha1.ServerConfig{
+				Authority: v1alpha1.ComputeNodeAuthority{
+					Users: []v1alpha1.ComputeNodeUser{
+						{
+							User:     "test_user@%",
+							Password: "test_password",
+						},
+					},
+					Privilege: v1alpha1.ComputeNodePrivilege{
+						Type: v1alpha1.AllPermitted,
+					},
+				},
+				Mode: v1alpha1.ComputeNodeServerMode{
+					Type: v1alpha1.ModeTypeCluster,
+					Repository: v1alpha1.Repository{
+						Type: v1alpha1.RepositoryTypeZookeeper,
+						Props: v1alpha1.Properties{
+							"test_repo_key": "test_repo_value",
+						},
+					},
+				},
+				Props: v1alpha1.Properties{
+					"test_prop_key": "test_prop_value",
+				},
+			},
+		}
+
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+		cm = configmap.UpdateConfigMap(cn, cm)
+		cfg := &v1alpha1.ServerConfig{}
+		err := yaml.Unmarshal([]byte(cm.Data[configmap.ConfigDataKeyForServer]), &cfg)
+		if err != nil {
+			fmt.Printf("Err: %s\n", err)
+		}
+
+		It("server config should be equal", func() {
+			Expect(cfg.Authority).To(Equal(cn.Spec.Bootstrap.ServerConfig.Authority))
+			Expect(cfg.Mode).To(Equal(cn.Spec.Bootstrap.ServerConfig.Mode))
+			Expect(cfg.Props).To(Equal(cn.Spec.Bootstrap.ServerConfig.Props))
+		})
 		It("default logback should be equal", func() {
-			Expect(expect.Data[configmap.AnnoLogbackConfig]).To(Equal(cm.Data[configmap.AnnoLogbackConfig]))
+			Expect(expect.Data[configmap.ConfigDataKeyForLogback]).To(Equal(cm.Data[configmap.ConfigDataKeyForLogback]))
+		})
+		It("default agent config should be equal", func() {
+			Expect(expect.Data[configmap.ConfigDataKeyForAgent]).To(Equal(cm.Data[configmap.ConfigDataKeyForAgent]))
+		})
+	})
+})
+
+var _ = Describe("Standalone Server Config", func() {
+	Context("Assert Simple Service Config Data", func() {
+		cn := &v1alpha1.ComputeNode{
+			Spec: v1alpha1.ComputeNodeSpec{
+				Bootstrap: v1alpha1.BootstrapConfig{
+					ServerConfig: v1alpha1.ServerConfig{
+						Mode: v1alpha1.ComputeNodeServerMode{
+							Type: v1alpha1.ModeTypeStandalone,
+						},
+					},
+				},
+			},
+		}
+
+		expect := &v1alpha1.ServerConfig{}
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+		err := yaml.Unmarshal([]byte(cm.Data[configmap.ConfigDataKeyForServer]), &expect)
+		if err != nil {
+			fmt.Printf("Err: %s\n", err)
+		}
+
+		It("server config authority should be equal", func() {
+			Expect(expect.Authority).To(Equal(cn.Spec.Bootstrap.ServerConfig.Authority))
+		})
+		It("server config mode should be equal", func() {
+			Expect(expect.Mode).To(Equal(cn.Spec.Bootstrap.ServerConfig.Mode))
+		})
+		It("server config props should be equal", func() {
+			Expect(expect.Props).To(Equal(cn.Spec.Bootstrap.ServerConfig.Props))
+		})
+	})
+
+	Context("Assert Full Service Config Data", func() {
+		cn := &v1alpha1.ComputeNode{
+			Spec: v1alpha1.ComputeNodeSpec{
+				Bootstrap: v1alpha1.BootstrapConfig{
+					ServerConfig: v1alpha1.ServerConfig{
+						Authority: v1alpha1.ComputeNodeAuthority{
+							Users: []v1alpha1.ComputeNodeUser{
+								{
+									User:     "test_user@%",
+									Password: "test_password",
+								},
+							},
+							Privilege: v1alpha1.ComputeNodePrivilege{
+								Type: v1alpha1.AllPermitted,
+							},
+						},
+						Mode: v1alpha1.ComputeNodeServerMode{
+							Type: v1alpha1.ModeTypeStandalone,
+						},
+						Props: v1alpha1.Properties{
+							"test_prop_key": "test_prop_value",
+						},
+					},
+				},
+			},
+		}
+
+		expect := &v1alpha1.ServerConfig{}
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+		err := yaml.Unmarshal([]byte(cm.Data[configmap.ConfigDataKeyForServer]), &expect)
+		if err != nil {
+			fmt.Printf("Err: %s\n", err)
+		}
+
+		It("server config authority should be equal", func() {
+			Expect(expect.Authority).To(Equal(cn.Spec.Bootstrap.ServerConfig.Authority))
+		})
+		It("server config mode should be equal", func() {
+			Expect(expect.Mode).To(Equal(cn.Spec.Bootstrap.ServerConfig.Mode))
+		})
+		It("server config props should be equal", func() {
+			Expect(expect.Props).To(Equal(cn.Spec.Bootstrap.ServerConfig.Props))
+		})
+	})
+})
+
+var _ = Describe("Cluster Server Config", func() {
+	var (
+		expect = &v1alpha1.ServerConfig{}
+		cn     = &v1alpha1.ComputeNode{
+			ObjectMeta: metav1.ObjectMeta{
+				Name:      "test_name",
+				Namespace: "test_namespace",
+				Labels: map[string]string{
+					"test_key": "test_value",
+				},
+			},
+			Spec: v1alpha1.ComputeNodeSpec{
+				Bootstrap: v1alpha1.BootstrapConfig{
+					ServerConfig: v1alpha1.ServerConfig{
+						Authority: v1alpha1.ComputeNodeAuthority{
+							Users: []v1alpha1.ComputeNodeUser{
+								{
+									User:     "test_user@%",
+									Password: "test_password",
+								},
+							},
+							Privilege: v1alpha1.ComputeNodePrivilege{
+								Type: v1alpha1.AllPermitted,
+							},
+						},
+						Mode: v1alpha1.ComputeNodeServerMode{
+							Type: v1alpha1.ModeTypeCluster,
+							Repository: v1alpha1.Repository{
+								Type: v1alpha1.RepositoryTypeZookeeper,
+								Props: v1alpha1.Properties{
+									"test_repo_key": "test_repo_value",
+								},
+							},
+						},
+						Props: v1alpha1.Properties{
+							"test_prop_key": "test_prop_value",
+						},
+					},
+				},
+			},
+		}
+	)
+
+	BeforeEach(func() {
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+
+		err := yaml.Unmarshal([]byte(cm.Data[configmap.ConfigDataKeyForServer]), &expect)
+		if err != nil {
+			fmt.Printf("Err: %s\n", err)
+		}
+	})
+
+	Context("Assert Service Config Data", func() {
+		It("server config authority should be equal", func() {
+			Expect(expect.Authority).To(Equal(cn.Spec.Bootstrap.ServerConfig.Authority))
+		})
+		It("server config mode should be equal", func() {
+			Expect(expect.Mode).To(Equal(cn.Spec.Bootstrap.ServerConfig.Mode))
+		})
+		It("server config props should be equal", func() {
+			Expect(expect.Props).To(Equal(cn.Spec.Bootstrap.ServerConfig.Props))
+		})
+	})
+})
+
+var _ = Describe("Logback Config", func() {
+	Context("Assert Logback Config Data From Annotations", func() {
+		var (
+			expect = ""
+			cn     = &v1alpha1.ComputeNode{
+				ObjectMeta: metav1.ObjectMeta{
+					Annotations: map[string]string{
+						configmap.AnnoLogbackConfig: "test_logback_value",
+					},
+				},
+				Spec: v1alpha1.ComputeNodeSpec{
+					Bootstrap: v1alpha1.BootstrapConfig{
+						LogbackConfig: configmap.DefaultLogback,
+					},
+				},
+			}
+		)
+
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+		expect = "test_logback_value"
+
+		It("Logback config should be equal", func() {
+			Expect(expect).To(Equal(cm.Data[configmap.ConfigDataKeyForLogback]))
+		})
+	})
+
+	Context("Assert Logback Config Data", func() {
+		var (
+			expect = ""
+			cn     = &v1alpha1.ComputeNode{
+				ObjectMeta: metav1.ObjectMeta{
+					Name:      "test_name",
+					Namespace: "test_namespace",
+					Labels: map[string]string{
+						"test_key": "test_value",
+					},
+				},
+				Spec: v1alpha1.ComputeNodeSpec{
+					Bootstrap: v1alpha1.BootstrapConfig{
+						LogbackConfig: configmap.DefaultLogback,
+					},
+				},
+			}
+		)
+
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+		expect = configmap.DefaultLogback
+
+		It("Logback config should be equal", func() {
+			Expect(expect).To(Equal(cm.Data[configmap.ConfigDataKeyForLogback]))
+		})
+	})
+})
+
+var _ = Describe("Agent Config", func() {
+	Context("Assert Full Agent Config Data", func() {
+		var (
+			expect = &v1alpha1.AgentConfig{}
+			cn     = &v1alpha1.ComputeNode{
+				ObjectMeta: metav1.ObjectMeta{
+					Name:      "test_name",
+					Namespace: "test_namespace",
+					Labels: map[string]string{
+						"test_key": "test_value",
+					},
+				},
+				Spec: v1alpha1.ComputeNodeSpec{
+					Bootstrap: v1alpha1.BootstrapConfig{
+						AgentConfig: v1alpha1.AgentConfig{
+							Plugins: v1alpha1.AgentPlugin{
+								Logging: &v1alpha1.PluginLogging{
+									File: v1alpha1.LoggingFile{
+										Props: v1alpha1.Properties{
+											"test_logging_key": "test_logging_value",
+										},
+									},
+								},
+								Metrics: &v1alpha1.PluginMetrics{
+									Prometheus: v1alpha1.Prometheus{
+										Host: "test_host",
+										Port: 1234,
+										Props: v1alpha1.Properties{
+											"test_metrics_key": "test_metrics_value",
+										},
+									},
+								},
+								Tracing: &v1alpha1.PluginTracing{
+									OpenTracing: v1alpha1.OpenTracing{
+										Props: v1alpha1.Properties{
+											"test_opentracing_key": "test_opentracing_value",
+										},
+									},
+									OpenTelemetry: v1alpha1.OpenTelemetry{
+										Props: v1alpha1.Properties{
+											"test_opentelemetry_key": "test_opentelemetry_value",
+										},
+									},
+								},
+							},
+						},
+					},
+				},
+			}
+		)
+
+		c := configmap.NewConfigMapClient(nil)
+		cm := c.Build(context.TODO(), cn)
+
+		err := yaml.Unmarshal([]byte(cm.Data[configmap.ConfigDataKeyForAgent]), &expect)
+		if err != nil {
+			fmt.Printf("Err: %s\n", err)
+		}
+
+		It("agent config plugins should be equal", func() {
+			Expect(expect.Plugins).To(Equal(cn.Spec.Bootstrap.AgentConfig.Plugins))
+		})
+		It("agent config logging should be equal", func() {
+			Expect(expect.Plugins.Logging).To(Equal(cn.Spec.Bootstrap.AgentConfig.Plugins.Logging))
+		})
+		It("agent config metrics should be equal", func() {
+			Expect(expect.Plugins.Metrics).To(Equal(cn.Spec.Bootstrap.AgentConfig.Plugins.Metrics))
 		})
-		It("default cluster repo config should be equal", func() {
-			Expect(expect.Data[configmap.AnnoClusterRepoConfig]).To(Equal(cm.Data[configmap.AnnoClusterRepoConfig]))
+		It("agent config tracing should be equal", func() {
+			Expect(expect.Plugins.Tracing).To(Equal(cn.Spec.Bootstrap.AgentConfig.Plugins.Tracing))
 		})
 	})
 })
diff --git a/shardingsphere-operator/pkg/kubernetes/deployment/builder.go b/shardingsphere-operator/pkg/kubernetes/deployment/builder.go
index b71ae6f..3253ca0 100644
--- a/shardingsphere-operator/pkg/kubernetes/deployment/builder.go
+++ b/shardingsphere-operator/pkg/kubernetes/deployment/builder.go
@@ -450,13 +450,17 @@ func NewDeployment(cn *v1alpha1.ComputeNode) *appsv1.Deployment {
 }
 
 func setProbes(scb common.ContainerBuilder, cn *v1alpha1.ComputeNode) {
-	if cn.Spec.Probes != nil && cn.Spec.Probes.LivenessProbe != nil {
+	if cn.Spec.Probes == nil {
+		return
+	}
+
+	if cn.Spec.Probes.LivenessProbe != nil {
 		scb.SetLivenessProbe(cn.Spec.Probes.LivenessProbe)
 	}
-	if cn.Spec.Probes != nil && cn.Spec.Probes.ReadinessProbe != nil {
+	if cn.Spec.Probes.ReadinessProbe != nil {
 		scb.SetReadinessProbe(cn.Spec.Probes.ReadinessProbe)
 	}
-	if cn.Spec.Probes != nil && cn.Spec.Probes.StartupProbe != nil {
+	if cn.Spec.Probes.StartupProbe != nil {
 		scb.SetStartupProbe(cn.Spec.Probes.StartupProbe)
 	}
 }
@@ -603,16 +607,3 @@ func DefaultDeployment(meta metav1.Object, gvk schema.GroupVersionKind) *appsv1.
 		},
 	}
 }
-
-// UpdateDeployment updates the deployment
-/*
-func UpdateDeployment(cn *v1alpha1.ComputeNode, cur *appsv1.Deployment) *appsv1.Deployment {
-	exp := &appsv1.Deployment{}
-	exp.ObjectMeta = cur.ObjectMeta
-	exp.ObjectMeta.ResourceVersion = ""
-	exp.Labels = cur.Labels
-	exp.Annotations = cur.Annotations
-	exp.Spec = NewDeployment(cn).Spec
-	return exp
-}
-*/