1

I am deploying mongodb to Kubernetes with following values:

mongodb:
  persistence:
    enabled: true
    existingClaim: mongodb-pvc
  volumePermissions:
    enabled: true
  mongodbRootPassword: hello
  mongodbUsername: db_user
  mongodbPassword: alongpassword
  mongodbDatabase: db_read
  replicaCount: 1
  usePassword: true

The chart gets deployed without any problem. But problem arises when connecting from rails app deployed in same cluster I set ENV like

- name: MONGO_DB_URI
  value: {{ template "core.mongodb.uri" . }}

and have this in template

{{- define "core.mongodb.uri" -}}
{{- printf "mongodb://%s:%s@%s-%s:27017" .Values.mongodb.user .Values.mongodb.password .Release.Name "mongodb.default.svc.cluster.local" -}}
{{- end -}}

The values are supplied correctly But when rails tries to connect the following error is thrown

Mongo::Auth::Unauthorized (User db_user (mechanism: scram) is not authorized to access admin (auth source: admin, used mechanism: SCRAM-SHA-1, used server: relese-name-mongodb.default.svc.cluster.local:27017 (STANDALONE)): Authentication failed. (on crelese-name-mongodb.default.svc.cluster.local:27017))

and get following in mongo log

2020-02-25T18:36:33.722+0000 I ACCESS   [conn2050] Supported SASL mechanisms requested for unknown user 'db_user@admin'
2020-02-25T18:36:33.733+0000 I ACCESS   [conn2050] SASL SCRAM-SHA-1 authentication failed for db_user on admin from client 10.244.0.227:34092 ; UserNotFound: Could not find user db_user@admin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.