1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-15 17:51:03 +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 - (Feature) Pre OOM Abort function
- (Bugfix) Fix ErrorArray String function - (Bugfix) Fix ErrorArray String function
- (Feature) Switch services to Port names - (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) ## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
- (Feature) Add action progress - (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/features"
"github.com/arangodb/kube-arangodb/pkg/deployment/pod" "github.com/arangodb/kube-arangodb/pkg/deployment/pod"
"github.com/arangodb/kube-arangodb/pkg/deployment/resources" "github.com/arangodb/kube-arangodb/pkg/deployment/resources"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/constants"
) )
const (
ProbePort util.EnvironmentVariable = "ARANGODB_SERVER_PORT"
)
var ( var (
cmdLifecycleProbe = &cobra.Command{ cmdLifecycleProbe = &cobra.Command{
Use: "probe", Use: "probe",
@ -118,7 +123,9 @@ func probeEndpoint(endpoint string) string {
proto = "https" 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) { func readJWTFile(file string) ([]byte, error) {

View file

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

View file

@ -560,3 +560,8 @@ func (s DeploymentSpec) GetCoreContainers(group ServerGroup) utils.StringList {
return result 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 define additional modes enabled on the Pod level
PodModes *ServerGroupSpecPodMode `json:"podModes,omitempty"` 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 // ServerGroupProbesSpec contains specification for probes for pods of the server group
@ -672,3 +676,30 @@ func (s *ServerGroupSpec) Group() ServerGroup {
return s.group 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) *out = new(ServerGroupSpecPodMode)
(*in).DeepCopyInto(*out) (*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 return
} }

View file

@ -560,3 +560,8 @@ func (s DeploymentSpec) GetCoreContainers(group ServerGroup) utils.StringList {
return result 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 define additional modes enabled on the Pod level
PodModes *ServerGroupSpecPodMode `json:"podModes,omitempty"` 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 // ServerGroupProbesSpec contains specification for probes for pods of the server group
@ -672,3 +676,30 @@ func (s *ServerGroupSpec) Group() ServerGroup {
return s.group 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) *out = new(ServerGroupSpecPodMode)
(*in).DeepCopyInto(*out) (*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 return
} }

View file

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

View file

@ -74,7 +74,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullAlways, ImagePullPolicy: core.PullAlways,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -125,7 +125,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullAlways, ImagePullPolicy: core.PullAlways,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -185,7 +185,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -242,7 +242,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -307,7 +307,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -362,7 +362,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
VolumeMounts: []core.VolumeMount{ VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered), Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -419,7 +419,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
VolumeMounts: []core.VolumeMount{ VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered), Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -479,7 +479,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
VolumeMounts: []core.VolumeMount{ VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered), Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -539,7 +539,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -591,7 +591,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -648,7 +648,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -701,7 +701,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.TlsKeyfileVolumeMount(), k8sutil.TlsKeyfileVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, true, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, true, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -740,8 +740,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"}) authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
authorization, shared.ArangoPort)
}, },
ExpectedEvent: "member agent is created", ExpectedEvent: "member agent is created",
ExpectedPod: core.Pod{ ExpectedPod: core.Pod{
@ -800,8 +799,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"}) authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, authorization, shared.ServerPortName)
authorization, shared.ArangoPort)
}, },
ExpectedEvent: "member agent is created", ExpectedEvent: "member agent is created",
ExpectedPod: core.Pod{ ExpectedPod: core.Pod{
@ -879,7 +877,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
k8sutil.RocksdbEncryptionVolumeMount(), k8sutil.RocksdbEncryptionVolumeMount(),
}, },
Resources: emptyResources, Resources: emptyResources,
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -919,8 +917,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"}) authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
authorization, shared.ArangoPort)
}, },
ExpectedEvent: "member dbserver is created", ExpectedEvent: "member dbserver is created",
ExpectedPod: core.Pod{ ExpectedPod: core.Pod{
@ -988,8 +985,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"}) authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
authorization, shared.ArangoPort)
}, },
ExpectedEvent: "member dbserver is created", ExpectedEvent: "member dbserver is created",
ExpectedPod: core.Pod{ ExpectedPod: core.Pod{
@ -1053,8 +1049,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"}) authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
authorization, shared.ArangoPort)
}, },
config: Config{ config: Config{
OperatorImage: testImageOperator, OperatorImage: testImageOperator,
@ -1124,8 +1119,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"}) authorization, err := createTestToken(deployment, testCase, []string{"/_api/version"})
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
authorization, shared.ArangoPort)
}, },
config: Config{ config: Config{
OperatorImage: testImageOperator, OperatorImage: testImageOperator,
@ -1260,8 +1254,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
authReadiness, err := createTestToken(deployment, testCase, []string{"/_admin/server/availability"}) authReadiness, err := createTestToken(deployment, testCase, []string{"/_admin/server/availability"})
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, authLiveness, shared.ServerPortName)
authLiveness, 0)
testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(httpProbe, true, authReadiness) testCase.ExpectedPod.Spec.Containers[0].ReadinessProbe = createTestReadinessProbe(httpProbe, true, authReadiness)
}, },
ExpectedEvent: "member single is created", 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...) runTestCases(t, testCases...)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -135,7 +135,7 @@ func TestEnsurePod_ArangoDB_Resources(t *testing.T) {
VolumeMounts: []core.VolumeMount{ VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
Env: withDefaultEnvs(t, resourcesUnfiltered), Env: withDefaultEnvs(t, resourcesUnfiltered),
@ -194,7 +194,7 @@ func TestEnsurePod_ArangoDB_Resources(t *testing.T) {
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
Env: withEnvs(resourceCPULimitAsEnv(t, resourcesUnfiltered)), Env: withEnvs(resourceCPULimitAsEnv(t, resourcesUnfiltered)),
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), SecurityContext: securityContext.NewSecurityContext(),
}, },
@ -250,7 +250,7 @@ func TestEnsurePod_ArangoDB_Resources(t *testing.T) {
VolumeMounts: []core.VolumeMount{ VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(), k8sutil.ArangodVolumeMount(),
}, },
LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ArangoPort), LivenessProbe: createTestLivenessProbe(httpProbe, false, "", shared.ServerPortName),
ImagePullPolicy: core.PullIfNotPresent, ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(), 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncMasterPort)
}, },
ExpectedEvent: "member syncmaster is created", ExpectedEvent: "member syncmaster is created",
ExpectedPod: core.Pod{ 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) auth, err := k8sutil.GetTokenSecret(context.Background(), deployment.GetCachedStatus().Secret().V1().Read(), name)
require.NoError(t, err) require.NoError(t, err)
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe( testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe("", true, "bearer "+auth, shared.ServerPortName)
"", true, "bearer "+auth, shared.ArangoSyncWorkerPort)
}, },
ExpectedEvent: "member syncworker is created", ExpectedEvent: "member syncworker is created",
ExpectedPod: core.Pod{ ExpectedPod: core.Pod{

View file

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

View file

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

View file

@ -22,6 +22,7 @@ package deployment
import ( import (
"context" "context"
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
@ -124,7 +125,7 @@ func createTestToken(deployment *Deployment, testCase *testCaseStruct, paths []s
return jwt.CreateArangodJwtAuthorizationHeaderAllowedPaths(s, "kube-arangodb", paths) 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) probe := createTestLivenessProbe(mode, secure, authorization, port)
mod(probe) mod(probe)
@ -141,12 +142,12 @@ func createTestReadinessSimpleProbe(mode string, secure bool, authorization stri
return probe 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() return getProbeCreator(mode)(secure, authorization, "/_api/version", port, api.ProbeTypeLiveness).Create()
} }
func createTestReadinessProbe(mode string, secure bool, authorization string) *core.Probe { 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() api.ProbeTypeReadiness).Create()
p.InitialDelaySeconds = 2 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 { 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.InitialDelaySeconds = 1
p.PeriodSeconds = 5 p.PeriodSeconds = 5
@ -165,7 +166,7 @@ func createTestStartupProbe(mode string, secure bool, authorization string, fail
return p 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 ( const (
cmdProbe = "cmdProbe" cmdProbe = "cmdProbe"
@ -182,13 +183,13 @@ func getProbeCreator(t string) probeCreator {
} }
func getHTTPProbeCreator() 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) return createHTTPTestProbe(secure, authorization, endpoint, port)
} }
} }
func getCMDProbeCreator() probeCreator { 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) 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{ return &probes.HTTPProbeConfig{
LocalPath: endpoint, LocalPath: endpoint,
Secure: secure, Secure: secure,
Authorization: authorization, Authorization: authorization,
Port: port, PortName: port,
} }
} }
@ -279,6 +280,55 @@ func createTestCommandForDBServer(name string, tls, auth, encryptionRocksDB bool
return append(command, sorted...) 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 { func createTestCommandForCoordinator(name string, tls, auth bool, mods ...func() k8sutil.OptionPairs) []string {
command := []string{resources.ArangoDExecutor} command := []string{resources.ArangoDExecutor}
@ -328,6 +378,42 @@ func createTestCommandForCoordinator(name string, tls, auth bool, mods ...func()
return append(command, args.Unique().AsArgs()...) 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 { func createTestCommandForSingleMode(tls, auth bool, mods ...func() k8sutil.OptionPairs) []string {
command := []string{resources.ArangoDExecutor} command := []string{resources.ArangoDExecutor}
@ -530,7 +616,7 @@ func createTestDeployment(t *testing.T, config Config, arangoDeployment *api.Ara
return d, eventRecorder return d, eventRecorder
} }
func createTestPorts(group api.ServerGroup) []core.ContainerPort { func createTestPorts(group api.ServerGroup, ports ...int) []core.ContainerPort {
port := shared.ArangoPort port := shared.ArangoPort
switch group { switch group {
@ -540,6 +626,10 @@ func createTestPorts(group api.ServerGroup) []core.ContainerPort {
port = shared.ArangoSyncWorkerPort port = shared.ArangoSyncWorkerPort
} }
if len(ports) > 0 {
port = ports[0]
}
return []core.ContainerPort{ return []core.ContainerPort{
{ {
Name: "server", Name: "server",
@ -568,7 +658,7 @@ func createTestImages(enterprise bool) api.ImageInfoList {
func createTestExporterLivenessProbe(secure bool) *core.Probe { func createTestExporterLivenessProbe(secure bool) *core.Probe {
return probes.HTTPProbeConfig{ return probes.HTTPProbeConfig{
LocalPath: "/", LocalPath: "/",
Port: shared.ArangoExporterPort, PortName: shared.ExporterPortName,
Secure: secure, Secure: secure,
}.Create() }.Create()
} }
@ -819,9 +909,8 @@ func addLifecycle(name string, uuidRequired bool, license string, group api.Serv
func (testCase *testCaseStruct) createTestEnvVariables(deployment *Deployment, group api.ServerGroup) { func (testCase *testCaseStruct) createTestEnvVariables(deployment *Deployment, group api.ServerGroup) {
if group == api.ServerGroupSyncMasters || group == api.ServerGroupSyncWorkers { if group == api.ServerGroupSyncMasters || group == api.ServerGroupSyncWorkers {
return
}
} else {
// Set up environment variables. // Set up environment variables.
for i, container := range testCase.ExpectedPod.Spec.Containers { for i, container := range testCase.ExpectedPod.Spec.Containers {
if container.Name != api.ServerGroupReservedContainerNameServer { if container.Name != api.ServerGroupReservedContainerNameServer {
@ -883,6 +972,23 @@ func (testCase *testCaseStruct) createTestEnvVariables(deployment *Deployment, g
}) })
} }
} }
}
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)
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),
})
}
}
}
} }
func isEnvExist(envs []core.EnvVar, name string) bool { func isEnvExist(envs []core.EnvVar, name string) bool {

View file

@ -45,7 +45,7 @@ func createInternalExporterArgs(spec api.DeploymentSpec, groupSpec api.ServerGro
if spec.IsSecure() { if spec.IsSecure() {
scheme = "https" 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 { } else {
options.Addf("--arangodb.endpoint", "http://localhost:%d%s", *port, path) 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) 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) options.Addf("--server.address", ":%d", port)
} }
@ -73,7 +83,7 @@ func getArangoExporterInternalEndpoint(version driver.Version) string {
func createExporterLivenessProbe(isSecure bool) *probes.HTTPProbeConfig { func createExporterLivenessProbe(isSecure bool) *probes.HTTPProbeConfig {
probeCfg := &probes.HTTPProbeConfig{ probeCfg := &probes.HTTPProbeConfig{
LocalPath: "/", LocalPath: "/",
Port: shared.ArangoExporterPort, PortName: shared.ExporterPortName,
Secure: isSecure, Secure: isSecure,
} }

View file

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

View file

@ -68,7 +68,7 @@ func createArangodArgs(cachedStatus interfaces.Inspector, input pod.Input, addit
} }
if input.GroupSpec.GetExternalPortEnabled() { 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 { 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 { groupSpec api.ServerGroupSpec, member api.MemberStatus) []string {
options := k8sutil.CreateOptionPairs(64) options := k8sutil.CreateOptionPairs(64)
var runCmd string 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() != "" { if spec.Sync.Monitoring.GetTokenSecretName() != "" {
options.Addf("--monitoring.token", "$(%s)", constants.EnvArangoSyncMonitoringToken) options.Addf("--monitoring.token", "$(%s)", constants.EnvArangoSyncMonitoringToken)
} }
@ -208,8 +204,7 @@ func createArangoSyncArgs(apiObject meta.Object, spec api.DeploymentSpec, group
switch group { switch group {
case api.ServerGroupSyncMasters: case api.ServerGroupSyncMasters:
runCmd = "master" runCmd = "master"
port = shared.ArangoSyncMasterPort masterEndpoint = spec.Sync.ExternalAccess.ResolveMasterEndpoint(k8sutil.CreateSyncMasterClientServiceDNSNameWithDomain(apiObject, spec.ClusterDomain), int(port))
masterEndpoint = spec.Sync.ExternalAccess.ResolveMasterEndpoint(k8sutil.CreateSyncMasterClientServiceDNSNameWithDomain(apiObject, spec.ClusterDomain), port)
keyPath := filepath.Join(shared.TLSKeyfileVolumeMountDir, constants.SecretTLSKeyfile) keyPath := filepath.Join(shared.TLSKeyfileVolumeMountDir, constants.SecretTLSKeyfile)
clientCAPath := filepath.Join(shared.ClientAuthCAVolumeMountDir, constants.SecretCACertificate) clientCAPath := filepath.Join(shared.ClientAuthCAVolumeMountDir, constants.SecretCACertificate)
options.Add("--server.keyfile", keyPath) 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) options.Addf("--cluster.endpoint", "%s://%s:%d", scheme, dbServiceName, shared.ArangoPort)
case api.ServerGroupSyncWorkers: case api.ServerGroupSyncWorkers:
runCmd = "worker" runCmd = "worker"
port = shared.ArangoSyncWorkerPort
masterEndpointHost := k8sutil.CreateSyncMasterClientServiceName(apiObject.GetName()) masterEndpointHost := k8sutil.CreateSyncMasterClientServiceName(apiObject.GetName())
masterEndpoint = []string{"https://" + net.JoinHostPort(masterEndpointHost, strconv.Itoa(shared.ArangoSyncMasterPort))} masterEndpoint = []string{"https://" + net.JoinHostPort(masterEndpointHost, strconv.Itoa(shared.ArangoSyncMasterPort))}
} }
for _, ep := range masterEndpoint { for _, ep := range masterEndpoint {
options.Add("--master.endpoint", ep) 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.endpoint", serverEndpoint)
options.Add("--server.port", strconv.Itoa(port)) options.Add("--server.port", strconv.Itoa(int(port)))
args := []string{ args := []string{
"run", "run",

View file

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

View file

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

View file

@ -22,6 +22,7 @@ package resources
import ( import (
"context" "context"
"fmt"
"math" "math"
"net" "net"
"net/url" "net/url"
@ -180,6 +181,13 @@ func (a *ArangoSyncContainer) GetEnvs() ([]core.EnvVar, []core.EnvFromSource) {
envs.Add(true, k8sutil.GetLifecycleEnv()...) 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 { if len(a.groupSpec.Envs) > 0 {
for _, env := range a.groupSpec.Envs { for _, env := range a.groupSpec.Envs {
// Do not override preset envs // Do not override preset envs

View file

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

View file

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

View file

@ -25,6 +25,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
core "k8s.io/api/core/v1" core "k8s.io/api/core/v1"
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
) )
func TestCreate(t *testing.T) { func TestCreate(t *testing.T) {
@ -32,7 +34,7 @@ func TestCreate(t *testing.T) {
secret := "the secret" secret := "the secret"
// http // 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() probe := config.Create()
assert.Equal(t, probe.InitialDelaySeconds, int32(15*60)) 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.Path, path)
assert.Equal(t, probe.Handler.HTTPGet.HTTPHeaders[0].Name, "Authorization") 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.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) assert.Equal(t, probe.Handler.HTTPGet.Scheme, core.URISchemeHTTP)
// https // 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() probe = config.Create()
assert.Equal(t, probe.Handler.HTTPGet.Scheme, core.URISchemeHTTPS) assert.Equal(t, probe.Handler.HTTPGet.Scheme, core.URISchemeHTTPS)
// http, custom timing // 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() probe = config.Create()
assert.Equal(t, probe.InitialDelaySeconds, int32(1)) 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 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{ ports := []core.ServicePort{
{ {
Name: shared.ServerPortName, Name: shared.ServerPortName,
@ -148,7 +148,7 @@ func HeadlessServiceDetails(deploymentName string, role string) ([]core.ServiceP
TargetPort: intstr.FromString(shared.ServerPortName), TargetPort: intstr.FromString(shared.ServerPortName),
}, },
} }
labels := LabelsForDeployment(deploymentName, role) labels := LabelsForDeployment(deploymentName, "")
return ports, labels return ports, labels
} }