mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Merge pull request #299 from arangodb/feature/advertised-endpoints
Advertised Endpoints
This commit is contained in:
commit
eb674903cd
6 changed files with 113 additions and 68 deletions
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
package v1alpha
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
)
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -397,6 +397,11 @@ func (in *ExternalAccessSpec) DeepCopyInto(out *ExternalAccessSpec) {
|
|||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.AdvertisedEndpoint != nil {
|
||||
in, out := &in.AdvertisedEndpoint, &out.AdvertisedEndpoint
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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)})
|
||||
|
@ -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"},
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue