From 37808e230ef88e6c46605303200e7c3a244d7fc3 Mon Sep 17 00:00:00 2001 From: acekingke Date: Thu, 21 Jul 2022 13:04:42 +0800 Subject: [PATCH] feat(singleNode): Support running single node. #361 --- api/v1alpha1/mysqlcluster_types.go | 2 +- .../crds/mysql.radondb.com_mysqlclusters.yaml | 1 + config/crd/bases/mysql.radondb.com_mysqlclusters.yaml | 1 + mysqlcluster/container/xenon.go | 6 +++++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/mysqlcluster_types.go b/api/v1alpha1/mysqlcluster_types.go index 932a7e467..26821755c 100644 --- a/api/v1alpha1/mysqlcluster_types.go +++ b/api/v1alpha1/mysqlcluster_types.go @@ -31,7 +31,7 @@ type MysqlClusterSpec struct { // Replicas is the number of pods. // +optional - // +kubebuilder:validation:Enum=0;2;3;5 + // +kubebuilder:validation:Enum=0;1;2;3;5 // +kubebuilder:default:=3 Replicas *int32 `json:"replicas,omitempty"` diff --git a/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml b/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml index 88d891c56..2472051bd 100644 --- a/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml +++ b/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml @@ -1259,6 +1259,7 @@ spec: description: Replicas is the number of pods. enum: - 0 + - 1 - 2 - 3 - 5 diff --git a/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml b/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml index 88d891c56..2472051bd 100644 --- a/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml +++ b/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml @@ -1259,6 +1259,7 @@ spec: description: Replicas is the number of pods. enum: - 0 + - 1 - 2 - 3 - 5 diff --git a/mysqlcluster/container/xenon.go b/mysqlcluster/container/xenon.go index 37f520c50..b42d1a6e4 100644 --- a/mysqlcluster/container/xenon.go +++ b/mysqlcluster/container/xenon.go @@ -43,7 +43,11 @@ func (c *xenon) getImage() string { // getCommand get the container command. func (c *xenon) getCommand() []string { - return nil + if *c.Spec.Replicas == 1 { + return []string{"xenon", "-c", "/etc/xenon/xenon.json", "-r", "LEADER"} + } + // If return nil, statefulset never update command , And I don't know why. + return []string{"xenon", "-c", "/etc/xenon/xenon.json"} } // getEnvVars get the container env.