Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 62 additions & 62 deletions dashboard/assets.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/Manual/Deployment/Kubernetes/DeploymentResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ This setting is used when `spec.externalAccess.type` is set to `NodePort` or `Au

If you do not specify this setting, a random port will be chosen automatically.

### `spec.externalAccess.advertisedEndpoint: string`

This setting specifies the advertised endpoint for all coordinators.

### `spec.auth.jwtSecretName: string`

This setting specifies the name of a kubernetes `Secret` that contains
Expand Down
24 changes: 24 additions & 0 deletions pkg/apis/deployment/v1alpha/external_access_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
package v1alpha

import (
"fmt"
"net/url"

"github.com/arangodb/kube-arangodb/pkg/util"
)

Expand All @@ -34,6 +37,8 @@ type ExternalAccessSpec struct {
NodePort *int `json:"nodePort,omitempty"`
// Optional IP used to configure a load-balancer on, in case of Auto or LoadBalancer type.
LoadBalancerIP *string `json:"loadBalancerIP,omitempty"`
// Advertised Endpoint is passed to the coordinators/single servers for advertising a specific endpoint
AdvertisedEndpoint *string `json:"advertisedEndpoint,omitempty"`
}

// GetType returns the value of type.
Expand All @@ -51,11 +56,27 @@ func (s ExternalAccessSpec) GetLoadBalancerIP() string {
return util.StringOrDefault(s.LoadBalancerIP)
}

// GetAdvertisedEndpoint returns the advertised endpoint or empty string if none was specified
func (s ExternalAccessSpec) GetAdvertisedEndpoint() string {
return util.StringOrDefault(s.AdvertisedEndpoint)
}

// HasAdvertisedEndpoint return whether an advertised endpoint was specified or not
func (s ExternalAccessSpec) HasAdvertisedEndpoint() bool {
return s.AdvertisedEndpoint != nil
}

// Validate the given spec
func (s ExternalAccessSpec) Validate() error {
if err := s.GetType().Validate(); err != nil {
return maskAny(err)
}
if s.AdvertisedEndpoint != nil {
ep := s.GetAdvertisedEndpoint()
if _, err := url.Parse(ep); err != nil {
return maskAny(fmt.Errorf("Failed to parse advertised endpoint '%s': %s", ep, err))
}
}
return nil
}

Expand All @@ -74,6 +95,9 @@ func (s *ExternalAccessSpec) SetDefaultsFrom(source ExternalAccessSpec) {
if s.LoadBalancerIP == nil {
s.LoadBalancerIP = util.NewStringOrNil(source.LoadBalancerIP)
}
if s.AdvertisedEndpoint == nil {
s.AdvertisedEndpoint = source.AdvertisedEndpoint
}
}

// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec.
Expand Down
6 changes: 1 addition & 5 deletions pkg/apis/deployment/v1alpha/license_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ func (s LicenseSpec) HasSecretName() bool {

// GetSecretName returns the license key if set. Empty string otherwise.
func (s LicenseSpec) GetSecretName() string {
if s.HasSecretName() {
return *s.SecretName
}

return ""
return util.StringOrDefault(s.SecretName)
}

// Validate validates the LicenseSpec
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pkg/deployment/resources/pod_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func (o optionPair) CompareTo(other optionPair) int {
return strings.Compare(o.Value, other.Value)
}

func versionHasAdvertisedEndpoint(v driver.Version) bool {
return v.CompareTo("3.4.0") >= 0
}

// createArangodArgs creates command line arguments for an arangod server in the given group.
func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup,
agents api.MemberStatusList, id string, version driver.Version, autoUpgrade bool) []string {
Expand Down Expand Up @@ -135,6 +139,8 @@ func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, gro
)
}

versionHasAdvertisedEndpoint := versionHasAdvertisedEndpoint(version)

/* if config.ServerThreads != 0 {
options = append(options,
optionPair{"--server.threads", strconv.Itoa(config.ServerThreads)})
Expand Down Expand Up @@ -180,6 +186,11 @@ func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, gro
optionPair{"--foxx.queues", "true"},
optionPair{"--server.statistics", "true"},
)
if deplSpec.ExternalAccess.HasAdvertisedEndpoint() && versionHasAdvertisedEndpoint {
options = append(options,
optionPair{"--cluster.my-advertised-endpoint", deplSpec.ExternalAccess.GetAdvertisedEndpoint()},
)
}
case api.ServerGroupSingle:
options = append(options,
optionPair{"--foxx.queues", "true"},
Expand All @@ -192,6 +203,11 @@ func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, gro
optionPair{"--cluster.my-address", myTCPURL},
optionPair{"--cluster.my-role", "SINGLE"},
)
if deplSpec.ExternalAccess.HasAdvertisedEndpoint() && versionHasAdvertisedEndpoint {
options = append(options,
optionPair{"--cluster.my-advertised-endpoint", deplSpec.ExternalAccess.GetAdvertisedEndpoint()},
)
}
}
}
if addAgentEndpoints {
Expand Down