Required role.
...
rules:
- apiGroups: [""]
resources: ["pods/portforward"]
verbs: ["get", "list", "create"]
...
Create the port forwarding.
kubectl -n YOUR-MONGO-NS port-forward \
--address 0.0.0.0
service/YOUR-MONGO-SERVICE-NAME 27017:27017
Then connect to mongo.
mongo -host 127.0.0.1 --port 27017 -u root --password XXXXXX
mongodump --db your-db-name
mongorestore --db your-db-name dump/your-db-name
use YOUR-DATABASE
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
db.addUser({user: "development", pwd: "123456", roles: [ "dbAdmin"]});
db.createUser({user: "development", pwd: "123456", roles: [ "dbAdmin"]});