Getting Started with TiKV Operator
Try with TiKV Operator
This document explains how to create a simple Kubernetes cluster and use it to do a basic test deployment of TiKV Cluster using TiKV Operator.
- Step 1: Create a Kubernetes cluster
- Step 2: Deploy TiKV Operator
- Step 3: Deploy TiKV Cluster
- Step 4: Access the PD endpoint
Step 1: Create a Kubernetes cluster
If you have already created a Kubernetes cluster, skip to Step 2: Deploy TiKV Operator.
This section covers 2 different ways to create a simple Kubernetes cluster that can be used to test TiKV Cluster locally. Choose whichever best matches your environment or experience level.
You can refer to their official documents to prepare a Kubernetes cluster.
The following shows a simple way to create a Kubernetes cluster using kind. Make sure Docker is up and running before proceeding.
On macOS / Linux:
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-$(uname)-amd64
chmod +x ./kind
./kind create cluster
On Windows:
curl.exe -Lo kind-windows-amd64.exe https://kind.sigs.k8s.io/dl/v0.8.1/kind-windows-amd64
.\kind-windows-amd64.exe create cluster
Step 2: Deploy TiKV Operator
Before deployment, make sure the following requirements are satisfied:
- A running Kubernetes Cluster that kubectl can connect to
- Helm 3
Install helm
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
Refer to Helm Documentation for more installation alternatives.
Install CRD
kubectl apply -f https://raw.githubusercontent.com/tikv/tikv-operator/master/manifests/crd.v1beta1.yaml
Install tikv-operator
Add the PingCAP Repository:
helm repo add pingcap https://charts.pingcap.org/
Create a namespace for TiKV Operator:
kubectl create ns tikv-operator helm install --namespace tikv-operator tikv-operator pingcap/tikv-operator --version v0.1.0
Install TiKV Operator:
helm install --namespace tikv-operator tikv-operator pingcap/tikv-operator --version v0.1.0
Confirm that the TiKV Operator components are running:
kubectl --namespace tikv-operator get pods
Step 3: Deploy TiKV Cluster
Deploy the TiKV Cluster:
curl -LO https://raw.githubusercontent.com/tikv/tikv-operator/master/examples/basic/tikv-cluster.yaml kubectl apply -f tikv-cluster.yaml
Expected output:
tikvcluster.tikv.org/basic created
Wait for it to be ready:
kubectl wait --for=condition=Ready --timeout 10m tikvcluster/basic
It may takes several minutes as it needs to pull images from Docker Hub.
Check the progress with the following command:
kubect get pods -o wide
If the network connection to the Docker Hub is slow, you can try this example which uses images hosted in Alibaba Cloud:
curl -LO https://raw.githubusercontent.com/tikv/tikv-operator/master/examples/basic-cn/tikv-cluster.yaml
kubectl apply -f tikv-cluster.yaml
Step 4: Access the PD endpoint
Open a new terminal tab and run this command:
kubectl port-forward svc/basic-pd 2379:2379
This will forward local port 2379
to PD service basic-pd
.
Now, you can access the PD endpoint with pd-ctl
or any other PD client:
$ pd-ctl cluster
{
"id": 6841476120821315702,
"max_peer_count": 3
}