mongodb openshift 中的运算符部署 "Failed to apply default image tag "/:4.2.6“引用格式无效”

mongodb operator deployment in openshift "Failed to apply default image tag "/:4.2.6" invalid reference format"

我指的是 https://github.com/mongodb/mongodb-kubernetes-operator 的 mongodb 社区运营商,并尝试将其部署到 openshift 或 okd

git clone https://github.com/mongodb/mongodb-kubernetes-operator.git
cd mongodb-kubernetes-operator 
kubectl create namespace mongodb
kubectl create -f deploy/operator/role.yaml --namespace mongodb
kubectl create -f deploy/operator/role_binding.yaml --namespace mongodb
kubectl create -f deploy/operator/service_account.yaml --namespace mongodb
kubectl create -f deploy/crds/mongodb.com_mongodb_crd.yaml --namespace mongodb

oc apply -f deploy/openshift/operator_openshift.yaml -n mongodb
oc apply -f deploy/crds/mongodb.com_v1_mongodb_openshift_cr.yaml -n mongodb

Operator pod 成功 运行 但 mongodb 副本集 pods 没有出现。错误如下

[kubenode@master mongodb-kubernetes-operator]$ oc get pods
NAME                                           READY     STATUS             RESTARTS   AGE
example-openshift-mongodb-0                    0/2       InvalidImageName   10         31m
mongodb-kubernetes-operator-66bfcbcf44-rqp5l   1/1       Running            0          32m


 Failed to apply default image tag "/:4.2.6": couldn't parse image reference "/:4.2.6": invalid reference format

这里的错误表明它拉错了图像,我尝试使用 oc edit statefulset.apps/example-openshift-mongodb 更新图像。正确更新图像名称并保存后,我看不到已保存的更改。请让我知道如何将图像更新为正确的图像

运营商信息

Kubernetes 集群信息

[kubenode@master mongodb-kubernetes-operator]$ openshift version
openshift v3.11.0+62803d0-1

[kubenode@master mongodb-kubernetes-operator]$ kubectl version
Client Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2018-10-15T09:45:30Z", GoVersion:"go1.10.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2020-12-07T17:59:40Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}

您可以使用此命令更新 mongo

的部署映像
kubectl set image deployment/deployment-name contianerame=image:tag

在您的情况下,您可以清楚地看到您尝试更新的 MongoDB 图片的标签存在问题

Failed to apply default image tag "/:4.2.6": couldn't parse image reference "/:4.2.6": invalid reference format

您还可以通过编辑部署或状态集来更新映像

kubectl 编辑 deployment or statefulsets name of deployment or statefulsets

我意识到,由于 mongo statefulset 是使用运算符和 crd 创建的,https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/ the changes done directly to statefulsets are not getting saved. Hence editing the the crd file that is https://github.com/mongodb/mongodb-kubernetes-operator/blob/master/deploy/crds/mongodb.com_v1_mongodb_openshift_cr.yaml 帮助我解决了这个问题。 在 mongodb.com_v1_mongodb_openshift_cr.yaml 中的第 33 行之后添加一个带有 image: mongo:4.2.6 的新行,然后部署