1、 命名空间

k create ns ti
k create namespace tidb-admin
k create namespace tidb-cluster
alias k='kubectl'
alias ti='k -n tidb'
alias tia='k -n tidb-admin'
alias tic='k -n tidb-cluster'

2、 Helm安装 tidb-operator

helm repo add pingcap https://charts.pingcap.org/
helm repo update
helm repo list
helm install --namespace tidb-admin tidb-operator pingcap/tidb-operator --version v1.4.4
tic api-resources | grep pingcap
statefulsets                       asts           apps.pingcap.com               true         StatefulSet
backups                            bk             pingcap.com                    true         Backup
backupschedules                    bks            pingcap.com                    true         BackupSchedule
restores                           rt             pingcap.com                    true         Restore
tidbclusterautoscalers             ta             pingcap.com                    true         TidbClusterAutoScaler
tidbclusters                       tc             pingcap.com                    true         TidbCluster
tidbinitializers                   ti             pingcap.com                    true         TidbInitializer
tidbmonitors                       tm             pingcap.com                    true         TidbMonitor

似乎缺少了TidbDashboard!

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

customresourcedefinition.apiextensions.k8s.io/backupschedules.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/backups.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/dmclusters.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/restores.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/tidbclusterautoscalers.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/tidbclusters.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/tidbdashboards.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/tidbinitializers.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/tidbmonitors.pingcap.com created
customresourcedefinition.apiextensions.k8s.io/tidbngmonitorings.pingcap.com created
ti api-resources | grep ping
backups                            bk             pingcap.com/v1alpha1                 true         Backup
backupschedules                    bks            pingcap.com/v1alpha1                 true         BackupSchedule
dmclusters                         dc             pingcap.com/v1alpha1                 true         DMCluster
restores                           rt             pingcap.com/v1alpha1                 true         Restore
tidbclusterautoscalers             ta             pingcap.com/v1alpha1                 true         TidbClusterAutoScaler
tidbclusters                       tc             pingcap.com/v1alpha1                 true         TidbCluster
tidbdashboards                     td             pingcap.com/v1alpha1                 true         TidbDashboard
tidbinitializers                   ti             pingcap.com/v1alpha1                 true         TidbInitializer
tidbmonitors                       tm             pingcap.com/v1alpha1                 true         TidbMonitor
tidbngmonitorings                  tngm           pingcap.com/v1alpha1                 true         TidbNGMonitoring

在这里插入图片描述
在这里插入图片描述

TiDB Operator Architecture

3、安装 TiDB Cluster

问题1:storageClassName
csi-localpv

问题2:Failed to pull image “k8s.gcr.io/kube-scheduler:v1.18.17”
k8smaster.qfusion.irds/irds/kube-scheduler:v1.18.17

在这里插入图片描述

在这里插入图片描述

apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
  name: dba
  namespace: tidb-cluster
spec:
  # ** Basic Configuration **
  #   # TiDB cluster version
  version: v6.5.0
  # Time zone of TiDB cluster Pods
  timezone: UTC
  configUpdateStrategy: RollingUpdate
  hostNetwork: false
  imagePullPolicy: IfNotPresent
  enableDynamicConfiguration: true
  pd:
    baseImage: pingcap/pd
    replicas: 1
    requests:
      cpu: "50m"
      memory: 50Mi
      storage: 50Mi
    limits:
      cpu: "6000m"
      memory: 20Gi
    config: |
      lease = 3
      enable-prevote = true
    storageClassName: "csi-localpv"
    mountClusterClientSecret: true
    
  tidb:
    baseImage: pingcap/tidb
    config: |
      split-table = true
      oom-action = "log"
    replicas: 1
    requests:
      cpu: "50m"
      memory: 50Mi
      storage: 10Gi
    limits:
      cpu: "8000m"
      memory: 40Gi
    storageClassName: "csi-localpv"
    service:
      type: NodePort
      mysqlNodePort: 30002
      statusNodePort: 30080


  tikv:
    baseImage: pingcap/tikv
    config: |
      [storage]
        [storage.block-cache]
          capacity = "32GB"
    replicas: 3
    requests:
      cpu: "50m"
      memory: 50Mi
      storage: 100Gi
    limits:
      cpu: "12000m"
      memory: 40Gi
    storageClassName: "csi-localpv"
    mountClusterClientSecret: true
  enablePVReclaim: false
  pvReclaimPolicy: Delete

  tlsCluster: {}

4、访问

kubectl port-forward -n tidb-cluster svc/dba-tidb 14000:4000 > pf14000.out &
mysql --comments -h 127.0.0.1 -P 14000 -u root
select tidb_version()\G

在这里插入图片描述

5、TiDB Dashboard

apiVersion: pingcap.com/v1alpha1
kind: TidbDashboard
metadata:
  name: basic
spec:
  baseImage: pingcap/tidb-dashboard
  version: latest

  ## tidb cluster to be monitored
  ## ** now only support monitoring one tidb cluster **
  clusters:
    - name: dba

  ## describes the compute resource requirements and limits.
  ## Ref: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

  requests:
      storage: 10Gi
  storageClassName: "csi-localpv"

密码是TiDB的root密码,默认是“空”
在这里插入图片描述

参考文档

TiDB Operator部署TiDB集群的监控与告警

Deploy TiDB Operator on Kubernetes

Get Started with TiDB Operator on Kubernetes

Helm

Advanced StatefulSet Controller

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐