Getting Started with TiKV Operator

Try with TiKV Operator

We are currently refactoring our documentation. Please excuse any problems you may find and report them here.

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

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.

  • Using kind (Kubernetes in Docker)
  • Using minikube (Kubernetes running locally in a VM)

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$(uname)-amd64
chmod +x ./kind
./kind create cluster

On Windows:

curl.exe -Lo kind-windows-amd64.exe
.\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
  1. Install helm

    curl | bash

    Refer to Helm Documentation for more installation alternatives.

  2. Install CRD

    kubectl apply -f
  3. Install tikv-operator

    1. Add the PingCAP Repository:

      helm repo add pingcap
    2. 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
    3. Install TiKV Operator:

      helm install --namespace tikv-operator tikv-operator pingcap/tikv-operator --version v0.1.0
    4. Confirm that the TiKV Operator components are running:

      kubectl --namespace tikv-operator get pods

Step 3: Deploy TiKV Cluster

  1. Deploy the TiKV Cluster:

    curl -LO
    kubectl apply -f tikv-cluster.yaml

    Expected output: created
  2. 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.

  3. 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
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