Skip to content

Commit

Permalink
upgrade tidb version to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxin45 committed Aug 30, 2017
1 parent be101e3 commit d643790
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion kubernetes/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ REGISTRY=${REGISTRY-'10.209.224.13:10500/ffan/rds'}
VERSION=${VERSION:-'latest'}

# The volume of pod host path
DATA_VOLUME=${DATA_VOLUME:-'/data'}
DATA_VOLUME=${DATA_VOLUME:-'/mnt'}

# The prefix of pod mount path
MOUNT=${MOUNT:-''}
Expand Down
4 changes: 1 addition & 3 deletions kubernetes/pd-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ echo "Creating pd pod for $cell cell..."
for id in `seq 1 $replicas`; do
id=$(printf "%03d\n" $id)
sed_script=""
for var in namespace cell id replicas cpu mem version tidbdata_volume registry cluster; do
for var in namespace cell id replicas cpu mem version tidbdata_volume registry cluster c_state c_state; do
sed_script+="s,{{$var}},${!var},g;"
done
sed_script+="s,{{c-state}},${c_state},g;"
sed_script+="s,{{c-urls}},${c_urls},g;"
# cat pd-pod.yaml | sed -e "$sed_script"
cat pd-pod.yaml | sed -e "$sed_script" | $KUBECTL $KUBECTL_OPTIONS create -f -
done
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/tikv-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
containers:
- name: tikv
image: {{registry}}/tikv:{{version}}
imagePullPolicy: Always
resources:
# 初始化requests和limits相同的值,是为了防止memory超过requests时,node资源不足,导致该pod被重新安排到其它node
requests:
Expand Down Expand Up @@ -58,8 +59,8 @@ spec:
fi
/tikv-server \
--store="$data_dir" \
--capacity={{capacity}} \
--addr="0.0.0.0:20160" \
--capacity={{capacity}}GB \
--advertise-addr="$POD_IP:20160" \
--pd="pd-{{cell}}:2379" \
--config="/etc/tikv/config.toml"
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/tikv-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ registry=${REGISTRY}
DATA_VOLUME=${DATA_VOLUME:-''}
namespace=$NS

((capacity=$capacity*1024*1024*1024))
cell=`echo $CELL`
tidbdata_volume='emptyDir: {}'
if [ -n "$DATA_VOLUME" ]; then
tidbdata_volume="hostPath: {path: ${DATA_VOLUME}}"
fi
mount=''
mount='data'

for id in `seq 1 $replicas`; do
echo "Creating tikv pod $id for $cell cell..."
Expand Down
4 changes: 2 additions & 2 deletions operator/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ func (p *Pd) toJSONTemplate(temp string) ([]byte, error) {
"{{mem}}", fmt.Sprintf("%v", p.Spec.Mem),
"{{version}}", p.Spec.Version,
"{{registry}}", imageRegistry,
"{{c-state}}", state,
"{{c-urls}}", cluster,
"{{c_state}}", state,
"{{c_urls}}", cluster,
)
str := r.Replace(temp)
j, err := yaml.YAMLToJSON([]byte(str))
Expand Down
6 changes: 3 additions & 3 deletions operator/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
sleep 1
done
# pd will overwrite if join exist cluster
sed -i -e 's/"existing"/"{{c-state}}"/' /etc/pd/config.toml
sed -i -e 's/"existing"/"{{c_state}}"/' /etc/pd/config.toml
fi
urls=""
Expand All @@ -118,7 +118,7 @@ spec:
--advertise-client-urls="$advertise_client_urls" \
--peer-urls="$peer_urls" \
--advertise-peer-urls="$advertise_peer_urls" \
{{c-urls}} \
{{c_urls}} \
--config="/etc/pd/config.toml"
`

Expand Down Expand Up @@ -185,7 +185,7 @@ spec:
/tikv-server \
--store="$data_dir" \
--addr="0.0.0.0:20160" \
--capacity={{capacity}}GB \
--capacity={{capacity}} \
--advertise-addr="$POD_IP:20160" \
--pd="pd-{{cell}}:2379" \
--config="/etc/tikv/config.toml"
Expand Down
5 changes: 4 additions & 1 deletion operator/tikv.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (

const (
defaultTikvPort = 20160

// GB ~/pingcap/tikv/src/util/config.rs<GB>
GB = 1024 * 1024 * 1024
)

var (
Expand Down Expand Up @@ -139,7 +142,7 @@ func (tk *Tikv) toJSONTemplate(temp string) ([]byte, error) {
"{{version}}", tk.Spec.Version,
"{{cpu}}", fmt.Sprintf("%v", tk.Spec.CPU),
"{{mem}}", fmt.Sprintf("%v", tk.Spec.Mem),
"{{capacity}}", fmt.Sprintf("%v", tk.Spec.Capatity),
"{{capacity}}", fmt.Sprintf("%v", tk.Spec.Capatity*GB),
"{{tidbdata_volume}}", fmt.Sprintf("%v", tk.Spec.Volume),
"{{id}}", fmt.Sprintf("%03v", tk.Member),
"{{registry}}", imageRegistry,
Expand Down

0 comments on commit d643790

Please sign in to comment.