title: Authentication mongo deployed on kubernetes
body: <p>I tried to configure <code>mongo</code> with authentication on a kubernetes cluster. I deployed the following <code>yaml</code>:</p>
  
  <pre><code>kind: StatefulSet
  metadata:
    name: mongo
  spec:
    serviceName: "mongo"
    replicas: 1
  template:
    metadata:
      labels:
        app: mongo
    spec:
      containers:
      - name: mongodb
        image: mongo:4.0.0
        env:
        - name: MONGO_INITDB_ROOT_USERNAME
          value: "admin"
        - name: MONGO_INITDB_ROOT_PASSWORD
  # Get password from secret
          value: "abc123changeme"
        command:
        - mongod
        - --auth
        - --replSet
        - rs0
        - --bind_ip
        - 0.0.0.0
        ports:
        - containerPort: 27017
          name: web
        volumeMounts:
        - name: mongo-ps
          mountPath: /data/db
      volumes:
      - name: mongo-ps
        persistentVolumeClaim:
          claimName: mongodb-pvc
  </code></pre>
  
  <p>When I tried to authenticate with username "admin" and password "abc123changeme" I received <code>"Authentication failed."</code>. </p>
  
  <p>How can I configure mongo admin username and password (I want to get password from secret)?</p>
  
  <p>Thanks</p>