Skip to content

Commit

Permalink
revise examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Song Gao committed Mar 16, 2020
1 parent a5078a4 commit 881eea3
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 25 deletions.
33 changes: 33 additions & 0 deletions examples/auto-scale/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# The extra TiDB cluster Components

> **Note:**
>
> This setup is for test or demo purpose only and **IS NOT** applicable for critical environment. Refer to the [Documents](https://pingcap.com/docs/stable/tidb-in-kubernetes/deploy/prerequisites/) for production setup.

The following steps will create a TiDB cluster with monitoring and auto-scaler, the monitoring data is not persisted by default.

**Prerequisites**:
- Has TiDB operator `v1.1.0-beta.2` or higher version installed. [Doc](https://pingcap.com/docs/stable/tidb-in-kubernetes/deploy/tidb-operator/)


## Auto-scaling

> **Note:**
>
> The Auto-scaling feature is still in alpha, you should enable this feature in TiDB Operator by setting values.yaml:
```yaml
features:
AutoScaling=true
```
Auto-scale the cluster based on CPU load
```bash
> kubectl -n <namespace> apply -f ./
```

## Destroy

```bash
> kubectl -n <namespace> delete -f ./
```
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: pingcap.com/v1alpha1
kind: TidbClusterAutoScaler
metadata:
name: basic
name: auto-scaling-demo
spec:
cluster:
name: basic
name: auto-scaling-demo
monitor:
name: basic
name: auto-scaling-demo
tikv:
minReplicas: 3
maxReplicas: 4
Expand Down
26 changes: 26 additions & 0 deletions examples/auto-scale/tidb-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
name: auto-scaling-demo
spec:
version: v3.0.8
timezone: UTC
pvReclaimPolicy: Delete
pd:
baseImage: pingcap/pd
replicas: 1
requests:
storage: "1Gi"
config: {}
tikv:
baseImage: pingcap/tikv
replicas: 1
requests:
storage: "1Gi"
config: {}
tidb:
baseImage: pingcap/tidb
replicas: 1
service:
type: ClusterIP
config: {}
20 changes: 20 additions & 0 deletions examples/auto-scale/tidb-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: pingcap.com/v1alpha1
kind: TidbMonitor
metadata:
name: auto-scaling-demo
spec:
clusters:
- name: auto-scaling-demo
prometheus:
baseImage: prom/prometheus
version: v2.11.1
grafana:
baseImage: grafana/grafana
version: 6.0.1
initializer:
baseImage: pingcap/tidb-monitor-initializer
version: v3.0.5
reloader:
baseImage: pingcap/tidb-monitor-reloader
version: v1.0.1
imagePullPolicy: IfNotPresent
23 changes: 3 additions & 20 deletions examples/extra/README.md → examples/initialize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ The following steps will create a TiDB cluster with monitoring, the monitoring d

**Prerequisites**:
- Has TiDB operator `v1.1.0-beta.2` or higher version installed. [Doc](https://pingcap.com/docs/stable/tidb-in-kubernetes/deploy/tidb-operator/)
- Has Tidb Cluster has been installed in `../basic/*`


## Initialize


Expand All @@ -35,29 +34,13 @@ You can aloso create other users and set their password:
Initialize the cluster to create the users and create the database named `test`

```bash
> kubectl -n <namespace> apply -f ./tidb-initializer.yaml
> kubectl -n <namespace> apply -f ./
```

Wait for Initialize job done:
```bash
$ kubectl get pod | grep basic-tidb-initializer
basic-tidb-initializer-whzn7 0/1 Completed 0 57s
```


## Auto-scaling

> **Note:**
>
> The Auto-scaling feature is still in alpha, you should enable this feature in TiDB Operator by setting values.yaml:
```yaml
features:
AutoScaling=true
```
Auto-scale the cluster based on CPU load
```bash
> kubectl -n <namespace> apply -f ./tidb-cluster-auto-scaler.yaml
initialize-demo-tidb-initializer-whzn7 0/1 Completed 0 57s
```

## Destroy
Expand Down
26 changes: 26 additions & 0 deletions examples/initialize/tidb-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
name: initialize-demo
spec:
version: v3.0.8
timezone: UTC
pvReclaimPolicy: Delete
pd:
baseImage: pingcap/pd
replicas: 1
requests:
storage: "1Gi"
config: {}
tikv:
baseImage: pingcap/tikv
replicas: 1
requests:
storage: "1Gi"
config: {}
tidb:
baseImage: pingcap/tidb
replicas: 1
service:
type: ClusterIP
config: {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: pingcap.com/v1alpha1
kind: TidbInitializer
metadata:
name: basic
name: initialize-demo
spec:
image: tnir/mysqlclient
imagePullPolicy: IfNotPresent
cluster:
name: basic
name: initialize-demo
initSql: "create database hello;"
passwordSecret: "tidb-secret"

0 comments on commit 881eea3

Please sign in to comment.