mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Always use internal metrics exporter (#783)
This commit is contained in:
parent
4639ff685b
commit
2de58faad6
10 changed files with 136 additions and 378 deletions
|
@ -2,9 +2,10 @@
|
|||
|
||||
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
||||
- Update UBI Image to 8.4
|
||||
- Fix ArangoSync Liveness Prove
|
||||
- Fix ArangoSync Liveness Probe
|
||||
- Allow runtime update of Sidecar images
|
||||
- Allow Agent recreation with preserved IDs
|
||||
- The internal metrics exporter can not be disabled
|
||||
|
||||
## [1.2.2](https://github.com/arangodb/kube-arangodb/tree/1.2.2) (2021-09-09)
|
||||
- Update 'github.com/arangodb/arangosync-client' dependency to v0.7.0
|
||||
|
|
|
@ -95,6 +95,7 @@ Feature-wise production readiness table:
|
|||
| Operator Maintenance Management Support | 1.2.0 | >= 3.6.0 | Community, Enterprise | Production | True | --deployment.feature.maintenance | N/A |
|
||||
| Operator Internal Metrics Exporter | 1.1.9 | >= 3.6.0 | Community, Enterprise | Alpha | False | --deployment.feature.metrics-exporter | N/A |
|
||||
| Operator Internal Metrics Exporter | 1.2.0 | >= 3.6.0 | Community, Enterprise | Production | True | --deployment.feature.metrics-exporter | N/A |
|
||||
| Operator Internal Metrics Exporter | 1.2.3 | >= 3.6.0 | Community, Enterprise | Production | True | --deployment.feature.metrics-exporter | It is always enabled |
|
||||
| Operator Ephemeral Volumes | 1.2.2 | >= 3.7.0 | Community, Enterprise | Alpha | False | --deployment.feature.ephemeral-volumes | N/A |
|
||||
|
||||
## Release notes for 0.3.16
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -23,18 +23,18 @@
|
|||
package deployment
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
core "k8s.io/api/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
core "k8s.io/api/core/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
)
|
||||
|
||||
func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
||||
|
@ -913,12 +913,14 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupAgents, firstAgentStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
ExpectedEvent: "member agent is created",
|
||||
ExpectedPod: core.Pod{
|
||||
Spec: core.PodSpec{
|
||||
Volumes: []core.Volume{
|
||||
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
|
||||
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
|
||||
},
|
||||
Containers: []core.Container{
|
||||
{
|
||||
|
@ -934,6 +936,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testArangodbInternalExporterContainer(false, emptyResources),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultAgentTerminationTimeout,
|
||||
|
@ -945,7 +948,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
Name: "DBserver Pod with metrics exporter",
|
||||
Name: "DBserver Pod with internal metrics exporter",
|
||||
ArangoDeployment: &api.ArangoDeployment{
|
||||
Spec: api.DeploymentSpec{
|
||||
Image: util.NewString(testImage),
|
||||
|
@ -988,7 +991,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testCreateExporterContainer(false, emptyResources),
|
||||
testArangodbInternalExporterContainer(false, emptyResources),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
|
@ -1008,7 +1011,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
TLS: noTLS,
|
||||
Metrics: api.MetricsSpec{
|
||||
Enabled: util.NewBool(true),
|
||||
Image: util.NewString(testExporterImage),
|
||||
Image: util.NewString(testImage),
|
||||
Authentication: api.MetricsAuthenticationSpec{
|
||||
JWTTokenSecretName: util.NewString(testExporterToken),
|
||||
},
|
||||
|
@ -1050,7 +1053,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testCreateExporterContainer(false, k8sutil.ExtractPodResourceRequirement(resourcesUnfiltered)),
|
||||
testArangodbInternalExporterContainer(false, k8sutil.ExtractPodResourceRequirement(resourcesUnfiltered)),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
|
@ -1123,7 +1126,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testCreateExporterContainer(false, emptyResources),
|
||||
testArangodbInternalExporterContainer(false, emptyResources),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
|
@ -1195,7 +1198,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testCreateExporterContainer(false, emptyResources),
|
||||
testArangodbInternalExporterContainer(false, emptyResources),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
|
@ -1289,7 +1292,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
Resources: emptyResources,
|
||||
},
|
||||
func() core.Container {
|
||||
c := testCreateExporterContainer(true, emptyResources)
|
||||
c := testArangodbInternalExporterContainer(true, emptyResources)
|
||||
c.VolumeMounts = append(c.VolumeMounts, k8sutil.TlsKeyfileVolumeMount())
|
||||
return c
|
||||
}(),
|
||||
|
@ -1435,3 +1438,65 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
|
|||
|
||||
runTestCases(t, testCases...)
|
||||
}
|
||||
|
||||
func testArangodbInternalExporterContainer(secure bool, resources core.ResourceRequirements, ports ...int32) core.Container {
|
||||
|
||||
var port int32 = k8sutil.ArangoExporterPort
|
||||
if len(ports) > 0 {
|
||||
port = ports[0]
|
||||
}
|
||||
|
||||
return core.Container{
|
||||
Name: k8sutil.ExporterContainerName,
|
||||
Image: testImage,
|
||||
Command: createTestInternalExporterCommand(secure, port),
|
||||
Ports: []core.ContainerPort{
|
||||
{
|
||||
Name: string(api.MetricsModeExporter),
|
||||
ContainerPort: port,
|
||||
Protocol: core.ProtocolTCP,
|
||||
},
|
||||
},
|
||||
LivenessProbe: createTestExporterLivenessProbe(secure),
|
||||
Resources: resources,
|
||||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: &core.SecurityContext{
|
||||
Capabilities: &core.Capabilities{
|
||||
Drop: []core.Capability{
|
||||
"ALL",
|
||||
},
|
||||
},
|
||||
},
|
||||
VolumeMounts: []core.VolumeMount{
|
||||
k8sutil.LifecycleVolumeMount(),
|
||||
k8sutil.ExporterJWTVolumeMount(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func createTestInternalExporterCommand(secure bool, port int32) []string {
|
||||
binaryPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
exePath := filepath.Join(k8sutil.LifecycleVolumeMountDir, filepath.Base(binaryPath))
|
||||
|
||||
args := []string{exePath, "exporter"}
|
||||
if secure {
|
||||
args = append(args, "--arangodb.endpoint=https://localhost:8529/_admin/metrics")
|
||||
} else {
|
||||
args = append(args, "--arangodb.endpoint=http://localhost:8529/_admin/metrics")
|
||||
}
|
||||
|
||||
args = append(args, "--arangodb.jwt-file=/secrets/exporter/jwt/token")
|
||||
|
||||
if port != k8sutil.ArangoExporterPort {
|
||||
args = append(args, fmt.Sprintf("--server.address=:%d", port))
|
||||
}
|
||||
|
||||
if secure {
|
||||
args = append(args, "--ssl.keyfile=/secrets/tls/tls.keyfile")
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ var (
|
|||
|
||||
metricsSpec = api.MetricsSpec{
|
||||
Enabled: util.NewBool(true),
|
||||
Image: util.NewString(testExporterImage),
|
||||
Image: util.NewString(testImage),
|
||||
Authentication: api.MetricsAuthenticationSpec{
|
||||
JWTTokenSecretName: util.NewString(testExporterToken),
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,7 @@
|
|||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Author Adam Janikowski
|
||||
// Author Tomasz Mielech
|
||||
//
|
||||
|
||||
package deployment
|
||||
|
@ -26,16 +27,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
core "k8s.io/api/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
core "k8s.io/api/core/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
)
|
||||
|
||||
func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
|
||||
|
@ -184,7 +182,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
|
|||
Resources: emptyResources,
|
||||
},
|
||||
func() core.Container {
|
||||
c := testCreateExporterContainer(true, emptyResources)
|
||||
c := testArangodbInternalExporterContainer(true, emptyResources)
|
||||
c.VolumeMounts = append(c.VolumeMounts, k8sutil.TlsKeyfileVolumeMount())
|
||||
return c
|
||||
}(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,7 @@
|
|||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Author Adam Janikowski
|
||||
// Author Tomasz Mielech
|
||||
//
|
||||
|
||||
package deployment
|
||||
|
@ -25,12 +26,11 @@ package deployment
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
core "k8s.io/api/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
core "k8s.io/api/core/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
)
|
||||
|
||||
func TestEnsurePod_Metrics(t *testing.T) {
|
||||
|
@ -85,7 +85,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testCreateExporterContainerWithPort(false, emptyResources, 9999),
|
||||
testArangodbInternalExporterContainer(false, emptyResources, 9999),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
|
@ -146,7 +146,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testCreateExporterContainer(false, emptyResources),
|
||||
testArangodbInternalExporterContainer(false, emptyResources),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
|
@ -191,6 +191,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
|
|||
Spec: core.PodSpec{
|
||||
Volumes: []core.Volume{
|
||||
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
|
||||
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
|
||||
},
|
||||
Containers: []core.Container{
|
||||
{
|
||||
|
@ -216,6 +217,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
testArangodbInternalExporterContainer(false, emptyResources),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
|
@ -260,6 +262,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
|
|||
Spec: core.PodSpec{
|
||||
Volumes: []core.Volume{
|
||||
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
|
||||
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
|
||||
},
|
||||
Containers: []core.Container{
|
||||
{
|
||||
|
@ -285,286 +288,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
|
|||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultAgentTerminationTimeout,
|
||||
Hostname: testDeploymentName + "-" + api.ServerGroupAgentsString + "-" + firstAgentStatus.ID,
|
||||
Subdomain: testDeploymentName + "-int",
|
||||
Affinity: k8sutil.CreateAffinity(testDeploymentName, api.ServerGroupAgentsString,
|
||||
false, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "DBserver Pod with sidecar metrics exporter and port override",
|
||||
ArangoDeployment: &api.ArangoDeployment{
|
||||
Spec: api.DeploymentSpec{
|
||||
Image: util.NewString(testImage),
|
||||
Authentication: noAuthentication,
|
||||
TLS: noTLS,
|
||||
Metrics: func() api.MetricsSpec {
|
||||
m := metricsSpec.DeepCopy()
|
||||
|
||||
m.Port = util.NewUInt16(9999)
|
||||
|
||||
m.Mode = api.MetricsModeSidecar.New()
|
||||
|
||||
return *m
|
||||
}(),
|
||||
},
|
||||
},
|
||||
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
|
||||
deployment.status.last = api.DeploymentStatus{
|
||||
Members: api.DeploymentStatusMembers{
|
||||
DBServers: api.MemberStatusList{
|
||||
firstDBServerStatus,
|
||||
},
|
||||
},
|
||||
Images: createTestImages(false),
|
||||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupDBServers, firstDBServerStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
ExpectedEvent: "member dbserver is created",
|
||||
ExpectedPod: core.Pod{
|
||||
Spec: core.PodSpec{
|
||||
Volumes: []core.Volume{
|
||||
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
|
||||
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
|
||||
},
|
||||
Containers: []core.Container{
|
||||
{
|
||||
Name: k8sutil.ServerContainerName,
|
||||
Image: testImage,
|
||||
Command: createTestCommandForDBServer(firstDBServerStatus.ID, false, false, false),
|
||||
Ports: createTestPorts(),
|
||||
VolumeMounts: []core.VolumeMount{
|
||||
k8sutil.ArangodVolumeMount(),
|
||||
},
|
||||
Resources: emptyResources,
|
||||
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", k8sutil.ArangoPort),
|
||||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
func() core.Container {
|
||||
z := testCreateExporterContainerWithPort(false, emptyResources, 9999)
|
||||
z.Command = append(z.Command, "--mode=passthru")
|
||||
return z
|
||||
}(),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultDBServerTerminationTimeout,
|
||||
Hostname: testDeploymentName + "-" + api.ServerGroupDBServersString + "-" + firstDBServerStatus.ID,
|
||||
Subdomain: testDeploymentName + "-int",
|
||||
Affinity: k8sutil.CreateAffinity(testDeploymentName, api.ServerGroupDBServersString,
|
||||
false, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Agency Pod with sidecar metrics exporter and port override",
|
||||
ArangoDeployment: &api.ArangoDeployment{
|
||||
Spec: api.DeploymentSpec{
|
||||
Image: util.NewString(testImage),
|
||||
Authentication: noAuthentication,
|
||||
TLS: noTLS,
|
||||
Metrics: func() api.MetricsSpec {
|
||||
m := metricsSpec.DeepCopy()
|
||||
|
||||
m.Port = util.NewUInt16(9999)
|
||||
|
||||
m.Mode = api.MetricsModeSidecar.New()
|
||||
|
||||
return *m
|
||||
}(),
|
||||
},
|
||||
},
|
||||
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
|
||||
deployment.status.last = api.DeploymentStatus{
|
||||
Members: api.DeploymentStatusMembers{
|
||||
Agents: api.MemberStatusList{
|
||||
firstAgentStatus,
|
||||
},
|
||||
},
|
||||
Images: createTestImages(false),
|
||||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupAgents, firstAgentStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
ExpectedEvent: "member agent is created",
|
||||
ExpectedPod: core.Pod{
|
||||
Spec: core.PodSpec{
|
||||
Volumes: []core.Volume{
|
||||
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
|
||||
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
|
||||
},
|
||||
Containers: []core.Container{
|
||||
{
|
||||
Name: k8sutil.ServerContainerName,
|
||||
Image: testImage,
|
||||
Command: createTestCommandForAgent(firstAgentStatus.ID, false, false, false),
|
||||
Ports: createTestPorts(),
|
||||
VolumeMounts: []core.VolumeMount{
|
||||
k8sutil.ArangodVolumeMount(),
|
||||
},
|
||||
Resources: emptyResources,
|
||||
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", k8sutil.ArangoPort),
|
||||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
func() core.Container {
|
||||
z := testCreateExporterContainerWithPort(false, emptyResources, 9999)
|
||||
z.Command = append(z.Command, "--mode=passthru")
|
||||
return z
|
||||
}(),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultAgentTerminationTimeout,
|
||||
Hostname: testDeploymentName + "-" + api.ServerGroupAgentsString + "-" + firstAgentStatus.ID,
|
||||
Subdomain: testDeploymentName + "-int",
|
||||
Affinity: k8sutil.CreateAffinity(testDeploymentName, api.ServerGroupAgentsString,
|
||||
false, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Agency Pod with sidecar metrics exporter and port override, with enabled deployment tls",
|
||||
ArangoDeployment: &api.ArangoDeployment{
|
||||
Spec: api.DeploymentSpec{
|
||||
Image: util.NewString(testImage),
|
||||
Authentication: noAuthentication,
|
||||
TLS: tlsSpec,
|
||||
Metrics: func() api.MetricsSpec {
|
||||
m := metricsSpec.DeepCopy()
|
||||
|
||||
m.Port = util.NewUInt16(9999)
|
||||
|
||||
m.Mode = api.MetricsModeSidecar.New()
|
||||
|
||||
return *m
|
||||
}(),
|
||||
},
|
||||
},
|
||||
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
|
||||
deployment.status.last = api.DeploymentStatus{
|
||||
Members: api.DeploymentStatusMembers{
|
||||
Agents: api.MemberStatusList{
|
||||
firstAgentStatus,
|
||||
},
|
||||
},
|
||||
Images: createTestImages(false),
|
||||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupAgents, firstAgentStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
ExpectedEvent: "member agent is created",
|
||||
ExpectedPod: core.Pod{
|
||||
Spec: core.PodSpec{
|
||||
Volumes: []core.Volume{
|
||||
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
|
||||
createTestTLSVolume(api.ServerGroupAgentsString, firstAgentStatus.ID),
|
||||
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
|
||||
},
|
||||
Containers: []core.Container{
|
||||
{
|
||||
Name: k8sutil.ServerContainerName,
|
||||
Image: testImage,
|
||||
Command: createTestCommandForAgent(firstAgentStatus.ID, true, false, false),
|
||||
Ports: createTestPorts(),
|
||||
VolumeMounts: []core.VolumeMount{
|
||||
k8sutil.ArangodVolumeMount(),
|
||||
k8sutil.TlsKeyfileVolumeMount(),
|
||||
},
|
||||
Resources: emptyResources,
|
||||
LivenessProbe: createTestLivenessProbe(httpProbe, true, "", k8sutil.ArangoPort),
|
||||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
func() core.Container {
|
||||
z := testCreateExporterContainerWithPortAndSecureEndpoint(true, true, emptyResources, 9999)
|
||||
|
||||
z.VolumeMounts = append(z.VolumeMounts, k8sutil.TlsKeyfileVolumeMount())
|
||||
|
||||
z.Command = append(z.Command, "--mode=passthru")
|
||||
return z
|
||||
}(),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultAgentTerminationTimeout,
|
||||
Hostname: testDeploymentName + "-" + api.ServerGroupAgentsString + "-" + firstAgentStatus.ID,
|
||||
Subdomain: testDeploymentName + "-int",
|
||||
Affinity: k8sutil.CreateAffinity(testDeploymentName, api.ServerGroupAgentsString,
|
||||
false, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Agency Pod with sidecar metrics exporter and port override, with enabled deployment tls but disabled metrics tls",
|
||||
ArangoDeployment: &api.ArangoDeployment{
|
||||
Spec: api.DeploymentSpec{
|
||||
Image: util.NewString(testImage),
|
||||
Authentication: noAuthentication,
|
||||
TLS: tlsSpec,
|
||||
Metrics: func() api.MetricsSpec {
|
||||
m := metricsSpec.DeepCopy()
|
||||
|
||||
m.Port = util.NewUInt16(9999)
|
||||
|
||||
m.Mode = api.MetricsModeSidecar.New()
|
||||
|
||||
m.TLS = util.NewBool(false)
|
||||
|
||||
return *m
|
||||
}(),
|
||||
},
|
||||
},
|
||||
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
|
||||
deployment.status.last = api.DeploymentStatus{
|
||||
Members: api.DeploymentStatusMembers{
|
||||
Agents: api.MemberStatusList{
|
||||
firstAgentStatus,
|
||||
},
|
||||
},
|
||||
Images: createTestImages(false),
|
||||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupAgents, firstAgentStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
ExpectedEvent: "member agent is created",
|
||||
ExpectedPod: core.Pod{
|
||||
Spec: core.PodSpec{
|
||||
Volumes: []core.Volume{
|
||||
k8sutil.CreateVolumeEmptyDir(k8sutil.ArangodVolumeName),
|
||||
createTestTLSVolume(api.ServerGroupAgentsString, firstAgentStatus.ID),
|
||||
k8sutil.CreateVolumeWithSecret(k8sutil.ExporterJWTVolumeName, testExporterToken),
|
||||
},
|
||||
Containers: []core.Container{
|
||||
{
|
||||
Name: k8sutil.ServerContainerName,
|
||||
Image: testImage,
|
||||
Command: createTestCommandForAgent(firstAgentStatus.ID, true, false, false),
|
||||
Ports: createTestPorts(),
|
||||
VolumeMounts: []core.VolumeMount{
|
||||
k8sutil.ArangodVolumeMount(),
|
||||
k8sutil.TlsKeyfileVolumeMount(),
|
||||
},
|
||||
Resources: emptyResources,
|
||||
LivenessProbe: createTestLivenessProbe(httpProbe, true, "", k8sutil.ArangoPort),
|
||||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
},
|
||||
func() core.Container {
|
||||
z := testCreateExporterContainerWithPortAndSecureEndpoint(true, false, emptyResources, 9999)
|
||||
|
||||
z.VolumeMounts = append(z.VolumeMounts, k8sutil.TlsKeyfileVolumeMount())
|
||||
|
||||
z.Command = append(z.Command, "--mode=passthru")
|
||||
return z
|
||||
}(),
|
||||
testArangodbInternalExporterContainer(false, emptyResources),
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyNever,
|
||||
TerminationGracePeriodSeconds: &defaultAgentTerminationTimeout,
|
||||
|
|
|
@ -68,7 +68,6 @@ const (
|
|||
testServiceAccountName = "testServiceAccountName"
|
||||
testPriorityClassName = "testPriority"
|
||||
testImageLifecycle = "arangodb/kube-arangodb:0.3.16"
|
||||
testExporterImage = "arangodb/arangodb-exporter:0.1.6"
|
||||
testImageOperatorUUIDInit = "image/test-1234:3.7"
|
||||
|
||||
testYes = "yes"
|
||||
|
@ -516,40 +515,6 @@ func createTestImages(enterprise bool) api.ImageInfoList {
|
|||
return createTestImagesWithVersion(enterprise, testVersion)
|
||||
}
|
||||
|
||||
func createTestExporterPorts(port uint16) []core.ContainerPort {
|
||||
return []core.ContainerPort{
|
||||
{
|
||||
Name: "exporter",
|
||||
ContainerPort: int32(port),
|
||||
Protocol: "TCP",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func createTestExporterCommand(secure, exporterSecure bool, port uint16) []string {
|
||||
command := []string{
|
||||
"/app/arangodb-exporter",
|
||||
}
|
||||
|
||||
if secure {
|
||||
command = append(command, "--arangodb.endpoint=https://localhost:8529")
|
||||
} else {
|
||||
command = append(command, "--arangodb.endpoint=http://localhost:8529")
|
||||
}
|
||||
|
||||
command = append(command, "--arangodb.jwt-file=/secrets/exporter/jwt/token")
|
||||
|
||||
if port != k8sutil.ArangoExporterPort {
|
||||
command = append(command, fmt.Sprintf("--server.address=:%d", port))
|
||||
}
|
||||
|
||||
if exporterSecure {
|
||||
command = append(command, "--ssl.keyfile=/secrets/tls/tls.keyfile")
|
||||
}
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func createTestExporterLivenessProbe(secure bool) *core.Probe {
|
||||
return probes.HTTPProbeConfig{
|
||||
LocalPath: "/",
|
||||
|
@ -607,29 +572,3 @@ func (testCase *testCaseStruct) createTestPodData(deployment *Deployment, group
|
|||
deployment.apiObject.Status.Members.Update(member, group)
|
||||
}
|
||||
}
|
||||
|
||||
func testCreateExporterContainerWithPortAndSecureEndpoint(secure, exporterSecure bool, resources core.ResourceRequirements, port uint16) core.Container {
|
||||
var securityContext api.ServerGroupSpecSecurityContext
|
||||
|
||||
return core.Container{
|
||||
Name: k8sutil.ExporterContainerName,
|
||||
Image: testExporterImage,
|
||||
Command: createTestExporterCommand(secure, exporterSecure, port),
|
||||
Ports: createTestExporterPorts(port),
|
||||
VolumeMounts: []core.VolumeMount{
|
||||
k8sutil.ExporterJWTVolumeMount(),
|
||||
},
|
||||
Resources: k8sutil.ExtractPodResourceRequirement(resources),
|
||||
LivenessProbe: createTestExporterLivenessProbe(exporterSecure),
|
||||
ImagePullPolicy: core.PullIfNotPresent,
|
||||
SecurityContext: securityContext.NewSecurityContext(),
|
||||
}
|
||||
}
|
||||
|
||||
func testCreateExporterContainerWithPort(secure bool, resources core.ResourceRequirements, port uint16) core.Container {
|
||||
return testCreateExporterContainerWithPortAndSecureEndpoint(secure, secure, resources, port)
|
||||
}
|
||||
|
||||
func testCreateExporterContainer(secure bool, resources core.ResourceRequirements) core.Container {
|
||||
return testCreateExporterContainerWithPortAndSecureEndpoint(secure, secure, resources, k8sutil.ArangoExporterPort)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,7 @@
|
|||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Author Adam Janikowski
|
||||
// Author Tomasz Mielech
|
||||
//
|
||||
|
||||
package features
|
||||
|
@ -34,6 +35,7 @@ type Feature interface {
|
|||
EnabledByDefault() bool
|
||||
Enabled() bool
|
||||
EnabledPointer() *bool
|
||||
Deprecated() (bool, string)
|
||||
Supported(v driver.Version, enterprise bool) bool
|
||||
}
|
||||
|
||||
|
@ -41,6 +43,8 @@ type feature struct {
|
|||
name, description string
|
||||
version driver.Version
|
||||
enterpriseRequired, enabledByDefault, enabled bool
|
||||
deprecated string
|
||||
constValue *bool
|
||||
}
|
||||
|
||||
func (f feature) Supported(v driver.Version, enterprise bool) bool {
|
||||
|
@ -48,6 +52,10 @@ func (f feature) Supported(v driver.Version, enterprise bool) bool {
|
|||
}
|
||||
|
||||
func (f feature) Enabled() bool {
|
||||
if f.constValue != nil {
|
||||
return *f.constValue
|
||||
}
|
||||
|
||||
return f.enabled
|
||||
}
|
||||
|
||||
|
@ -74,3 +82,8 @@ func (f feature) Name() string {
|
|||
func (f feature) Description() string {
|
||||
return f.description
|
||||
}
|
||||
|
||||
// Deprecated returns true if the feature is deprecated and the reason why it is deprecated.
|
||||
func (f feature) Deprecated() (bool, string) {
|
||||
return len(f.deprecated) > 0, f.deprecated
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,7 @@
|
|||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Author Adam Janikowski
|
||||
// Author Tomasz Mielech
|
||||
//
|
||||
|
||||
package features
|
||||
|
@ -80,11 +81,16 @@ func Init(cmd *cobra.Command) {
|
|||
}
|
||||
}
|
||||
|
||||
f.BoolVar(feature.EnabledPointer(), fmt.Sprintf("deployment.feature.%s", feature.Name()), feature.EnabledByDefault(), z)
|
||||
featureName := fmt.Sprintf("deployment.feature.%s", feature.Name())
|
||||
if ok, reason := feature.Deprecated(); ok {
|
||||
f.MarkDeprecated(featureName, reason)
|
||||
}
|
||||
|
||||
f.BoolVar(feature.EnabledPointer(), featureName, feature.EnabledByDefault(), z)
|
||||
}
|
||||
}
|
||||
|
||||
func cmdRun(cmd *cobra.Command, args []string) {
|
||||
func cmdRun(_ *cobra.Command, _ []string) {
|
||||
featuresLock.Lock()
|
||||
defer featuresLock.Unlock()
|
||||
|
||||
|
@ -106,6 +112,10 @@ func cmdRun(cmd *cobra.Command, args []string) {
|
|||
println("ArangoDB Edition Required: Community, Enterprise")
|
||||
}
|
||||
|
||||
if ok, reason := feature.Deprecated(); ok {
|
||||
println(fmt.Sprintf("Deprecated: %s", reason))
|
||||
}
|
||||
|
||||
println()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,15 @@
|
|||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Author Adam Janikowski
|
||||
// Author Tomasz Mielech
|
||||
//
|
||||
|
||||
package features
|
||||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registerFeature(metricsExporter)
|
||||
}
|
||||
|
@ -32,6 +37,8 @@ var metricsExporter = &feature{
|
|||
version: "3.6.0",
|
||||
enterpriseRequired: false,
|
||||
enabledByDefault: true,
|
||||
deprecated: "It is always set to True",
|
||||
constValue: util.NewBool(true),
|
||||
}
|
||||
|
||||
func MetricsExporter() Feature {
|
||||
|
|
Loading…
Reference in a new issue