diff --git a/examples/auto-scale/README.md b/examples/auto-scale/README.md new file mode 100644 index 0000000000..c62cdab26e --- /dev/null +++ b/examples/auto-scale/README.md @@ -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 apply -f ./ +``` + +## Destroy + +```bash +> kubectl -n delete -f ./ +``` diff --git a/examples/extra/tidb-cluster-auto-scaler.yaml b/examples/auto-scale/tidb-cluster-auto-scaler.yaml similarity index 87% rename from examples/extra/tidb-cluster-auto-scaler.yaml rename to examples/auto-scale/tidb-cluster-auto-scaler.yaml index b85eb0a34e..7727b8e0f2 100644 --- a/examples/extra/tidb-cluster-auto-scaler.yaml +++ b/examples/auto-scale/tidb-cluster-auto-scaler.yaml @@ -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 diff --git a/examples/auto-scale/tidb-cluster.yaml b/examples/auto-scale/tidb-cluster.yaml new file mode 100644 index 0000000000..c80004d985 --- /dev/null +++ b/examples/auto-scale/tidb-cluster.yaml @@ -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: {} diff --git a/examples/auto-scale/tidb-monitor.yaml b/examples/auto-scale/tidb-monitor.yaml new file mode 100644 index 0000000000..c1c99bc95d --- /dev/null +++ b/examples/auto-scale/tidb-monitor.yaml @@ -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 diff --git a/examples/extra/README.md b/examples/initialize/README.md similarity index 73% rename from examples/extra/README.md rename to examples/initialize/README.md index 9535f71495..92cc86f7d2 100644 --- a/examples/extra/README.md +++ b/examples/initialize/README.md @@ -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 @@ -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 apply -f ./tidb-initializer.yaml +> kubectl -n 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 apply -f ./tidb-cluster-auto-scaler.yaml +initialize-demo-tidb-initializer-whzn7 0/1 Completed 0 57s ``` ## Destroy diff --git a/examples/initialize/tidb-cluster.yaml b/examples/initialize/tidb-cluster.yaml new file mode 100644 index 0000000000..1ec543ea72 --- /dev/null +++ b/examples/initialize/tidb-cluster.yaml @@ -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: {} diff --git a/examples/extra/tidb-initializer.yaml b/examples/initialize/tidb-initializer.yaml similarity index 80% rename from examples/extra/tidb-initializer.yaml rename to examples/initialize/tidb-initializer.yaml index 3dea65ee8c..d20ec961ae 100644 --- a/examples/extra/tidb-initializer.yaml +++ b/examples/initialize/tidb-initializer.yaml @@ -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"