apecloud / kubeblocks

KubeBlocks is an open-source control plane software that runs and manages databases, message queues and other stateful applications on K8s.
https://kubeblocks.io
GNU Affero General Public License v3.0
2.18k stars 181 forks source link

[BUG] mongodb cluster start failed #8437

Closed shuoshadow closed 1 week ago

shuoshadow commented 1 week ago
Kubernetes: v1.28.9
KubeBlocks: 0.9.2-beta.8
kbcli: 0.9.1
WARNING: version difference between kbcli (0.9.1) and kubeblocks (0.9.2-beta.8) 
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
  name: test-mongodb
  namespace: kb-cloud
spec:
  clusterDefinitionRef: mongodb
  clusterVersionRef: mongodb-5.0
  terminationPolicy: Delete
  affinity:
    podAntiAffinity: Preferred
    topologyKeys:
    - kubernetes.io/hostname
  tolerations:
    - key: "node-type"
      operator: "Equal"
      value: "mid"
      effect: "NoSchedule"
  componentSpecs:
  - name: mongodb
    componentDefRef: mongodb
    enabledLogs:
    - running
    disableExporter: false
    serviceAccountName: kb-mongo-cluster
    replicas: 3
    resources:
      limits:
        cpu: '4'
        memory: 4Gi
      requests:
        cpu: '1'
        memory: 2Gi
    volumeClaimTemplates:
    - name: data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 200Gi
        storageClassName: openebs-hostpath
Name: test-mongodb       Created Time: Nov 11,2024 07:32 UTC+0000
NAMESPACE   CLUSTER-DEFINITION   VERSION       STATUS     TERMINATION-POLICY   
kb-cloud    mongodb              mongodb-5.0   Creating   Delete               

Endpoints:
COMPONENT   MODE        INTERNAL                                                EXTERNAL   
mongodb     ReadWrite   test-mongodb-mongodb.kb-cloud.svc.cluster.local:27017   <none>     

Topology:
COMPONENT   INSTANCE                 ROLE     STATUS    AZ       NODE                          CREATED-TIME                 
mongodb     test-mongodb-mongodb-0   <none>   Running   <none>   dev-k8s-mid03/10.10.111.246   Nov 11,2024 07:32 UTC+0000   
mongodb     test-mongodb-mongodb-1   <none>   Running   <none>   dev-k8s-mid07/10.10.111.242   Nov 11,2024 07:32 UTC+0000   
mongodb     test-mongodb-mongodb-2   <none>   Running   <none>   dev-k8s-mid08/10.10.111.241   Nov 11,2024 07:32 UTC+0000   

Resources Allocation:
COMPONENT   DEDICATED   CPU(REQUEST/LIMIT)   MEMORY(REQUEST/LIMIT)   STORAGE-SIZE   STORAGE-CLASS      
mongodb     false       1 / 4                2Gi / 4Gi               data:200Gi     openebs-hostpath   

Images:
COMPONENT   TYPE      IMAGE                                                                    
mongodb     mongodb   apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/mongo:5.0.14   

Data Protection:
BACKUP-REPO   AUTO-BACKUP   BACKUP-SCHEDULE   BACKUP-METHOD   BACKUP-RETENTION   RECOVERABLE-TIME   

Show cluster events: kbcli cluster list-events -n kb-cloud test-mongodb

image image

image

xuriwuyun commented 1 week ago

Is this a new cluster or a backup-restore cluster? Please provide the console output of the MongoDB container in pod test-mongodb-mongodb-0.

h-shihao commented 1 week ago

你好,我想请教一下,你是如何实现修改镜像地址docker.io/apecloud/mongo:5.0.14为apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/mongo:5.0.14 的?

xuriwuyun commented 1 week ago

this can be made by upgrade mongodb-addon with ` helm repo add kubeblocks-addons https://jihulab.com/api/v4/projects/150246/packages/helm/stable

helm upgrade -i kb-addon-mongodb kubeblocks-addons/mongodb -n kb-system --set image.repository=apecloud/mongo,image.registry=apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com `

shuoshadow commented 1 week ago

Is this a new cluster or a backup-restore cluster? Please provide the console output of the MongoDB container in pod test-mongodb-mongodb-0.

HI, That's a new cluster, there is no log in pod test-mongodb-mongodb-0.

image

xuriwuyun commented 1 week ago

The MongoDB add-on may be outdated. You can upgrade it by using the following command: helm upgrade -i kb-addon-mongodb kubeblocks-addons/mongodb -n kb-system , and then try again.

shanshanying commented 1 week ago

@shuoshadow

Or you can use kbcli addon search mongodb to fetch the list of available versionss. And upgrade you MongoDB Addon use kbcli addon upgrade mongodb --version <version-for-kb09> (versions with prefix 0.9)

shuoshadow commented 1 week ago

@shanshanying

@shuoshadow

Or you can use kbcli addon search mongodb to fetch the list of available versionss. And upgrade you MongoDB Addon use kbcli addon upgrade mongodb --version <version-for-kb09> (versions with prefix 0.9)

I executed the command, but it had no effect and still failed to start. image

xuriwuyun commented 1 week ago

Please provide the YAML for the cluster and pod, as well as the console output from the MongoDB container in the pod.

shuoshadow commented 1 week ago

Please provide the YAML for the cluster and pod, as well as the console output from the MongoDB container in the pod.

apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
  name: test-mongodb
  namespace: kb-cloud
spec:
  clusterDefinitionRef: mongodb
  clusterVersionRef: mongodb-5.0
  terminationPolicy: Delete
  affinity:
    podAntiAffinity: Preferred
    topologyKeys:
    - kubernetes.io/hostname
  tolerations:
    - key: "node-type"
      operator: "Equal"
      value: "mid"
      effect: "NoSchedule"
  componentSpecs:
  - name: mongodb
    componentDefRef: mongodb
    enabledLogs:
    - running
    disableExporter: false
    serviceAccountName: kb-mongo-cluster
    replicas: 3
    resources:
      limits:
        cpu: '4'
        memory: 4Gi
      requests:
        cpu: '1'
        memory: 2Gi
    volumeClaimTemplates:
    - name: data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 200Gi
        storageClassName: openebs-hostpath
shuoshadow commented 1 week ago

Is this a new cluster or a backup-restore cluster? Please provide the console output of the MongoDB container in pod test-mongodb-mongodb-0.

HI, That's a new cluster, there is no log in pod test-mongodb-mongodb-0.

image

@xuriwuyun no any log output

the file log /data/mongodb/logs/mongodb.log in pod test-mongodb-mongodb-0.

image

xuriwuyun commented 1 week ago

i see, the cluster yaml is outdated, you can use this new template instead:

` apiVersion: apps.kubeblocks.io/v1alpha1 kind: Cluster metadata: name: mongo-cluster namespace: default spec: componentSpecs:

shuoshadow commented 1 week ago

i see, the cluster yaml is outdated, you can use this new template instead:

` apiVersion: apps.kubeblocks.io/v1alpha1 kind: Cluster metadata: name: mongo-cluster namespace: default spec: componentSpecs:

  • componentDef: mongodb name: mongodb replicas: 3 resources: limits: cpu: "0.5" memory: 0.5Gi requests: cpu: "0.5" memory: 0.5Gi serviceVersion: 6.0.16 volumeClaimTemplates:

    • name: data spec: accessModes:

    • ReadWriteOnce resources: requests: storage: 20Gi terminationPolicy: Delete `

image

image

Message:               cluster API validate error, clusterDef: , topology: , comps: 1, legacy comps: 1, simplified API: false

no pod were created

shuoshadow commented 1 week ago

@xuriwuyun

  Warning  Warning         8m30s (x12 over 8m40s)  cluster-controller  no matched component definition found: mongodb
  Warning  PreCheckFailed  3m12s (x17 over 8m40s)  cluster-controller  no matched component definition found: mongodb

image