1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Feature] Configurable ArangoD Port (#1199)

This commit is contained in:
Adam Janikowski 2022-12-08 08:59:50 +01:00 committed by GitHub
parent 2ca875da07
commit 2ffd238f75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 563 additions and 211 deletions

View file

@ -34,6 +34,7 @@
- (Feature) Pre OOM Abort function
- (Bugfix) Fix ErrorArray String function
- (Feature) Switch services to Port names
- (Feature) Configurable ArangoD Port
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
- (Feature) Add action progress

View file

@ -43,9 +43,14 @@ import (
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
"github.com/arangodb/kube-arangodb/pkg/deployment/resources"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/constants"
)
const (
ProbePort util.EnvironmentVariable = "ARANGODB_SERVER_PORT"
)
var (
cmdLifecycleProbe = &cobra.Command{
Use: "probe",
@ -118,7 +123,9 @@ func probeEndpoint(endpoint string) string {
proto = "https"
}
return fmt.Sprintf("%s://%s:%d%s", proto, "127.0.0.1", shared.ArangoPort, endpoint)
port := ProbePort.GetOrDefault(fmt.Sprintf("%d", shared.ArangoPort))
return fmt.Sprintf("%s://%s:%s%s", proto, "127.0.0.1", port, endpoint)
}
func readJWTFile(file string) ([]byte, error) {

View file

@ -40,8 +40,10 @@ var cmdLifecycleStartup = &cobra.Command{
func cmdLifecycleStartupFunc(cmd *cobra.Command, args []string) error {
var close bool
port := ProbePort.GetOrDefault(fmt.Sprintf("%d", shared.ArangoPort))
server := &http.Server{
Addr: fmt.Sprintf(":%d", shared.ArangoPort),
Addr: fmt.Sprintf(":%s", port),
}
handlers := http.NewServeMux()

View file

@ -560,3 +560,8 @@ func (s DeploymentSpec) GetCoreContainers(group ServerGroup) utils.StringList {
return result
}
func (s DeploymentSpec) GetGroupPort(group ServerGroup) uint16 {
spec := s.GetServerGroupSpec(group)
return spec.GetPort()
}

View file

@ -160,6 +160,10 @@ type ServerGroupSpec struct {
// PodModes define additional modes enabled on the Pod level
PodModes *ServerGroupSpecPodMode `json:"podModes,omitempty"`
// Port define Port used by member
Port *uint16 `json:"port,omitempty"`
// ExporterPort define Port used by exporter
ExporterPort *uint16 `json:"exporterPort,omitempty"`
}
// ServerGroupProbesSpec contains specification for probes for pods of the server group
@ -672,3 +676,30 @@ func (s *ServerGroupSpec) Group() ServerGroup {
return s.group
}
func (s *ServerGroupSpec) GetPort() uint16 {
if s != nil {
if p := s.Port; p != nil {
return *p
}
}
switch s.Group() {
case ServerGroupSyncMasters:
return shared.ArangoSyncMasterPort
case ServerGroupSyncWorkers:
return shared.ArangoSyncWorkerPort
default:
return shared.ArangoPort
}
}
func (s *ServerGroupSpec) GetExporterPort() uint16 {
if s != nil {
if p := s.ExporterPort; p != nil {
return *p
}
}
return shared.ArangoExporterPort
}

View file

@ -2445,6 +2445,16 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) {
*out = new(ServerGroupSpecPodMode)
(*in).DeepCopyInto(*out)
}
if in.Port != nil {
in, out := &in.Port, &out.Port
*out = new(uint16)
**out = **in
}
if in.ExporterPort != nil {
in, out := &in.ExporterPort, &out.ExporterPort
*out = new(uint16)
**out = **in
}
return
}

View file

@ -560,3 +560,8 @@ func (s DeploymentSpec) GetCoreContainers(group ServerGroup) utils.StringList {
return result
}
func (s DeploymentSpec) GetGroupPort(group ServerGroup) uint16 {
spec := s.GetServerGroupSpec(group)
return spec.GetPort()
}

View file

@ -160,6 +160,10 @@ type ServerGroupSpec struct {
// PodModes define additional modes enabled on the Pod level
PodModes *ServerGroupSpecPodMode `json:"podModes,omitempty"`
// Port define Port used by member
Port *uint16 `json:"port,omitempty"`
// ExporterPort define Port used by exporter
ExporterPort *uint16 `json:"exporterPort,omitempty"`
}
// ServerGroupProbesSpec contains specification for probes for pods of the server group
@ -672,3 +676,30 @@ func (s *ServerGroupSpec) Group() ServerGroup {
return s.group
}
func (s *ServerGroupSpec) GetPort() uint16 {
if s != nil {
if p := s.Port; p != nil {
return *p
}
}
switch s.Group() {
case ServerGroupSyncMasters:
return shared.ArangoSyncMasterPort
case ServerGroupSyncWorkers:
return shared.ArangoSyncWorkerPort
default:
return shared.ArangoPort
}
}
func (s *ServerGroupSpec) GetExporterPort() uint16 {
if s != nil {
if p := s.ExporterPort; p != nil {
return *p
}
}
return shared.ArangoExporterPort
}

View file

@ -2445,6 +2445,16 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) {
*out = new(ServerGroupSpecPodMode)
(*in).DeepCopyInto(*out)
}
if in.Port != nil {
in, out := &in.Port, &out.Port
*out = new(uint16)
**out = **in
}
if in.ExporterPort != nil {
in, out := &in.ExporterPort, &out.ExporterPort
*out = new(uint16)
**out = **in
}
return
}

View file

@ -97,7 +97,7 @@ func TestEnsurePod_ArangoDB_AntiAffinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -159,7 +159,7 @@ func TestEnsurePod_ArangoDB_AntiAffinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -224,7 +224,7 @@ func TestEnsurePod_ArangoDB_AntiAffinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -294,7 +294,7 @@ func TestEnsurePod_ArangoDB_AntiAffinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -373,7 +373,7 @@ func TestEnsurePod_ArangoDB_Affinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -438,7 +438,7 @@ func TestEnsurePod_ArangoDB_Affinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -506,7 +506,7 @@ func TestEnsurePod_ArangoDB_Affinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -579,7 +579,7 @@ func TestEnsurePod_ArangoDB_Affinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -660,7 +660,7 @@ func TestEnsurePod_ArangoDB_NodeAffinity(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -74,7 +74,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullAlways,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -125,7 +125,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullAlways,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -185,7 +185,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -242,7 +242,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -307,7 +307,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -362,7 +362,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -419,7 +419,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -479,7 +479,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -539,7 +539,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -591,7 +591,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -648,7 +648,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -701,7 +701,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.TlsKeyfileVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, true, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, true, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -740,8 +740,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false,
authorization, shared.ArangoPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
},
ExpectedEvent: "member agent is created",
ExpectedPod: core.Pod{
@ -800,8 +799,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true,
authorization, shared.ArangoPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, authorization, shared.ServerPortName)
},
ExpectedEvent: "member agent is created",
ExpectedPod: core.Pod{
@ -879,7 +877,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.RocksdbEncryptionVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -919,8 +917,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false,
authorization, shared.ArangoPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
},
ExpectedEvent: "member dbserver is created",
ExpectedPod: core.Pod{
@ -988,8 +985,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false,
authorization, shared.ArangoPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
},
ExpectedEvent: "member dbserver is created",
ExpectedPod: core.Pod{
@ -1053,8 +1049,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false,
authorization, shared.ArangoPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
},
config: Config{
OperatorImage: testImageOperator,
@ -1124,8 +1119,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false,
authorization, shared.ArangoPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
},
config: Config{
OperatorImage: testImageOperator,
@ -1260,8 +1254,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authReadiness, err := createTestToken(deployment, testCase, []string{"/_admin/server/availability"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true,
authLiveness, 0)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, authLiveness, shared.ServerPortName)
testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(httpProbe, true, authReadiness)
},
ExpectedEvent: "member single is created",
@ -1297,6 +1290,143 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
},
},
},
{
Name: "Single Pod with TLS and authentication and readiness and port override",
ArangoDeployment: &api.ArangoDeployment{
Spec: api.DeploymentSpec{
Image: util.NewString(testImage),
Authentication: authenticationSpec,
TLS: api.TLSSpec{
CASecretName: util.NewString(testCASecretName),
},
Single: api.ServerGroupSpec{
Port: util.NewUInt16(18529),
},
},
},
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
deployment.currentObjectStatus = &api.DeploymentStatus{
Members: api.DeploymentStatusMembers{
Single: api.MemberStatusList{
singleStatus,
},
},
Images: createTestImages(false),
}
testCase.createTestPodData(deployment, api.ServerGroupSingle, singleStatus)
authLiveness, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
authReadiness, err := createTestToken(deployment, testCase, []string{"/_admin/server/availability"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, authLiveness, shared.ServerPortName)
testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(httpProbe, true, authReadiness)
},
ExpectedEvent: "member single is created",
ExpectedPod: core.Pod{
Spec: core.PodSpec{
Volumes: []core.Volume{
k8sutil.CreateVolumeEmptyDir(shared.ArangodVolumeName),
createTestTLSVolume(api.ServerGroupSingleString, singleStatus.ID),
k8sutil.CreateVolumeWithSecret(shared.ClusterJWTSecretVolumeName, testJWTSecretName),
},
Containers: []core.Container{
{
Name: shared.ServerContainerName,
Image: testImage,
Command: createTestCommandForSingleModeWithPortOverride(true, true, 18529),
Ports: createTestPorts(api.ServerGroupSingle, 18529),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
k8sutil.TlsKeyfileVolumeMount(),
k8sutil.ClusterJWTVolumeMount(),
},
Resources: emptyResources,
},
},
RestartPolicy: core.RestartPolicyNever,
TerminationGracePeriodSeconds: &defaultSingleTerminationTimeout,
Hostname: testDeploymentName + "-" + api.ServerGroupSingleString + "-" + singleStatus.ID,
Subdomain: testDeploymentName + "-int",
Affinity: k8sutil.CreateAffinity(testDeploymentName, api.ServerGroupSingleString,
false, ""),
},
},
},
{
Name: "Coordinator Pod with TLS and authentication and readiness and liveness and custom port",
Features: testCaseFeatures{
JWTRotation: true,
},
ArangoDeployment: &api.ArangoDeployment{
Spec: api.DeploymentSpec{
Image: util.NewString(testImage),
Authentication: authenticationSpec,
Environment: api.NewEnvironment(api.EnvironmentProduction),
TLS: api.TLSSpec{
CASecretName: util.NewString(testCASecretName),
},
Coordinators: api.ServerGroupSpec{
Port: util.NewUInt16(18529),
},
},
},
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
deployment.currentObjectStatus = &api.DeploymentStatus{
Members: api.DeploymentStatusMembers{
Coordinators: api.MemberStatusList{
firstCoordinatorStatus,
},
},
Images: createTestImages(false),
}
testCase.createTestPodData(deployment, api.ServerGroupCoordinators, firstCoordinatorStatus)
auth, err := createTestToken(deployment, testCase, []string{"/_admin/server/availability"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(cmdProbe, true, auth)
testCase.ExpectedPod.Spec.Containers[0].StartupProbe = createTestStartupProbe(cmdProbe, true, auth, 720)
},
ExpectedEvent: "member coordinator is created",
ExpectedPod: core.Pod{
Spec: core.PodSpec{
Volumes: []core.Volume{
k8sutil.CreateVolumeEmptyDir(shared.ArangodVolumeName),
createTestTLSVolume(api.ServerGroupCoordinatorsString, firstCoordinatorStatus.ID),
k8sutil.CreateVolumeWithSecret(shared.ClusterJWTSecretVolumeName, testJWTSecretName),
},
Containers: []core.Container{
{
Name: shared.ServerContainerName,
Image: testImage,
Command: createTestCommandForCoordinatorWithPort(firstCoordinatorStatus.ID, true, true, 18529),
Ports: createTestPorts(api.ServerGroupCoordinators, 18529),
ImagePullPolicy: core.PullIfNotPresent,
Resources: emptyResources,
SecurityContext: securityContext.NewSecurityContext(),
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
k8sutil.TlsKeyfileVolumeMount(),
k8sutil.ClusterJWTVolumeMount(),
},
},
},
RestartPolicy: core.RestartPolicyNever,
TerminationGracePeriodSeconds: &defaultCoordinatorTerminationTimeout,
Hostname: testDeploymentName + "-" + api.ServerGroupCoordinatorsString + "-" + firstCoordinatorStatus.ID,
Subdomain: testDeploymentName + "-int",
Affinity: k8sutil.CreateAffinity(testDeploymentName, api.ServerGroupCoordinatorsString,
true, ""),
},
},
},
}
runTestCases(t, testCases...)

View file

@ -81,7 +81,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
k8sutil.RocksdbEncryptionVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -129,8 +129,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true,
authorization, shared.ArangoPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, authorization, shared.ServerPortName)
},
config: Config{
OperatorImage: testImageOperator,
@ -156,7 +155,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
Command: createTestCommandForDBServer(firstDBServerStatus.ID, true, true, true),
Ports: createTestPorts(api.ServerGroupDBServers),
Lifecycle: createTestLifecycle(api.ServerGroupAgents),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
VolumeMounts: []core.VolumeMount{
@ -229,7 +228,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
k8sutil.RocksdbEncryptionVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -296,7 +295,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
k8sutil.RocksdbEncryptionReadOnlyVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -77,7 +77,7 @@ func TestEnsurePod_ArangoDB_Features(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -140,7 +140,7 @@ func TestEnsurePod_ArangoDB_Features(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -362,7 +362,7 @@ func TestEnsurePod_ArangoDB_Features(t *testing.T) {
testCase.createTestPodData(deployment, api.ServerGroupSingle, singleStatus)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, "", 0)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName)
testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(httpProbe, false, "")
},
ExpectedEvent: "member single is created",
@ -427,7 +427,7 @@ func TestEnsurePod_ArangoDB_Features(t *testing.T) {
testCase.createTestPodData(deployment, api.ServerGroupSingle, singleStatus)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, "", 0)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName)
testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(httpProbe, false, "")
},
ExpectedEvent: "member single is created",
@ -492,7 +492,7 @@ func TestEnsurePod_ArangoDB_Features(t *testing.T) {
testCase.createTestPodData(deployment, api.ServerGroupSingle, singleStatus)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, "", 0)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName)
testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(httpProbe, false, "")
},
ExpectedEvent: "member single is created",

View file

@ -89,7 +89,7 @@ func TestEnsurePod_ArangoDB_ImagePropagation(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullAlways,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -141,7 +141,7 @@ func TestEnsurePod_ArangoDB_ImagePropagation(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullAlways,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -193,7 +193,7 @@ func TestEnsurePod_ArangoDB_ImagePropagation(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullAlways,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -78,7 +78,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -138,7 +138,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -207,7 +207,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -275,7 +275,7 @@ func TestEnsurePod_Metrics(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -77,7 +77,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -134,7 +134,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: modTestLivenessProbe(httpProbe, false, "", shared.ArangoPort, func(probe *core.Probe) {
LivenessProbe: modTestLivenessProbe(httpProbe, false, "", shared.ServerPortName, func(probe *core.Probe) {
probe.TimeoutSeconds = 50
}),
ImagePullPolicy: core.PullIfNotPresent,
@ -192,7 +192,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ReadinessProbe: createTestReadinessSimpleProbe(httpProbe, false, ""),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
@ -243,7 +243,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -299,7 +299,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ReadinessProbe: createTestReadinessSimpleProbe(httpProbe, false, ""),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
@ -406,7 +406,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ReadinessProbe: createTestReadinessProbe(httpProbe, false, ""),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
@ -464,7 +464,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(cmdProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(cmdProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -518,7 +518,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -572,7 +572,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -679,7 +679,7 @@ func TestEnsurePod_ArangoDB_Probe(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -135,7 +135,7 @@ func TestEnsurePod_ArangoDB_Resources(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -194,7 +194,7 @@ func TestEnsurePod_ArangoDB_Resources(t *testing.T) {
k8sutil.ArangodVolumeMount(),
},
Env: withEnvs(resourceCPULimitAsEnv(t, resourcesUnfiltered)),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -250,7 +250,7 @@ func TestEnsurePod_ArangoDB_Resources(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -229,8 +229,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -319,8 +318,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -424,8 +422,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -526,8 +523,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -628,8 +624,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -733,8 +728,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -833,8 +827,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -940,8 +933,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -1057,8 +1049,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -1172,8 +1163,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{
@ -1284,8 +1274,7 @@ func TestEnsurePod_Sync_Worker(t *testing.T) {
auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(
"", true, "bearer "+auth, shared.ArangoSyncWorkerPort)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
},
ExpectedEvent: "member syncworker is created",
ExpectedPod: core.Pod{

View file

@ -452,7 +452,7 @@ func TestEnsurePod_ArangoDB_TLS_SNI(t *testing.T) {
k8sutil.TlsKeyfileVolumeMount(),
},
Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, true, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, true, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -96,7 +96,7 @@ func TestEnsurePod_ArangoDB_Volumes(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -157,7 +157,7 @@ func TestEnsurePod_ArangoDB_Volumes(t *testing.T) {
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
@ -220,7 +220,7 @@ func TestEnsurePod_ArangoDB_Volumes(t *testing.T) {
k8sutil.ArangodVolumeMount(),
createExampleVolumeMount("volume").VolumeMount(),
},
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},

View file

@ -22,6 +22,7 @@ package deployment
import (
"context"
"fmt"
"os"
"path/filepath"
"sort"
@ -124,7 +125,7 @@ func createTestToken(deployment *Deployment, testCase *testCaseStruct, paths []s
return jwt.CreateArangodJwtAuthorizationHeaderAllowedPaths(s, "kube-arangodb", paths)
}
func modTestLivenessProbe(mode string, secure bool, authorization string, port int, mod func(*core.Probe)) *core.Probe {
func modTestLivenessProbe(mode string, secure bool, authorization string, port string, mod func(*core.Probe)) *core.Probe {
probe := createTestLivenessProbe(mode, secure, authorization, port)
mod(probe)
@ -141,12 +142,12 @@ func createTestReadinessSimpleProbe(mode string, secure bool, authorization stri
return probe
}
func createTestLivenessProbe(mode string, secure bool, authorization string, port int) *core.Probe {
func createTestLivenessProbe(mode string, secure bool, authorization string, port string) *core.Probe {
return getProbeCreator(mode)(secure, authorization, "/_api/version", port, api.ProbeTypeLiveness).Create()
}
func createTestReadinessProbe(mode string, secure bool, authorization string) *core.Probe {
p := getProbeCreator(mode)(secure, authorization, "/_admin/server/availability", shared.ArangoPort,
p := getProbeCreator(mode)(secure, authorization, "/_admin/server/availability", shared.ServerPortName,
api.ProbeTypeReadiness).Create()
p.InitialDelaySeconds = 2
@ -156,7 +157,7 @@ func createTestReadinessProbe(mode string, secure bool, authorization string) *c
}
func createTestStartupProbe(mode string, secure bool, authorization string, failureThreshold int32) *core.Probe {
p := getProbeCreator(mode)(secure, authorization, "/_api/version", shared.ArangoPort, api.ProbeTypeStartUp).Create()
p := getProbeCreator(mode)(secure, authorization, "/_api/version", shared.ServerPortName, api.ProbeTypeStartUp).Create()
p.InitialDelaySeconds = 1
p.PeriodSeconds = 5
@ -165,7 +166,7 @@ func createTestStartupProbe(mode string, secure bool, authorization string, fail
return p
}
type probeCreator func(secure bool, authorization, endpoint string, port int, probe api.ProbeType) resources.Probe
type probeCreator func(secure bool, authorization, endpoint string, port string, probe api.ProbeType) resources.Probe
const (
cmdProbe = "cmdProbe"
@ -182,13 +183,13 @@ func getProbeCreator(t string) probeCreator {
}
func getHTTPProbeCreator() probeCreator {
return func(secure bool, authorization, endpoint string, port int, _ api.ProbeType) resources.Probe {
return func(secure bool, authorization, endpoint string, port string, _ api.ProbeType) resources.Probe {
return createHTTPTestProbe(secure, authorization, endpoint, port)
}
}
func getCMDProbeCreator() probeCreator {
return func(secure bool, authorization, endpoint string, port int, probeType api.ProbeType) resources.Probe {
return func(secure bool, authorization, endpoint string, _ string, probeType api.ProbeType) resources.Probe {
return createCMDTestProbe(secure, authorization != "", probeType)
}
}
@ -215,12 +216,12 @@ func createCMDTestProbe(secure, authorization bool, probeType api.ProbeType) res
}
}
func createHTTPTestProbe(secure bool, authorization string, endpoint string, port int) resources.Probe {
func createHTTPTestProbe(secure bool, authorization string, endpoint string, port string) resources.Probe {
return &probes.HTTPProbeConfig{
LocalPath: endpoint,
Secure: secure,
Authorization: authorization,
Port: port,
PortName: port,
}
}
@ -279,6 +280,55 @@ func createTestCommandForDBServer(name string, tls, auth, encryptionRocksDB bool
return append(command, sorted...)
}
func createTestCommandForCoordinatorWithPort(name string, tls, auth bool, port int, mods ...func() k8sutil.OptionPairs) []string {
command := []string{resources.ArangoDExecutor}
args := k8sutil.OptionPairs{}
if tls {
args.Addf("--cluster.my-address", "ssl://%s-%s-%s.test-int.default.svc:8529",
testDeploymentName,
api.ServerGroupCoordinatorsString,
name)
} else {
args.Addf("--cluster.my-address", "tcp://%s-%s-%s.test-int.default.svc:8529",
testDeploymentName,
api.ServerGroupCoordinatorsString,
name)
}
args.Add("--cluster.my-role", "COORDINATOR")
args.Add("--database.directory", "/data")
args.Add("--foxx.queues", "true")
args.Add("--log.level", "INFO")
args.Add("--log.output", "+")
args.Add("--server.authentication", auth)
if tls {
args.Addf("--server.endpoint", "ssl://[::]:%d", port)
} else {
args.Addf("--server.endpoint", "tcp://[::]:%d", port)
}
if auth {
args.Add("--server.jwt-secret-keyfile", "/secrets/cluster/jwt/token")
}
args.Add("--server.statistics", "true")
args.Add("--server.storage-engine", "rocksdb")
if tls {
args.Add("--ssl.ecdh-curve", "")
args.Add("--ssl.keyfile", "/secrets/tls/tls.keyfile")
}
for _, mod := range mods {
args.Merge(mod())
}
return append(command, args.Unique().AsArgs()...)
}
func createTestCommandForCoordinator(name string, tls, auth bool, mods ...func() k8sutil.OptionPairs) []string {
command := []string{resources.ArangoDExecutor}
@ -328,6 +378,42 @@ func createTestCommandForCoordinator(name string, tls, auth bool, mods ...func()
return append(command, args.Unique().AsArgs()...)
}
func createTestCommandForSingleModeWithPortOverride(tls, auth bool, port int, mods ...func() k8sutil.OptionPairs) []string {
command := []string{resources.ArangoDExecutor}
args := k8sutil.OptionPairs{}
args.Add("--database.directory", "/data")
args.Add("--foxx.queues", "true")
args.Add("--log.level", "INFO")
args.Add("--log.output", "+")
args.Add("--server.authentication", auth)
if tls {
args.Addf("--server.endpoint", "ssl://[::]:%d", port)
} else {
args.Addf("--server.endpoint", "tcp://[::]:%d", port)
}
if auth {
args.Add("--server.jwt-secret-keyfile", "/secrets/cluster/jwt/token")
}
args.Add("--server.statistics", "true")
args.Add("--server.storage-engine", "rocksdb")
if tls {
args.Add("--ssl.ecdh-curve", "")
args.Add("--ssl.keyfile", "/secrets/tls/tls.keyfile")
}
for _, mod := range mods {
args.Merge(mod())
}
return append(command, args.Unique().AsArgs()...)
}
func createTestCommandForSingleMode(tls, auth bool, mods ...func() k8sutil.OptionPairs) []string {
command := []string{resources.ArangoDExecutor}
@ -530,7 +616,7 @@ func createTestDeployment(t *testing.T, config Config, arangoDeployment *api.Ara
return d, eventRecorder
}
func createTestPorts(group api.ServerGroup) []core.ContainerPort {
func createTestPorts(group api.ServerGroup, ports ...int) []core.ContainerPort {
port := shared.ArangoPort
switch group {
@ -540,6 +626,10 @@ func createTestPorts(group api.ServerGroup) []core.ContainerPort {
port = shared.ArangoSyncWorkerPort
}
if len(ports) > 0 {
port = ports[0]
}
return []core.ContainerPort{
{
Name: "server",
@ -568,7 +658,7 @@ func createTestImages(enterprise bool) api.ImageInfoList {
func createTestExporterLivenessProbe(secure bool) *core.Probe {
return probes.HTTPProbeConfig{
LocalPath: "/",
Port: shared.ArangoExporterPort,
PortName: shared.ExporterPortName,
Secure: secure,
}.Create()
}
@ -819,68 +909,84 @@ func addLifecycle(name string, uuidRequired bool, license string, group api.Serv
func (testCase *testCaseStruct) createTestEnvVariables(deployment *Deployment, group api.ServerGroup) {
if group == api.ServerGroupSyncMasters || group == api.ServerGroupSyncWorkers {
return
}
// Set up environment variables.
} else {
// Set up environment variables.
for i, container := range testCase.ExpectedPod.Spec.Containers {
if container.Name != api.ServerGroupReservedContainerNameServer {
continue
}
testCase.ExpectedPod.Spec.Containers[i].EnvFrom = []core.EnvFromSource{
{
ConfigMapRef: &core.ConfigMapEnvSource{
LocalObjectReference: core.LocalObjectReference{
Name: features.ConfigMapName(),
},
Optional: util.NewBool(true),
},
},
}
var version, enterprise string
if len(deployment.currentObjectStatus.Images) > 0 {
version = string(deployment.currentObjectStatus.Images[0].ArangoDBVersion)
enterprise = strconv.FormatBool(deployment.currentObjectStatus.Images[0].Enterprise)
}
if version == "" {
version = testVersion
}
if enterprise == "" {
enterprise = "false"
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideServerGroupEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideServerGroupEnv,
Value: group.AsRole(),
})
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideDeploymentModeEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideDeploymentModeEnv,
Value: string(testCase.ArangoDeployment.Spec.GetMode()),
})
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideVersionEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideVersionEnv,
Value: version,
})
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideEnterpriseEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideEnterpriseEnv,
Value: enterprise,
})
}
}
}
for i, container := range testCase.ExpectedPod.Spec.Containers {
if container.Name != api.ServerGroupReservedContainerNameServer {
continue
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBServerPortEnv) {
gs := deployment.GetSpec().GetServerGroupSpec(group)
testCase.ExpectedPod.Spec.Containers[i].EnvFrom = []core.EnvFromSource{
{
ConfigMapRef: &core.ConfigMapEnvSource{
LocalObjectReference: core.LocalObjectReference{
Name: features.ConfigMapName(),
},
Optional: util.NewBool(true),
},
},
}
var version, enterprise string
if len(deployment.currentObjectStatus.Images) > 0 {
version = string(deployment.currentObjectStatus.Images[0].ArangoDBVersion)
enterprise = strconv.FormatBool(deployment.currentObjectStatus.Images[0].Enterprise)
}
if version == "" {
version = testVersion
}
if enterprise == "" {
enterprise = "false"
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideServerGroupEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideServerGroupEnv,
Value: group.AsRole(),
})
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideDeploymentModeEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideDeploymentModeEnv,
Value: string(testCase.ArangoDeployment.Spec.GetMode()),
})
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideVersionEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideVersionEnv,
Value: version,
})
}
if !isEnvExist(testCase.ExpectedPod.Spec.Containers[i].Env, resources.ArangoDBOverrideEnterpriseEnv) {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBOverrideEnterpriseEnv,
Value: enterprise,
})
if p := gs.Port; p != nil {
testCase.ExpectedPod.Spec.Containers[i].Env = append(testCase.ExpectedPod.Spec.Containers[i].Env,
core.EnvVar{
Name: resources.ArangoDBServerPortEnv,
Value: fmt.Sprintf("%d", *p),
})
}
}
}
}

View file

@ -45,7 +45,7 @@ func createInternalExporterArgs(spec api.DeploymentSpec, groupSpec api.ServerGro
if spec.IsSecure() {
scheme = "https"
}
options.Addf("--arangodb.endpoint", "%s://localhost:%d%s", scheme, shared.ArangoPort, path)
options.Addf("--arangodb.endpoint", "%s://localhost:%d%s", scheme, groupSpec.GetPort(), path)
} else {
options.Addf("--arangodb.endpoint", "http://localhost:%d%s", *port, path)
}
@ -55,7 +55,17 @@ func createInternalExporterArgs(spec api.DeploymentSpec, groupSpec api.ServerGro
options.Add("--ssl.keyfile", keyPath)
}
if port := spec.Metrics.GetPort(); port != shared.ArangoExporterPort {
var port uint16 = shared.ArangoExporterPort
if p := spec.Metrics.Port; p != nil {
port = *p
}
if p := groupSpec.ExporterPort; p != nil {
port = *p
}
if port != shared.ArangoExporterPort {
options.Addf("--server.address", ":%d", port)
}
@ -73,7 +83,7 @@ func getArangoExporterInternalEndpoint(version driver.Version) string {
func createExporterLivenessProbe(isSecure bool) *probes.HTTPProbeConfig {
probeCfg := &probes.HTTPProbeConfig{
LocalPath: "/",
Port: shared.ArangoExporterPort,
PortName: shared.ExporterPortName,
Secure: isSecure,
}

View file

@ -29,11 +29,20 @@ import (
// ArangodbInternalExporterContainer creates metrics container based on internal exporter
func ArangodbInternalExporterContainer(image string, args []string, livenessProbe *probes.HTTPProbeConfig,
resources core.ResourceRequirements, securityContext *core.SecurityContext,
spec api.DeploymentSpec) (core.Container, error) {
resources core.ResourceRequirements, spec api.DeploymentSpec, groupSpec api.ServerGroupSpec) (core.Container, error) {
exePath := k8sutil.LifecycleBinary()
var port uint16 = shared.ArangoExporterPort
if p := spec.Metrics.Port; p != nil {
port = *p
}
if p := groupSpec.ExporterPort; p != nil {
port = *p
}
c := core.Container{
Name: shared.ExporterContainerName,
Image: image,
@ -41,13 +50,13 @@ func ArangodbInternalExporterContainer(image string, args []string, livenessProb
Ports: []core.ContainerPort{
{
Name: "exporter",
ContainerPort: int32(spec.Metrics.GetPort()),
ContainerPort: int32(port),
Protocol: core.ProtocolTCP,
},
},
Resources: k8sutil.ExtractPodResourceRequirement(resources),
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext,
SecurityContext: groupSpec.SecurityContext.NewSecurityContext(),
VolumeMounts: []core.VolumeMount{k8sutil.LifecycleVolumeMount()},
}

View file

@ -68,7 +68,7 @@ func createArangodArgs(cachedStatus interfaces.Inspector, input pod.Input, addit
}
if input.GroupSpec.GetExternalPortEnabled() {
options.Addf("--server.endpoint", "%s://%s:%d", scheme, input.Deployment.GetListenAddr(), shared.ArangoPort)
options.Addf("--server.endpoint", "%s://%s:%d", scheme, input.Deployment.GetListenAddr(), input.GroupSpec.GetPort())
}
if port := input.GroupSpec.InternalPort; port != nil {
@ -192,12 +192,8 @@ func createArangoSyncArgs(apiObject meta.Object, spec api.DeploymentSpec, group
groupSpec api.ServerGroupSpec, member api.MemberStatus) []string {
options := k8sutil.CreateOptionPairs(64)
var runCmd string
var port int
port := groupSpec.GetPort()
/*if config.DebugCluster {
options = append(options,
k8sutil.OptionPair{"--log.level", "debug"})
}*/
if spec.Sync.Monitoring.GetTokenSecretName() != "" {
options.Addf("--monitoring.token", "$(%s)", constants.EnvArangoSyncMonitoringToken)
}
@ -208,8 +204,7 @@ func createArangoSyncArgs(apiObject meta.Object, spec api.DeploymentSpec, group
switch group {
case api.ServerGroupSyncMasters:
runCmd = "master"
port = shared.ArangoSyncMasterPort
masterEndpoint = spec.Sync.ExternalAccess.ResolveMasterEndpoint(k8sutil.CreateSyncMasterClientServiceDNSNameWithDomain(apiObject, spec.ClusterDomain), port)
masterEndpoint = spec.Sync.ExternalAccess.ResolveMasterEndpoint(k8sutil.CreateSyncMasterClientServiceDNSNameWithDomain(apiObject, spec.ClusterDomain), int(port))
keyPath := filepath.Join(shared.TLSKeyfileVolumeMountDir, constants.SecretTLSKeyfile)
clientCAPath := filepath.Join(shared.ClientAuthCAVolumeMountDir, constants.SecretCACertificate)
options.Add("--server.keyfile", keyPath)
@ -227,16 +222,15 @@ func createArangoSyncArgs(apiObject meta.Object, spec api.DeploymentSpec, group
options.Addf("--cluster.endpoint", "%s://%s:%d", scheme, dbServiceName, shared.ArangoPort)
case api.ServerGroupSyncWorkers:
runCmd = "worker"
port = shared.ArangoSyncWorkerPort
masterEndpointHost := k8sutil.CreateSyncMasterClientServiceName(apiObject.GetName())
masterEndpoint = []string{"https://" + net.JoinHostPort(masterEndpointHost, strconv.Itoa(shared.ArangoSyncMasterPort))}
}
for _, ep := range masterEndpoint {
options.Add("--master.endpoint", ep)
}
serverEndpoint := "https://" + net.JoinHostPort(k8sutil.CreatePodDNSNameWithDomain(apiObject, spec.ClusterDomain, group.AsRole(), member.ID), strconv.Itoa(port))
serverEndpoint := "https://" + net.JoinHostPort(k8sutil.CreatePodDNSNameWithDomain(apiObject, spec.ClusterDomain, group.AsRole(), member.ID), strconv.Itoa(int(port)))
options.Add("--server.endpoint", serverEndpoint)
options.Add("--server.port", strconv.Itoa(port))
options.Add("--server.port", strconv.Itoa(int(port)))
args := []string{
"run",

View file

@ -49,6 +49,7 @@ const (
ArangoDBOverrideDeploymentModeEnv = "ARANGODB_OVERRIDE_DEPLOYMENT_MODE"
ArangoDBOverrideVersionEnv = "ARANGODB_OVERRIDE_VERSION"
ArangoDBOverrideEnterpriseEnv = "ARANGODB_OVERRIDE_ENTERPRISE"
ArangoDBServerPortEnv = "ARANGODB_SERVER_PORT"
)
var _ interfaces.PodCreator = &MemberArangoDPod{}
@ -100,7 +101,7 @@ func (a *ArangoDContainer) GetPorts() []core.ContainerPort {
ports := []core.ContainerPort{
{
Name: shared.ServerPortName,
ContainerPort: int32(shared.ArangoPort),
ContainerPort: int32(a.groupSpec.GetPort()),
Protocol: core.ProtocolTCP,
},
}
@ -110,7 +111,7 @@ func (a *ArangoDContainer) GetPorts() []core.ContainerPort {
case api.MetricsModeInternal:
ports = append(ports, core.ContainerPort{
Name: shared.ExporterPortName,
ContainerPort: int32(shared.ArangoPort),
ContainerPort: int32(a.groupSpec.GetPort()),
Protocol: core.ProtocolTCP,
})
}
@ -240,6 +241,13 @@ func (a *ArangoDContainer) GetEnvs() ([]core.EnvVar, []core.EnvFromSource) {
Value: strconv.FormatBool(a.input.Enterprise),
})
if p := a.groupSpec.Port; p != nil {
envs.Add(true, core.EnvVar{
Name: ArangoDBServerPortEnv,
Value: fmt.Sprintf("%d", *p),
})
}
envFromSource := []core.EnvFromSource{
{
ConfigMapRef: &core.ConfigMapEnvSource{
@ -537,8 +545,7 @@ func (m *MemberArangoDPod) createMetricsExporterSidecarInternalExporter() (*core
c, err := ArangodbInternalExporterContainer(image, args,
createExporterLivenessProbe(m.spec.IsSecure() && m.spec.Metrics.IsTLS()), m.spec.Metrics.Resources,
m.groupSpec.SecurityContext.NewSecurityContext(),
m.spec)
m.spec, m.groupSpec)
if err != nil {
return nil, err
}

View file

@ -29,7 +29,6 @@ import (
"github.com/arangodb/go-driver/jwt"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
"github.com/arangodb/kube-arangodb/pkg/util"
@ -288,7 +287,7 @@ func (r *Resources) probeBuilderStartupCoreOperator(spec api.DeploymentSpec, gro
}, nil
}
func (r *Resources) probeBuilderLivenessCore(spec api.DeploymentSpec, _ api.ServerGroup, _ api.ImageInfo) (Probe, error) {
func (r *Resources) probeBuilderLivenessCore(spec api.DeploymentSpec, group api.ServerGroup, _ api.ImageInfo) (Probe, error) {
authorization := ""
if spec.IsAuthenticated() {
secretData, err := r.getJWTSecret(spec)
@ -385,7 +384,7 @@ func (r *Resources) probeBuilderReadinessCoreSelect() probeBuilder {
return r.probeBuilderReadinessCore
}
func (r *Resources) probeBuilderReadinessCoreOperator(spec api.DeploymentSpec, _ api.ServerGroup, _ api.ImageInfo) (Probe, error) {
func (r *Resources) probeBuilderReadinessCoreOperator(spec api.DeploymentSpec, group api.ServerGroup, _ api.ImageInfo) (Probe, error) {
args := r.probeCommand(spec, api.ProbeTypeReadiness)
return &probes.CMDProbeConfig{
@ -426,10 +425,7 @@ func (r *Resources) probeBuilderReadinessCore(spec api.DeploymentSpec, _ api.Ser
func (r *Resources) probeBuilderLivenessSync(spec api.DeploymentSpec, group api.ServerGroup, _ api.ImageInfo) (Probe, error) {
authorization := ""
port := shared.ArangoSyncMasterPort
if group == api.ServerGroupSyncWorkers {
port = shared.ArangoSyncWorkerPort
}
if spec.Sync.Monitoring.GetTokenSecretName() != "" {
// Use monitoring token
token, err := r.getSyncMonitoringToken(spec)
@ -455,16 +451,12 @@ func (r *Resources) probeBuilderLivenessSync(spec api.DeploymentSpec, group api.
LocalPath: "/_api/version",
Secure: spec.Sync.TLS.IsSecure(),
Authorization: authorization,
Port: port,
}, nil
}
func (r *Resources) probeBuilderStartupSync(spec api.DeploymentSpec, group api.ServerGroup, _ api.ImageInfo) (Probe, error) {
authorization := ""
port := shared.ArangoSyncMasterPort
if group == api.ServerGroupSyncWorkers {
port = shared.ArangoSyncWorkerPort
}
if spec.Sync.Monitoring.GetTokenSecretName() != "" {
// Use monitoring token
token, err := r.getSyncMonitoringToken(spec)
@ -490,7 +482,6 @@ func (r *Resources) probeBuilderStartupSync(spec api.DeploymentSpec, group api.S
LocalPath: "/_api/version",
Secure: spec.Sync.TLS.IsSecure(),
Authorization: authorization,
Port: port,
}, nil
}

View file

@ -22,6 +22,7 @@ package resources
import (
"context"
"fmt"
"math"
"net"
"net/url"
@ -180,6 +181,13 @@ func (a *ArangoSyncContainer) GetEnvs() ([]core.EnvVar, []core.EnvFromSource) {
envs.Add(true, k8sutil.GetLifecycleEnv()...)
if p := a.groupSpec.Port; p != nil {
envs.Add(true, core.EnvVar{
Name: ArangoDBServerPortEnv,
Value: fmt.Sprintf("%d", *p),
})
}
if len(a.groupSpec.Envs) > 0 {
for _, env := range a.groupSpec.Envs {
// Do not override preset envs

View file

@ -130,7 +130,7 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
// Headless service
counterMetric.Inc()
headlessPorts, headlessSelector := k8sutil.HeadlessServiceDetails(deploymentName, role)
headlessPorts, headlessSelector := k8sutil.HeadlessServiceDetails(deploymentName)
if s, exists := cachedStatus.Service().V1().GetSimple(k8sutil.CreateHeadlessServiceName(deploymentName)); !exists {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)

View file

@ -36,8 +36,8 @@ type HTTPProbeConfig struct {
Secure bool
// Value for an Authorization header (can be empty)
Authorization string
// Port to inspect (defaults to ArangoPort)
Port int
// PortName define port name used to connect to the server for probes
PortName string
// Number of seconds after the container has started before liveness probes are initiated (defaults to 30)
InitialDelaySeconds int32
// Number of seconds after which the probe times out (defaults to 2).
@ -71,17 +71,22 @@ func (config HTTPProbeConfig) Create() *core.Probe {
Value: config.Authorization,
})
}
def := func(value, defaultValue int32) int32 {
if value != 0 {
return value
def := func(values ...string) string {
for _, v := range values {
if v != "" {
return v
}
}
return defaultValue
return ""
}
return &core.Probe{
Handler: core.Handler{
HTTPGet: &core.HTTPGetAction{
Path: config.LocalPath,
Port: intstr.FromInt(int(def(int32(config.Port), shared.ArangoPort))),
Port: intstr.FromString(def(config.PortName, shared.ServerPortName)),
Scheme: scheme,
HTTPHeaders: headers,
},

View file

@ -25,6 +25,8 @@ import (
"github.com/stretchr/testify/assert"
core "k8s.io/api/core/v1"
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
)
func TestCreate(t *testing.T) {
@ -32,7 +34,7 @@ func TestCreate(t *testing.T) {
secret := "the secret"
// http
config := HTTPProbeConfig{path, false, secret, 0, 0, 0, 0, 0, 0}
config := HTTPProbeConfig{path, false, secret, "", 0, 0, 0, 0, 0}
probe := config.Create()
assert.Equal(t, probe.InitialDelaySeconds, int32(15*60))
@ -44,17 +46,17 @@ func TestCreate(t *testing.T) {
assert.Equal(t, probe.Handler.HTTPGet.Path, path)
assert.Equal(t, probe.Handler.HTTPGet.HTTPHeaders[0].Name, "Authorization")
assert.Equal(t, probe.Handler.HTTPGet.HTTPHeaders[0].Value, secret)
assert.Equal(t, probe.Handler.HTTPGet.Port.IntValue(), 8529)
assert.Equal(t, probe.Handler.HTTPGet.Port.String(), shared.ServerPortName)
assert.Equal(t, probe.Handler.HTTPGet.Scheme, core.URISchemeHTTP)
// https
config = HTTPProbeConfig{path, true, secret, 0, 0, 0, 0, 0, 0}
config = HTTPProbeConfig{path, true, secret, "", 0, 0, 0, 0, 0}
probe = config.Create()
assert.Equal(t, probe.Handler.HTTPGet.Scheme, core.URISchemeHTTPS)
// http, custom timing
config = HTTPProbeConfig{path, false, secret, 0, 1, 2, 3, 4, 5}
config = HTTPProbeConfig{path, false, secret, "", 1, 2, 3, 4, 5}
probe = config.Create()
assert.Equal(t, probe.InitialDelaySeconds, int32(1))

View file

@ -139,7 +139,7 @@ func CreateHeadlessService(ctx context.Context, svcs servicev1.ModInterface, dep
return svcName, newlyCreated, nil
}
func HeadlessServiceDetails(deploymentName string, role string) ([]core.ServicePort, map[string]string) {
func HeadlessServiceDetails(deploymentName string) ([]core.ServicePort, map[string]string) {
ports := []core.ServicePort{
{
Name: shared.ServerPortName,
@ -148,7 +148,7 @@ func HeadlessServiceDetails(deploymentName string, role string) ([]core.ServiceP
TargetPort: intstr.FromString(shared.ServerPortName),
},
}
labels := LabelsForDeployment(deploymentName, role)
labels := LabelsForDeployment(deploymentName, "")
return ports, labels
}