Skip to content

Commit

Permalink
feat(singleNode): Support running single node. radondb#361
Browse files Browse the repository at this point in the history
  • Loading branch information
acekingke committed Jul 21, 2022
1 parent 348dc2a commit 4cfb653
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,7 @@ spec:
description: Replicas is the number of pods.
enum:
- 0
- 1
- 2
- 3
- 5
Expand Down
1 change: 1 addition & 0 deletions config/crd/bases/mysql.radondb.com_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,7 @@ spec:
description: Replicas is the number of pods.
enum:
- 0
- 1
- 2
- 3
- 5
Expand Down
7 changes: 5 additions & 2 deletions mysqlcluster/container/xenon.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func (c *xenon) getImage() string {

// getCommand get the container command.
func (c *xenon) getCommand() []string {
if *c.Spec.Replicas == 1 {
return []string{"xenon", "-c", "/etc/xenon/xenon.json", "-r", "LEADER"}
}
return nil
}

Expand Down Expand Up @@ -86,7 +89,7 @@ func (c *xenon) getLifecycle() *corev1.Lifecycle {
Command: []string{
"/bin/bash",
"-c",
"/xenonchecker preStop",
"timeout 7 /xenonchecker preStop",
},
},
},
Expand All @@ -95,7 +98,7 @@ func (c *xenon) getLifecycle() *corev1.Lifecycle {
Command: []string{
"/bin/bash",
"-c",
"/xenonchecker postStart",
"timeout 7 /xenonchecker postStart",
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions sidecar/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ func (cfg *Config) buildXenonConf() []byte {
"semi-sync-degrade": true,
"purge-binlog-disabled": true,
"super-idle": false,
"leader-start-command": "/xenonchecker leaderStart",
"leader-stop-command": "/xenonchecker leaderStop"
"leader-start-command": "timeout 7 /xenonchecker leaderStart",
"leader-stop-command": "timeout 7 /xenonchecker leaderStop"
}
}
`, hostName, utils.XenonPort, hostName, utils.XenonPeerPort, cfg.ReplicationPassword, cfg.ReplicationUser,
Expand Down

0 comments on commit 4cfb653

Please sign in to comment.