Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
justurbo opened this issue Mar 6, 2025 · 1 comment

Comments

@justurbo
Copy link

justurbo commented Mar 6, 2025

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
@justurbo
Copy link
Author

justurbo commented Mar 7, 2025

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  = "createResource"
    value = true
  }
  set {
    name  = "resource.version"
    value = var.MONGO_VERSION
  }
}

This does not create any Kubernetes resrouces.

kubectl get crds | grep mongodb
kubectl get all -n mongodb

Both commands do not return any Kubernetes results.

I cannot understand... Is something wrong with the way I install the community operator using the Terraform Helm provider?

Has anybody had luck with Kubernetes MongoDB Community Operator and Terraform as IaC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant