Skip to content

Commit 8629f6d

Browse files
nmarukovichhors
andauthored
K8SPSMDB-1297 add data dir to proc (#1924)
Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent a0c910a commit 8629f6d

10 files changed

+35
-45
lines changed

e2e-tests/monitoring-2-0/compare/statefulset_monitoring-cfg-oc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ spec:
277277
- mountPath: /etc/mongodb-ssl
278278
name: ssl
279279
readOnly: true
280+
- mountPath: /data/db
281+
name: mongod-data
282+
readOnly: true
280283
dnsPolicy: ClusterFirst
281284
initContainers:
282285
- command:

e2e-tests/monitoring-2-0/compare/statefulset_monitoring-cfg.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ spec:
278278
- mountPath: /etc/mongodb-ssl
279279
name: ssl
280280
readOnly: true
281+
- mountPath: /data/db
282+
name: mongod-data
283+
readOnly: true
281284
dnsPolicy: ClusterFirst
282285
initContainers:
283286
- command:

e2e-tests/monitoring-2-0/compare/statefulset_monitoring-mongos-oc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ spec:
278278
- mountPath: /etc/mongodb-ssl
279279
name: ssl
280280
readOnly: true
281+
- mountPath: /data/db
282+
name: mongod-data
283+
readOnly: true
281284
dnsPolicy: ClusterFirst
282285
initContainers:
283286
- command:

e2e-tests/monitoring-2-0/compare/statefulset_monitoring-mongos.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ spec:
279279
- mountPath: /etc/mongodb-ssl
280280
name: ssl
281281
readOnly: true
282+
- mountPath: /data/db
283+
name: mongod-data
284+
readOnly: true
282285
dnsPolicy: ClusterFirst
283286
initContainers:
284287
- command:

e2e-tests/monitoring-2-0/compare/statefulset_monitoring-rs0-oc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ spec:
265265
- mountPath: /etc/mongodb-ssl
266266
name: ssl
267267
readOnly: true
268+
- mountPath: /data/db
269+
name: mongod-data
270+
readOnly: true
268271
dnsPolicy: ClusterFirst
269272
initContainers:
270273
- command:

e2e-tests/monitoring-2-0/compare/statefulset_monitoring-rs0.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ spec:
266266
- mountPath: /etc/mongodb-ssl
267267
name: ssl
268268
readOnly: true
269+
- mountPath: /data/db
270+
name: mongod-data
271+
readOnly: true
269272
dnsPolicy: ClusterFirst
270273
initContainers:
271274
- command:

pkg/psmdb/const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616

1717
// MongodDataVolClaimName is a PVC Claim name
1818
MongodDataVolClaimName = "mongod-data"
19-
// MongodContainerDataDir is a mondo data path in container
19+
// MongodContainerDataDir is a mongo data path in container
2020
MongodContainerDataDir = "/data/db"
2121

2222
BinVolumeName = "bin"

pkg/psmdb/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func EntrypointInitContainer(cr *api.PerconaServerMongoDB, name, image string, p
1818
VolumeMounts: []corev1.VolumeMount{
1919
{
2020
Name: MongodDataVolClaimName,
21-
MountPath: "/data/db",
21+
MountPath: MongodContainerDataDir,
2222
},
2323
},
2424
Image: image,

pkg/psmdb/pmm.go

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,6 @@ func PMMContainer(cr *api.PerconaServerMongoDB, secret *corev1.Secret, dbPort in
2525
ports = append(ports, corev1.ContainerPort{ContainerPort: int32(i)})
2626
}
2727

28-
dbArgsEnv := []corev1.EnvVar{
29-
{
30-
Name: "MONGODB_USER",
31-
ValueFrom: &corev1.EnvVarSource{
32-
SecretKeyRef: &corev1.SecretKeySelector{
33-
Key: "MONGODB_CLUSTER_MONITOR_USER_ESCAPED",
34-
LocalObjectReference: corev1.LocalObjectReference{
35-
Name: secret.Name,
36-
},
37-
},
38-
},
39-
},
40-
{
41-
Name: "MONGODB_PASSWORD",
42-
ValueFrom: &corev1.EnvVarSource{
43-
SecretKeyRef: &corev1.SecretKeySelector{
44-
Key: "MONGODB_CLUSTER_MONITOR_PASSWORD_ESCAPED",
45-
LocalObjectReference: corev1.LocalObjectReference{
46-
Name: secret.Name,
47-
},
48-
},
49-
},
50-
},
51-
{
52-
Name: "DB_ARGS",
53-
// no need to change the port here since these arguments are used only if cr.CompareVersion("1.2.0") < 0
54-
Value: "--uri=mongodb://$(MONGODB_USER):$(MONGODB_PASSWORD)@127.0.0.1:27017/",
55-
},
56-
}
5728
dbEnv := []corev1.EnvVar{
5829
{
5930
Name: "DB_USER",
@@ -114,13 +85,16 @@ func PMMContainer(cr *api.PerconaServerMongoDB, secret *corev1.Secret, dbPort in
11485
},
11586
},
11687
Ports: ports,
88+
VolumeMounts: []corev1.VolumeMount{
89+
{
90+
Name: "ssl",
91+
MountPath: SSLDir,
92+
ReadOnly: true,
93+
},
94+
},
11795
}
11896

119-
if cr.CompareVersion("1.2.0") >= 0 {
120-
pmm.Env = append(pmm.Env, dbEnv...)
121-
} else {
122-
pmm.Env = append(pmm.Env, dbArgsEnv...)
123-
}
97+
pmm.Env = append(pmm.Env, dbEnv...)
12498

12599
if customLogin {
126100
pmmPassKey := api.PMMAPIKey
@@ -171,14 +145,12 @@ func PMMContainer(cr *api.PerconaServerMongoDB, secret *corev1.Secret, dbPort in
171145
pmm.Env = append(pmm.Env, pmmAgentEnvs(spec, secret, customLogin, customAdminParams)...)
172146
}
173147

174-
if cr.CompareVersion("1.13.0") >= 0 {
175-
pmm.VolumeMounts = []corev1.VolumeMount{
176-
{
177-
Name: "ssl",
178-
MountPath: SSLDir,
179-
ReadOnly: true,
180-
},
181-
}
148+
if cr.CompareVersion("1.18.0") >= 0 {
149+
pmm.VolumeMounts = append(pmm.VolumeMounts, corev1.VolumeMount{
150+
Name: MongodDataVolClaimName,
151+
MountPath: MongodContainerDataDir,
152+
ReadOnly: true,
153+
})
182154
}
183155

184156
return pmm

pkg/psmdb/statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func backupAgentContainer(ctx context.Context, cr *api.PerconaServerMongoDB, rep
437437

438438
c.VolumeMounts = append(c.VolumeMounts, []corev1.VolumeMount{
439439
{
440-
Name: "mongod-data",
440+
Name: MongodDataVolClaimName,
441441
MountPath: MongodContainerDataDir,
442442
ReadOnly: false,
443443
},

0 commit comments

Comments
 (0)