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

Authentication failed with replica set mongodb kubernetes #89

Closed
viniciusks opened this issue Oct 17, 2018 · 4 comments
Closed

Authentication failed with replica set mongodb kubernetes #89

viniciusks opened this issue Oct 17, 2018 · 4 comments

Comments

@viniciusks
Copy link

Description

Before I had just a mongodb pod with simple authentication (username and password), today I needed to perform the mongo replica set to increase mongo's performance.

Today my mongo structure is like this:
mongo-0 - primary
mongo-1 - should be the secondary

But mongo-1 gives authentication failure.
How would I configure my mongo statefulset to accept this authentication?

Code

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: mongo
spec:
serviceName: "mongo"
replicas: 2
template:
metadata:
labels:
role: mongo
environment: test
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mongo
image: ootz/ootz_mongo:3.6
command:
- mongod
args:
- "--replSet"
- rs0
- "--bind_ip"
- 0.0.0.0
- "--auth"
- "--smallfiles"
- "--noprealloc"
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
resources:
limits:
cpu: 1100m
requests:
cpu: 1100m
- name: mongo-sidecar
image: cvallance/mongo-k8s-sidecar:latest
resources:
limits:
cpu: 50m
requests:
cpu: 20m
env:
- name: MONGO_SIDECAR_POD_LABELS
value: "role=mongo,environment=test"
- name: MONGODB_USERNAME
value: "username"
- name: MONGODB_PASSWORD
value: "password"
- name: MONGODB_DATABASE
value: "admin"
nodeSelector:
purpose: db
volumeClaimTemplates:
metadata:
name: mongo-persistent-storage
annotations:
volume.beta.kubernetes.io/storage-class: "fast"
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 10Gi

@manan-jadhav
Copy link

#86 Try using this PR's updated spec

@viniciusks
Copy link
Author

Thank you, I've already resolved

@mau21mau
Copy link

@viniciusks How did you solved the issue?

@viniciusks
Copy link
Author

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

3 participants