Using TiKV Operator

Get started using TiKV Operator

This document explains how to deploy a basic TiKV Cluster using TiKV Operator. TiKV Operator is a Kubernetes Operator that aims to automate the deployment, management, and operational tasks of TiKV clusters.

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 locally. Choose whichever that 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, following the steps below:

    a. Add the PingCAP Repository:

    helm repo add pingcap

    b. Create a namespace for TiKV Operator:

    kubectl create ns tikv-operator

    c. Install TiKV Operator:

    helm install --namespace tikv-operator tikv-operator pingcap/tikv-operator --version v0.1.0

    d. 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 the cluster 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