-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathaccess-mongo-from-kubernetes-as-admin.sh
executable file
·91 lines (84 loc) · 2.46 KB
/
access-mongo-from-kubernetes-as-admin.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /bin/sh
set -e
cat <<EOF
**********************************************************************************************************************
***** This script allows you to connect to mongo directly from inside the cluster => useful for AWS installation *****
**********************************************************************************************************************
1 - Firstly you have to connect to db :
use database
2 - You can execute requests ex :
- Display all TaskData :
db.TaskData.find().limit(3).pretty()
- Filter by session / output :
db.TaskData.find({ SessionId: { \$eq : '7eafe4e3-0aa2-46ef-8ce6-bf9e365c5449' }, ExpectedOutputIds: { \$eq : 'a600dca5-b672-4177-9b4a-880dbcefee4e'}}).pretty()
more informations here : https://www.mongodb.com/docs/manual/reference/method/db.collection.find/
EOF
kubectl run -it --rm -n armonik mongoshclient --image=rtsp/mongosh --overrides='
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"creationTimestamp": null,
"labels": {
"run": "mongoshclient"
},
"name": "mongoshclient",
"namespace": "armonik"
},
"spec": {
"containers": [
{
"name": "mongosh",
"image": "rtsp/mongosh",
"stdin": true,
"tty": true,
"command": [
"bash",
"-c"
],
"args": [
"mongosh --tlsCAFile /mongodb/chain.pem --tlsAllowInvalidCertificates --tlsAllowInvalidHostnames --tls -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD mongodb+srv://mongodb-armonik-headless.armonik.svc.cluster.local/"
],
"env": [
{
"name": "MONGO_INITDB_ROOT_USERNAME",
"valueFrom": {
"secretKeyRef": {
"name": "mongodb-admin",
"key": "username"
}
}
},
{
"name": "MONGO_INITDB_ROOT_PASSWORD",
"valueFrom": {
"secretKeyRef": {
"name": "mongodb-admin",
"key": "password"
}
}
}
],
"volumeMounts": [
{
"name": "mongodb-secret-volume",
"mountPath": "/mongodb/"
}
],
"resources": {}
}
],
"volumes": [
{
"name": "mongodb-secret-volume",
"secret": {
"secretName": "mongodb"
}
}
],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Always"
},
"status": {}
}
'