Skip to content

no matches for kind "MongoDBCommunity" in group "mongodbcommunity.mongodb.com" #1683

Open
@justurbo

Description

@justurbo

I am trying to set up a MongoDB Community Kubernetes Operator following the official guide, however, I am facing an issue when installing CRDs with helm:

Error: API did not recognize GroupVersionKind from manifest (CRD may not be installed)

no matches for kind "MongoDBCommunity" in group "mongodbcommunity.mongodb.com"

error message

Terraform HCL setup:

resource "kubernetes_namespace_v1" "default" {
  metadata {
    name = "mongodb"
  }
}

resource "helm_release" "mongodb" {
  namespace  = kubernetes_namespace_v1.default.metadata[0].name
  repository = "https://mongodb.github.io/helm-charts"
  chart      = "community-operator"
  version    = "0.12.0"
  name       = "community-operator"
  # set {
  #   name  = "community-operator-crds.enabled"
  #   value = true
  # }
}

resource "kubernetes_secret_v1" "mongo_admin_password" {
  metadata {
    namespace = kubernetes_namespace_v1.default.metadata[0].name
    name      = "mongo-admin-password"
  }
  type = "Opaque"
  data = {
    password = var.ADMIN_PASSWORD
  }
}

resource "kubernetes_manifest" "create" {
  manifest = yamldecode(templatefile("${path.module}/custom_resources/create.yaml", {
    NAMESPACE    = kubernetes_namespace_v1.default.metadata[0].name
    CLUSTER_NAME = var.CLUSTER_NAME
    VERSION      = var.MONGO_VERSION,

    ADMIN_USERNAME                = var.ADMIN_USERNAME,
    ADMIN_PASSWORD_SECRET_NAME    = kubernetes_secret_v1.mongo_admin_password.metadata[0].name,
    SCRAM_CREDENTIALS_SECRET_NAME = "mongo-admin"
  }))

  depends_on = [helm_release.mongodb]
}

resource "kubernetes_manifest" "scale" {
  manifest = yamldecode(templatefile("${path.module}/custom_resources/scale.yaml", {
    NAMESPACE    = kubernetes_namespace_v1.default.metadata[0].name
    CLUSTER_NAME = var.CLUSTER_NAME
    VERSION      = var.MONGO_VERSION,
    REPLICAS     = var.REPLICAS,
  }))

  depends_on = [kubernetes_manifest.create]
}

create.yaml which is failing

apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
  name: ${CLUSTER_NAME}
  namespace: ${NAMESPACE}
spec:
  members: 1
  type: ReplicaSet
  version: ${VERSION}
  security:
    authentication:
      modes: [ "SCRAM" ]
  users:
    - name: ${ADMIN_USERNAME}
      db: admin
      # a reference to the secret that will be used to generate the user's password
      passwordSecretRef:
        name: ${ADMIN_PASSWORD_SECRET_NAME}
      roles:
        - name: clusterAdmin
          db: admin
        - name: userAdminAnyDatabase
          db: admin
      scramCredentialsSecretName: ${SCRAM_CREDENTIALS_SECRET_NAME}
  additionalMongodConfig:
    storage.wiredTiger.engineConfig.journalCompressor: zlib

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions