Skip to content

Commit

Permalink
start tidb-server with
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxGit committed Mar 4, 2020
1 parent 596d10d commit a662543
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions charts/tidb-cluster/templates/scripts/_start_tidb.sh.tpl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ then
tail -f /dev/null
fi

# Use HOSTNAME if POD_NAME is unset for backward compatibility.
POD_NAME=${POD_NAME:-$HOSTNAME}
ARGS="--store=tikv \
--advertise-address=${POD_NAME}.${HEADLESS_SERVICE_NAME}.${NAMESPACE}.svc \
--host=0.0.0.0 \
--path=${CLUSTER_NAME}-pd:2379 \
--config=/etc/tidb/tidb.toml
Expand Down
3 changes: 3 additions & 0 deletions pkg/manager/member/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ then
tail -f /dev/null
fi
# Use HOSTNAME if POD_NAME is unset for backward compatibility.
POD_NAME=${POD_NAME:-$HOSTNAME}
ARGS="--store=tikv \
--advertise-address=${POD_NAME}.${HEADLESS_SERVICE_NAME}.${NAMESPACE}.svc \
--host=0.0.0.0 \
--path=${CLUSTER_NAME}-pd:2379 \
--config=/etc/tidb/tidb.toml
Expand Down
21 changes: 21 additions & 0 deletions pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ func getNewTiDBHeadlessServiceForTidbCluster(tc *v1alpha1.TidbCluster) *corev1.S
func getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbCluster, cm *corev1.ConfigMap) *apps.StatefulSet {
ns := tc.GetNamespace()
tcName := tc.GetName()
headlessSvcName := controller.TiDBPeerMemberName(tcName)
baseTiDBSpec := tc.BaseTiDBSpec()
instanceName := tc.GetInstanceName()
tidbConfigMap := controller.MemberConfigMapName(tc, v1alpha1.TiDBMemberType)
Expand Down Expand Up @@ -712,10 +713,30 @@ func getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbCluster, cm *corev1.ConfigMap)
slowLogFileEnvVal = slowQueryLogFile
}
envs := []corev1.EnvVar{
{
Name: "NAMESPACE",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
},
{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
},
},
{
Name: "CLUSTER_NAME",
Value: tc.GetName(),
},
{
Name: "HEADLESS_SERVICE_NAME",
Value: headlessSvcName,
},
{
Name: "TZ",
Value: tc.Spec.Timezone,
Expand Down

0 comments on commit a662543

Please sign in to comment.