1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

minikubeでTiDBを運用してみたい

Posted at

minikube start --kubernetes-version=v1.31.4 --nodes 4 --driver docker

minikubeが動いているという前提です。

もしまだminikubeをインストールしてないなら
https://qiita.com/gabakugik/items/fd9ea540a1ce93bd855a
参照

カスタムリソースをインストール後helm updateしてtidb-operatorをインストール

kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.6.1/manifests/crd.yaml

helm repo add pingcap https://charts.pingcap.org/

helm repo update

kubectl create namespace tidb-admin

helm install tidb-operator pingcap/tidb-operator --version v1.6.1 --namespace tidb-admin

これで構築できます

次にtidb-sample-cluster.yamlを作ります

tidb-sample-cluster.yaml
apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
  name: tidb-sample
spec:
  version: v8.5.0
  # version: v8.5.1
  timezone: UTC
  pd:
    baseImage: pingcap/pd
    replicas: 1
    # replicas: 3
    requests:
      storage: "1Gi"
    config: {}
  tikv:
    baseImage: pingcap/tikv
    replicas: 1
    # replicas: 3
    requests:
      storage: "1Gi"
    config: {}
    # fix issue https://github.com/pingcap/tidb-operator/issues/5372
    env:
      - name: GRPC_DNS_RESOLVER
        value: native
  tidb:
    baseImage: pingcap/tidb
    replicas: 1
    # replicas: 3
    service:
      type: ClusterIP
      # type: LoadBalancer
      # type: NodePort
    config: {}
    # config: |
    #   graceful-wait-before-shutdown = 30
    # requests:
    #   cpu: 1000m
    #   memory: 256Mi
  # tiproxy:
  #   version: v1.3.0
  #   replicas: 2
  #   config: {}
  # tiflash:
  #   replicas: 1
  #   config: {}
  #   storageClaims:
  #     - resources:
  #         requests:
  #           storage: 10Gi
  #       storageClassName: standard

これを

kubectl apply -f tidb-sample-cluster.yaml

します。

kubectl get pod

下記3つがでてくればOK

NAME               READY   AGE
tidb-sample-pd     1/1     8m19s
tidb-sample-tidb   2/2     7m28s
tidb-sample-tikv   1/1     7m58s

tidb接続してみる(mysql)

kubectl run mysql-client --image=mysql8.0 -it --rm --restart=Never --/bin/bash

mysql --user root --host tidb-sample-tidb --port 4000

で接続

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?