k8s部署集群,apply yaml文件出错

[root@node01 tidb]# kubectl -n tidb-cluster apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/master/examples/basic/tidb-cluster.yaml

error: unable to recognize “https://raw.githubusercontent.com/pingcap/tidb-operator/master/examples/basic/tidb-cluster.yaml”: no matches for kind “TidbCluster” in version “pingcap.com/v1alpha1

Hi ,参考一下官网文档的部署方案再试试 https://docs.pingcap.com/tidb-in-kubernetes/stable/deploy-tidb-operator

如果还是不行,麻烦再反馈一下具体爹 yaml 文件配置

kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/master/manifests/crd.yaml
mkdir -p ${HOME}/tidb-operator &&
helm inspect values pingcap/tidb-operator --version=${chart_version} > ${HOME}/tidb-operator/values-tidb-operator.yaml
helm install tidb-operator pingcap/tidb-operator --namespace=tidb-admin --version=${chart_version} -f ${HOME}/tidb-operator/values-tidb-operator.yaml &&
kubectl get po -n tidb-admin -l app.kubernetes.io/name=tidb-operator
是执行kubectl -n tidb-cluster apply -f …的先决条件,是否执行了?

yaml文件按照https://github.com/pingcap/tidb-operator/blob/master/examples/advanced/tidb-cluster.yaml这个

https://raw.githubusercontent.com/pingcap/tidb-operator/master/examples/basic/tidb-cluster.yaml这个
都试过了,都是不行呢

tidb-operator已经安装了呀:
[root@node01 tidb]# kubectl get po -n tidb-admin -l app.kubernetes.io/name=tidb-operator
NAME READY STATUS RESTARTS AGE
tidb-controller-manager-64d789d965-9zhf6 1/1 Running 1 2d18h
tidb-scheduler-68d9c65d6d-n2f7p 2/2 Running 2 2d18h

麻烦提供一下 K8s 、tidb-operator 版本,提供一下复现的操作步骤。

k8s 1.18
tidb-operator v1.3.1
操作步骤正好记录了一下,都是按照官网来的,中间有个镜像拉不下来(k8s.gcr.io/kube-scheduler:v1.18.0),用阿里替代的:
部署 TiDB Operator:
helm repo add pingcap https://charts.pingcap.org/

创建crd:
kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/master/manifests/crd.yaml

在线部署 TiDB Operator:

mkdir -p ${HOME}/tidb-operator

helm inspect values pingcap/tidb-operator --version=v1.3.1 > ${HOME}/tidb-operator/values-tidb-operator.yaml

kubectl create namespace tidb-admin

目标机器上:
docker pull registry.aliyuncs.com/google_containers/kube-scheduler:v1.18.0
docker images
docker tag registry.aliyuncs.com/google_containers/kube-scheduler:v1.18.0 k8s.gcr.io/kube-scheduler:v1.18.0
docker rmi registry.aliyuncs.com/google_containers/kube-scheduler:v1.18.0

helm install tidb-operator pingcap/tidb-operator --namespace=tidb-admin --version=v1.3.1 -f ${HOME}/tidb-operator/values-tidb-operator.yaml
kubectl get po -n tidb-admin -l app.kubernetes.io/name=tidb-operator

部署tidb:
yaml文件:https://github.com/pingcap/tidb-operator/blob/master/examples/advanced/tidb-cluster.yaml

kubectl create -f tidb-cluster.yaml -n tidb-cluster

  1. kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/master/manifests/crd.yaml 这个有报错吗?现在 v1 版本 crd 太大,不能 apply,如果新建用 create,升级用 replace
  2. kubectl get crds 看一下输出

应该是没有报错。
输出:[root@k8s01 ~]# kubectl get crds
NAME CREATED AT
backups.pingcap.com 2022-03-04T07:07:13Z
backupschedules.pingcap.com 2022-03-04T07:07:13Z
dmclusters.pingcap.com 2022-03-04T07:07:14Z
restores.pingcap.com 2022-03-04T07:07:14Z
tidbclusterautoscalers.pingcap.com 2022-03-04T07:07:14Z
tidbclusters.pingcap.com 2022-03-04T07:07:14Z
tidbinitializers.pingcap.com 2022-03-04T07:07:15Z
tidbmonitors.pingcap.com 2022-03-04T07:07:15Z
tidbngmonitorings.pingcap.com 2022-03-04T07:07:16Z

现在执行这个还报错吗?麻烦再贴一下详细的报错吧

[root@node01 ~]# kubectl -n tidb-cluster apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/master/examples/basic/tidb-cluster.yaml

error: unable to recognize “https://raw.githubusercontent.com/pingcap/tidb-operator/master/examples/basic/tidb-cluster.yaml”: no matches for kind “TidbCluster” in version “pingcap.com/v1alpha1

就是这个错误

image

image
是一个 k8s?

1 个赞

!!啊,是我两个环境搞混了,谢谢,谢谢大家,抱歉



这种不报错也不返回是什么问题呢?

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。