Basically ive set up a mongo-express pod to run but when i connect to it, the password i set simply doesn't work.
Q1) Can i check if its using the secret, eg "kubectl get secrets" or open up docker container for mongodb and go to some specific config file to see password it expects me to use??
Q2) why isn't this working?
The image below is an example of where im upto.
some of the scripts below have been cut down to the relevant parts. full files at my github https://github.com/learncss666/no_password_secret
- my secret yaml
apiVersion: v1
kind: Secret
metadata:
name: mongodb-secret
type: Opaque
data:
mongo-root-username: dGdtamFjaw==
mongo-root-password: cGFzc3dvcmQ=
- the part of my mongo.yaml that handles the secret
....
env:
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
name: mongodb-secret
key: mongo-root-username
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-secret
key: mongo-root-password
....
- get all, to show my pods and stuff
PS C:\Users\tgmjack\Desktop\k8s prac> kubectl get all
NAME READY STATUS RESTARTS AGE
pod/mongo-express-859f75dd4f-xtthk 1/1 Running 1 (48m ago) 16h
pod/mongodb-deployment-699744c7d-xtp7r 1/1 Running 1 (48m ago) 19h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 42h
service/mongo-express-service LoadBalancer 10.96.233.157 <pending> 8081:30000/TCP 16h
service/mongodb-service ClusterIP 10.104.65.149 <none> 27017/TCP 18h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/mongo-express 1/1 1 1 16h
deployment.apps/mongodb-deployment 1/1 1 1 19h
NAME DESIRED CURRENT READY AGE
replicaset.apps/mongo-express-859f75dd4f 1 1 1 16h
replicaset.apps/mongodb-deployment-6658f4c549 0 0 0 19h
replicaset.apps/mongodb-deployment-699744c7d 1 1 1 19h
- but then i got go to mongo-express, it asks for a username and password and mine doesnt work
######################
I'm at 1:45 in this tutorial, Ive followed every step
https://www.youtube.com/watch?v=X48VuDVv0do&t=1099s
######## update I found how to get the username n password from secret... this is base 64 for "tgmjack" and "password"
PS C:\Users\tgmjack\Desktop\k8s prac> kubectl get secret mongodb-secret -o=jsonpath='{.data.mongo-root-password}'
cGFzc3dvcmQ=
PS C:\Users\tgmjack\Desktop\k8s prac> kubectl get secret mongodb-secret -o=jsonpath='{.data.mongo-root-username}'
dGdtamFjaw==