Skip to content

Commit 2de58fa

Browse files
authored
[Feature] Always use internal metrics exporter (#783)
1 parent 4639ff6 commit 2de58fa

File tree

10 files changed

+136
-378
lines changed

10 files changed

+136
-378
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
44
- Update UBI Image to 8.4
5-
- Fix ArangoSync Liveness Prove
5+
- Fix ArangoSync Liveness Probe
66
- Allow runtime update of Sidecar images
77
- Allow Agent recreation with preserved IDs
8+
- The internal metrics exporter can not be disabled
89

910
## [1.2.2](https://github.com/arangodb/kube-arangodb/tree/1.2.2) (2021-09-09)
1011
- Update 'github.com/arangodb/arangosync-client' dependency to v0.7.0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Feature-wise production readiness table:
9595
| Operator Maintenance Management Support | 1.2.0 | >= 3.6.0 | Community, Enterprise | Production | True | --deployment.feature.maintenance | N/A |
9696
| Operator Internal Metrics Exporter | 1.1.9 | >= 3.6.0 | Community, Enterprise | Alpha | False | --deployment.feature.metrics-exporter | N/A |
9797
| Operator Internal Metrics Exporter | 1.2.0 | >= 3.6.0 | Community, Enterprise | Production | True | --deployment.feature.metrics-exporter | N/A |
98+
| Operator Internal Metrics Exporter | 1.2.3 | >= 3.6.0 | Community, Enterprise | Production | True | --deployment.feature.metrics-exporter | It is always enabled |
9899
| Operator Ephemeral Volumes | 1.2.2 | >= 3.7.0 | Community, Enterprise | Alpha | False | --deployment.feature.ephemeral-volumes | N/A |
99100

100101
## Release notes for 0.3.16

pkg/deployment/deployment_core_test.go

Lines changed: 80 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -23,18 +23,18 @@
2323
package deployment
2424

2525
import (
26+
"fmt"
27+
"os"
28+
"path/filepath"
2629
"testing"
2730

28-
"github.com/arangodb/kube-arangodb/pkg/util/constants"
29-
30-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
31-
3231
"github.com/stretchr/testify/require"
33-
34-
"github.com/arangodb/kube-arangodb/pkg/util"
32+
core "k8s.io/api/core/v1"
3533

3634
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
37-
core "k8s.io/api/core/v1"
35+
"github.com/arangodb/kube-arangodb/pkg/util"
36+
"github.com/arangodb/kube-arangodb/pkg/util/constants"
37+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3838
)
3939

4040
func TestEnsurePod_ArangoDB_Core(t *testing.T) {
@@ -913,12 +913,14 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
913913
}
914914

915915
testCase.createTestPodData(deployment, api.ServerGroupAgents, firstAgentStatus)
916+
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
916917
},
917918
ExpectedEvent: "member agent is created",
918919
ExpectedPod: core.Pod{
919920
Spec: core.PodSpec{
920921
Volumes: []core.Volume{
921922
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
923+
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
922924
},
923925
Containers: []core.Container{
924926
{
@@ -934,6 +936,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
934936
ImagePullPolicy: core.PullIfNotPresent,
935937
SecurityContext: securityContext.NewSecurityContext(),
936938
},
939+
testArangodbInternalExporterContainer(false, emptyResources),
937940
},
938941
RestartPolicy: core.RestartPolicyNever,
939942
TerminationGracePeriodSeconds: &defaultAgentTerminationTimeout,
@@ -945,7 +948,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
945948
},
946949
},
947950
{
948-
Name: "DBserver Pod with metrics exporter",
951+
Name: "DBserver Pod with internal metrics exporter",
949952
ArangoDeployment: &api.ArangoDeployment{
950953
Spec: api.DeploymentSpec{
951954
Image: util.NewString(testImage),
@@ -988,7 +991,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
988991
ImagePullPolicy: core.PullIfNotPresent,
989992
SecurityContext: securityContext.NewSecurityContext(),
990993
},
991-
testCreateExporterContainer(false, emptyResources),
994+
testArangodbInternalExporterContainer(false, emptyResources),
992995
},
993996
RestartPolicy: core.RestartPolicyNever,
994997
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
@@ -1008,7 +1011,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
10081011
TLS: noTLS,
10091012
Metrics: api.MetricsSpec{
10101013
Enabled: util.NewBool(true),
1011-
Image: util.NewString(testExporterImage),
1014+
Image: util.NewString(testImage),
10121015
Authentication: api.MetricsAuthenticationSpec{
10131016
JWTTokenSecretName: util.NewString(testExporterToken),
10141017
},
@@ -1050,7 +1053,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
10501053
ImagePullPolicy: core.PullIfNotPresent,
10511054
SecurityContext: securityContext.NewSecurityContext(),
10521055
},
1053-
testCreateExporterContainer(false, k8sutil.ExtractPodResourceRequirement(resourcesUnfiltered)),
1056+
testArangodbInternalExporterContainer(false, k8sutil.ExtractPodResourceRequirement(resourcesUnfiltered)),
10541057
},
10551058
RestartPolicy: core.RestartPolicyNever,
10561059
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
@@ -1123,7 +1126,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
11231126
ImagePullPolicy: core.PullIfNotPresent,
11241127
SecurityContext: securityContext.NewSecurityContext(),
11251128
},
1126-
testCreateExporterContainer(false, emptyResources),
1129+
testArangodbInternalExporterContainer(false, emptyResources),
11271130
},
11281131
RestartPolicy: core.RestartPolicyNever,
11291132
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
@@ -1195,7 +1198,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
11951198
ImagePullPolicy: core.PullIfNotPresent,
11961199
SecurityContext: securityContext.NewSecurityContext(),
11971200
},
1198-
testCreateExporterContainer(false, emptyResources),
1201+
testArangodbInternalExporterContainer(false, emptyResources),
11991202
},
12001203
RestartPolicy: core.RestartPolicyNever,
12011204
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
@@ -1289,7 +1292,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
12891292
Resources: emptyResources,
12901293
},
12911294
func() core.Container {
1292-
c := testCreateExporterContainer(true, emptyResources)
1295+
c := testArangodbInternalExporterContainer(true, emptyResources)
12931296
c.VolumeMounts = append(c.VolumeMounts, k8sutil.TlsKeyfileVolumeMount())
12941297
return c
12951298
}(),
@@ -1435,3 +1438,65 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
14351438

14361439
runTestCases(t, testCases...)
14371440
}
1441+
1442+
func testArangodbInternalExporterContainer(secure bool, resources core.ResourceRequirements, ports ...int32) core.Container {
1443+
1444+
var port int32 = k8sutil.ArangoExporterPort
1445+
if len(ports) > 0 {
1446+
port = ports[0]
1447+
}
1448+
1449+
return core.Container{
1450+
Name: k8sutil.ExporterContainerName,
1451+
Image: testImage,
1452+
Command: createTestInternalExporterCommand(secure, port),
1453+
Ports: []core.ContainerPort{
1454+
{
1455+
Name: string(api.MetricsModeExporter),
1456+
ContainerPort: port,
1457+
Protocol: core.ProtocolTCP,
1458+
},
1459+
},
1460+
LivenessProbe: createTestExporterLivenessProbe(secure),
1461+
Resources: resources,
1462+
ImagePullPolicy: core.PullIfNotPresent,
1463+
SecurityContext: &core.SecurityContext{
1464+
Capabilities: &core.Capabilities{
1465+
Drop: []core.Capability{
1466+
"ALL",
1467+
},
1468+
},
1469+
},
1470+
VolumeMounts: []core.VolumeMount{
1471+
k8sutil.LifecycleVolumeMount(),
1472+
k8sutil.ExporterJWTVolumeMount(),
1473+
},
1474+
}
1475+
}
1476+
1477+
func createTestInternalExporterCommand(secure bool, port int32) []string {
1478+
binaryPath, err := os.Executable()
1479+
if err != nil {
1480+
return []string{}
1481+
}
1482+
exePath := filepath.Join(k8sutil.LifecycleVolumeMountDir, filepath.Base(binaryPath))
1483+
1484+
args := []string{exePath, "exporter"}
1485+
if secure {
1486+
args = append(args, "--arangodb.endpoint=https://localhost:8529/_admin/metrics")
1487+
} else {
1488+
args = append(args, "--arangodb.endpoint=http://localhost:8529/_admin/metrics")
1489+
}
1490+
1491+
args = append(args, "--arangodb.jwt-file=/secrets/exporter/jwt/token")
1492+
1493+
if port != k8sutil.ArangoExporterPort {
1494+
args = append(args, fmt.Sprintf("--server.address=:%d", port))
1495+
}
1496+
1497+
if secure {
1498+
args = append(args, "--ssl.keyfile=/secrets/tls/tls.keyfile")
1499+
}
1500+
1501+
return args
1502+
}

pkg/deployment/deployment_definitions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var (
9696

9797
metricsSpec = api.MetricsSpec{
9898
Enabled: util.NewBool(true),
99-
Image: util.NewString(testExporterImage),
99+
Image: util.NewString(testImage),
100100
Authentication: api.MetricsAuthenticationSpec{
101101
JWTTokenSecretName: util.NewString(testExporterToken),
102102
},

pkg/deployment/deployment_encryption_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818
// Copyright holder is ArangoDB GmbH, Cologne, Germany
1919
//
2020
// Author Adam Janikowski
21+
// Author Tomasz Mielech
2122
//
2223

2324
package deployment
@@ -26,16 +27,13 @@ import (
2627
"fmt"
2728
"testing"
2829

29-
"github.com/arangodb/kube-arangodb/pkg/util/constants"
30-
31-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
32-
3330
"github.com/stretchr/testify/require"
34-
35-
"github.com/arangodb/kube-arangodb/pkg/util"
31+
core "k8s.io/api/core/v1"
3632

3733
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
38-
core "k8s.io/api/core/v1"
34+
"github.com/arangodb/kube-arangodb/pkg/util"
35+
"github.com/arangodb/kube-arangodb/pkg/util/constants"
36+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3937
)
4038

4139
func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
@@ -184,7 +182,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
184182
Resources: emptyResources,
185183
},
186184
func() core.Container {
187-
c := testCreateExporterContainer(true, emptyResources)
185+
c := testArangodbInternalExporterContainer(true, emptyResources)
188186
c.VolumeMounts = append(c.VolumeMounts, k8sutil.TlsKeyfileVolumeMount())
189187
return c
190188
}(),

0 commit comments

Comments
 (0)