mongodb / helm-charts

Apache License 2.0
99 stars 92 forks source link

No cluster IP supplied to Mongo service when created using community operator #357

Closed james-ro-williams closed 2 weeks ago

james-ro-williams commented 2 weeks ago

What did you do to encounter the bug?

What did you expect? The mongo service created mongod-svc to have a cluster-ip assigned to it, allowing for the creation of an ingress service.

What happened instead? The service is created with no cluster-ip assigned

Screenshots image

Kubernetes Cluster Information

Additional context mongo_manifest.yaml:

---
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
  name: mongodb
spec:
  members: 1
  type: ReplicaSet
  version: "8.0.0"
  security:
    authentication:
      modes: ["SCRAM"]
  users:
    - name: my-user
      db: admin
      passwordSecretRef: # a reference to the secret that will be used to generate the user's password
        name: my-user-password
      roles:
        - name: clusterAdmin
          db: admin
        - name: userAdminAnyDatabase
          db: admin
      scramCredentialsSecretName: my-scram
  statefulSet:
    spec:
      # the storage class name must be the same as the one used in the volumeClaimTemplates, and this is where we define the use of our storage class
      # https://github.com/mongodb/mongodb-kubernetes-operator/issues/961#issuecomment-1113549548
      service:
        spec:
          type: ClusterIP
          clusterIP: ""
      volumeClaimTemplates:
        - metadata:
            name: data-volume
          spec:
            accessModes: ["ReadWriteOnce"]
            storageClassName: "dev-ebs-sc-hot-storage"
            resources:
              requests:
                storage: 1Gi
        - metadata:
            name: logs-volume
          spec:
            accessModes: ["ReadWriteOnce"]
            storageClassName: "dev-ebs-sc-hot-storage"
            resources:
              requests:
                storage: 1Gi
  additionalMongodConfig:
    storage.wiredTiger.engineConfig.journalCompressor: zlib

# the user credentials will be generated from this secret
# once the credentials are generated, this secret is no longer required
---
apiVersion: v1
kind: Secret
metadata:
  name: my-user-password
type: Opaque
stringData:
  password: <your-password-here>
james-ro-williams commented 2 weeks ago

After further investigation, I've found this to be the desired behaviour - as to coordinate access to a StatefulSet a headless service is created. This is working as intended.