Skip to content

Commit

Permalink
Merge branch 'master' into gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZhangQD authored Sep 27, 2019
2 parents 1d7b68c + c2d1ee2 commit e46b381
Show file tree
Hide file tree
Showing 26 changed files with 674 additions and 129 deletions.
2 changes: 1 addition & 1 deletion charts/tidb-cluster/templates/monitor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ spec:
- key: dashboard-config
path: dashboards.yaml
name: dashboards-provisioning
{{- end }}
- emptyDir: {}
name: prometheus-rules
- emptyDir: {}
name: grafana-dashboard
{{- end }}
{{- if .Values.monitor.tolerations }}
tolerations:
{{ toYaml .Values.monitor.tolerations | indent 6 }}
Expand Down
9 changes: 9 additions & 0 deletions charts/tidb-cluster/templates/tidb-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ spec:
hostNetwork: {{ .Values.pd.hostNetwork }}
podSecurityContext:
{{ toYaml .Values.pd.podSecurityContext | indent 6}}
{{- if .Values.pd.priorityClassName }}
priorityClassName: {{ .Values.pd.priorityClassName }}
{{- end }}
tikv:
replicas: {{ .Values.tikv.replicas }}
image: {{ .Values.tikv.image }}
Expand All @@ -75,6 +78,9 @@ spec:
hostNetwork: {{ .Values.tikv.hostNetwork }}
podSecurityContext:
{{ toYaml .Values.tikv.podSecurityContext | indent 6}}
{{- if .Values.tikv.priorityClassName }}
priorityClassName: {{ .Values.tikv.priorityClassName }}
{{- end }}
tidb:
replicas: {{ .Values.tidb.replicas }}
image: {{ .Values.tidb.image }}
Expand All @@ -97,6 +103,9 @@ spec:
hostNetwork: {{ .Values.tidb.hostNetwork }}
podSecurityContext:
{{ toYaml .Values.tidb.podSecurityContext | indent 6}}
{{- if .Values.tidb.priorityClassName }}
priorityClassName: {{ .Values.tidb.priorityClassName }}
{{- end }}
binlogEnabled: {{ .Values.binlog.pump.create | default false }}
maxFailoverCount: {{ .Values.tidb.maxFailoverCount | default 3 }}
separateSlowLog: {{ .Values.tidb.separateSlowLog | default false }}
Expand Down
19 changes: 17 additions & 2 deletions charts/tidb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ schedulerName: tidb-scheduler
# timezone is the default system timzone for TiDB
timezone: UTC

# default reclaim policy of a PV
# reclaim policy of a PV, default: Retain.
# you must set it to Retain to ensure data safety in production environment.
# https://pingcap.com/docs/v3.0/tidb-in-kubernetes/reference/configuration/local-pv/#data-security
pvReclaimPolicy: Retain

# services is the service list to expose, default is ClusterIP
Expand Down Expand Up @@ -167,6 +169,10 @@ pd:
# refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext: {}

# Specify the priorityClassName for PD Pod.
# refer to https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#how-to-use-priority-and-preemption
priorityClassName: ""

tikv:
# Please refer to https://github.com/tikv/tikv/blob/master/etc/config-template.toml for the default
# tikv configurations (change to the tags of your tikv version),
Expand Down Expand Up @@ -252,6 +258,10 @@ tikv:
# refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext: {}

# Specify the priorityClassName for TiKV Pod.
# refer to https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#how-to-use-priority-and-preemption
priorityClassName: ""

tidb:
# Please refer to https://github.com/pingcap/tidb/blob/master/config/config.toml.example for the default
# tidb configurations(change to the tags of your tidb version),
Expand Down Expand Up @@ -322,6 +332,10 @@ tidb:
# refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext: {}

# Specify the priorityClassName for TiDB Pod.
# refer to https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#how-to-use-priority-and-preemption
priorityClassName: ""

maxFailoverCount: 3
service:
type: NodePort
Expand Down Expand Up @@ -558,8 +572,9 @@ binlog:
# just follow the format in the file and configure in the 'config' section
# as below if you want to customize any configuration.
# config: |
# worker-count = 16
# detect-interval = 10
# [syncer]
# worker-count = 16
# disable-dispatch = false
# ignore-schemas = "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql"
# safe-mode = false
Expand Down
15 changes: 8 additions & 7 deletions deploy/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ module "vpc" {
module "tidb-operator" {
source = "../modules/aws/tidb-operator"

eks_name = var.eks_name
eks_version = var.eks_version
operator_version = var.operator_version
config_output_path = "credentials/"
subnets = local.subnets
vpc_id = module.vpc.vpc_id
ssh_key_name = module.key-pair.key_name
eks_name = var.eks_name
eks_version = var.eks_version
operator_version = var.operator_version
config_output_path = "credentials/"
subnets = local.subnets
vpc_id = module.vpc.vpc_id
ssh_key_name = module.key-pair.key_name
operator_helm_values = var.operator_values == "" ? "" : file(var.operator_values)
}

module "bastion" {
Expand Down
2 changes: 1 addition & 1 deletion deploy/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ variable "operator_version" {
}

variable "operator_values" {
description = "The helm values of TiDB Operator, it is recommended to use the 'file()' function call to read the content from a local file, e.g. 'file(\"my-cluster.yaml\")'"
description = "The helm values file for TiDB Operator, path is relative to current working dir"
default = ""
}

Expand Down
1 change: 1 addition & 0 deletions deploy/modules/aliyun/tidb-cluster/values/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tidb:
logLevel: info
service:
type: LoadBalancer
externalTrafficPolicy: Local
exposeStatus: true
annotations:
service.beta.kubernetes.io/alicloud-loadbalancer-address-type: intranet
Expand Down
1 change: 1 addition & 0 deletions deploy/modules/aws/tidb-cluster/values/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tikv:
tidb:
service:
type: LoadBalancer
externalTrafficPolicy: Local
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: '0.0.0.0/0'
service.beta.kubernetes.io/aws-load-balancer-type: nlb
Expand Down
1 change: 1 addition & 0 deletions deploy/modules/gcp/tidb-cluster/values/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tikv:
tidb:
service:
type: LoadBalancer
externalTrafficPolicy: Local
annotations:
cloud.google.com/load-balancer-type: "Internal"
separateSlowLog: true
Expand Down
122 changes: 122 additions & 0 deletions docs/benchmark-tidb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Benchmark TiDB

## Table Of Contents

- [Prerequisites](#prerequisites)
- [Sysbench](#sysbench)
* [Customize with kustomize](#customize-with-kustomize)
+ [More customizations](#more-customizations)
* [Prepare: Create test tables and insert test records](#prepare-create-test-tables-and-insert-test-records)
* [Warmup TiDB](#warmup-tidb)
* [Run benchmark](#run-benchmark)

## Prerequisites

You must run a TiDB cluster in your Kubernetes environment first. You can follow our
docs [here](https://pingcap.com/docs/v3.0/tidb-in-kubernetes/deploy/prerequisites/).

Please note that it's recommended to prepare a dedicated node to run your
benchmark tool, e.g. sysbench.

We also require [kustomize] to customize our manifest yaml files. You can
follow
[this](https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md)
to install latest kustomize on your machine.

## Sysbench

### Customize with kustomize

We assume you are working in the root of tidb-operator repo. If you don't have
a copy, you can run `git clone --depth=1 https://github.com/pingcap/tidb-operator`
to clone it onto your local machine.

Configure environments:

```
TIDB_HOST="<your-tidb-host>" # this can be tidb service name, pod ip or load balancer ip, etc.
```

Create `kustomization.yaml`:

```
mkdir -p sysbench/output
cat <<EOF > sysbench/kustomization.yaml
resources:
- ../manifests/sysbench
commonAnnotations:
tidb-host: $TIDB_HOST
EOF
```

Optionally, if you want to change tidb user, port, password or other
configurations you can customize them in `commonAnnotations` or `patches`
fields:

```
commonAnnotations:
tidb-password: "root"
patches:
- patch: |-
apiVersion: batch/v1
kind: Job
metadata:
name: sysbench-bench
spec:
template:
metadata:
annotations:
sysbench-threads: "100"
sysbench-test-name: oltp_read_write
```

Label the node to run sysbench:

```
kubectl label nodes <sysbench-node> dedicated=sysbench
```

Run `kustomize`:

```
kustomize build sysbench/ -o sysbench/output/
```

#### More customizations

Change sysbench image, here is an example:

```
patches:
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: your-sysbench-image
target:
kind: Job
```

### Prepare: Create test tables and insert test records

```
kubectl apply -f sysbench/output/*config.yaml
kubectl apply -f sysbench/output/*prepare.yaml
```

You can run `kubectl logs -l job-name=sysbench-prepare` to view logs.

### Warmup TiDB

```
kubectl apply -f sysbench/output/*warmup.yaml
```

You can run `kubectl logs -l job-name=sysbench-warmup` to view logs.

### Run benchmark

```
kubectl apply -f sysbench/output/*bench.yaml
```

You can run `kubectl logs -l job-name=sysbench-bench` to view logs.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/docker/go-units v0.3.3 // indirect
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dustin/go-humanize v1.0.0
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 // indirect
github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
Expand Down
83 changes: 83 additions & 0 deletions manifests/sysbench/bench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: batch/v1
kind: Job
metadata:
name: sysbench-bench
labels:
app: sysbench-bench
spec:
parallelism: 3
template:
metadata:
labels:
app: sysbench-bench
spec:
restartPolicy: Never
containers:
- name: sysbench
image: uhub.ucloud.cn/pingcap/sysbench:latest
env:
env:
- name: TABLE_COUNT
valueFrom:
fieldRef:
fieldPath: metadata.annotations['table-count']
- name: TABLE_SIZE
valueFrom:
fieldRef:
fieldPath: metadata.annotations['table-size']
- name: TIDB_HOST
valueFrom:
fieldRef:
fieldPath: metadata.annotations['tidb-host']
- name: TIDB_PORT
valueFrom:
fieldRef:
fieldPath: metadata.annotations['tidb-port']
- name: TIDB_USER
valueFrom:
fieldRef:
fieldPath: metadata.annotations['tidb-user']
- name: TIDB_PASSWORD
valueFrom:
fieldRef:
fieldPath: metadata.annotations['tidb-password']
- name: TIDB_DB
valueFrom:
fieldRef:
fieldPath: metadata.annotations['tidb-db']
- name: SYSBENCH_TIME
valueFrom:
fieldRef:
fieldPath: metadata.annotations['sysbench-time']
- name: SYSBENCH_THREADS
valueFrom:
fieldRef:
fieldPath: metadata.annotations['sysbench-threads']
- name: SYSBENCH_TEST_NAME
valueFrom:
fieldRef:
fieldPath: metadata.annotations['sysbench-test-name']
command:
- sysbench
- --config-file=/etc/sysbench/common.conf
- --mysql-host=$(TIDB_HOST)
- --mysql-port=$(TIDB_PORT)
- --mysql-user=$(TIDB_USER)
- --mysql-password=$(TIDB_PASSWORD)
- --mysql-db=$(TIDB_DB)
- --tables=$(TABLE_COUNT)
- --table-size=$(TABLE_SIZE)
- --time=$(SYSBENCH_TIME)
- --threads=$(SYSBENCH_THREADS)
- $(SYSBENCH_TEST_NAME)
- run
volumeMounts:
- name: config
mountPath: /etc/sysbench
volumes:
- name: config
configMap:
name: sysbench-config
items:
- key: common
path: common.conf
10 changes: 10 additions & 0 deletions manifests/sysbench/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: sysbench-config
data:
common: |
db-driver=mysql
rand-type=uniform
rand-seed=0
report-interval=10
Loading

0 comments on commit e46b381

Please sign in to comment.