Im referring to mongodb community operator from https://github.com/mongodb/mongodb-kubernetes-operator and trying to deploy it in openshift or 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 is successfully running but mongodb replica set pods does not come up. Error is as follows
[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
Here as the error indicates it is pulling the wrong image and i tried to update the image using oc edit statefulset.apps/example-openshift-mongodb
. Once I update the image name correctly and save, i dont see the changes saved. Please let me know what could be done to update the image to right one
Operator Information
Kubernetes Cluster Information
[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"}
you can use this command to update the deployment image of mongo
kubectl set image deployment/deployment-name contianerame=image:tag
in your case you can see clearly there is an issue with the tag of MongoDB image you tried to update
Failed to apply default image tag "/:4.2.6": couldn't parse image reference "/:4.2.6": invalid reference format
you can also update the image by editing the deployment or statefulsets
kubectl edit deployment or statefulsets
name of deployment or statefulsets
I realized that since mongo statefulset are created using operator and 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 has helped me to solve the issue.
Add a new line with image: mongo:4.2.6
after line no 33 in the mongodb.com_v1_mongodb_openshift_cr.yaml and then deploy