Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

529
Views
deploy MongoDB in EKS/EFS with Mongo Operator

I'm trying to deploy mongodb with the kubernetes operator on AWS EKS with EFS for the storage class. Just following the documentation examples here:

https://github.com/mongodb/mongodb-kubernetes-operator

I don't understand how to define the PVC naming properly. I've looked through the Github issues and Stack Overflow. Just not finding the example to resolve what seems to be a simple issue.


apiVersion: mongodb.com/v1
kind: MongoDB
metadata:
  name: mongodb
spec:
  members: 1
  type: ReplicaSet
  version: "4.2.6"
  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:
     volumeClaimTemplates:
       - metadata:
         name: data-volume
         spec:
          accessModes: [ "ReadWriteOnce" ]
          resources:
            requests:
              storage: 1Gi
            storageClassName: "efs-sc"

Events:

create Pod mongodb-0 in StatefulSet mongodb failed error: failed to create PVC -mongodb-0: PersistentVolumeClaim "-mongodb-0" is invalid: metadata.name: Invalid value: "-mongodb-0": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*') 
over 4 years ago ยท Santiago Trujillo
1 answers
Answer question

0

I replicated this error and I found an error in your yaml file. There is a missing indentation in the voluemClaimTemplates name.

This is your yaml file:

     volumeClaimTemplates:
       - metadata:
    ๐Ÿ‘‰   name: data-volume
         spec:
          accessModes: [ "ReadWriteOnce" ]
          resources:
            requests:
              storage: 1Gi
            storageClassName: "efs-sc"

And this is the correct part with fixed indentation:

     volumeClaimTemplates:
       - metadata:
    ๐Ÿ‘‰     name: data-volume
         spec:
          accessModes: [ "ReadWriteOnce" ]
          resources:
            requests:
              storage: 1Gi
            storageClassName: "efs-sc"

It appears that because of this error the operator could not get the name correctly and he was trying to create volumes with its default template. You can verify that yourself with k get sts mongodb -oyaml:

  volumeClaimTemplates:
  - apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
      volumeMode: Filesystem
  - apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: data-volume
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 10G
      volumeMode: Filesystem

over 4 years ago ยท Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!