1
0
Fork 0
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:
Lars Maier 2018-12-05 17:09:15 +01:00 committed by GitHub
commit eb674903cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 113 additions and 68 deletions

File diff suppressed because one or more lines are too long

View file

@ -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. 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` ### `spec.auth.jwtSecretName: string`
This setting specifies the name of a kubernetes `Secret` that contains This setting specifies the name of a kubernetes `Secret` that contains

View file

@ -23,6 +23,9 @@
package v1alpha package v1alpha
import ( import (
"fmt"
"net/url"
"github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util"
) )
@ -34,6 +37,8 @@ type ExternalAccessSpec struct {
NodePort *int `json:"nodePort,omitempty"` NodePort *int `json:"nodePort,omitempty"`
// Optional IP used to configure a load-balancer on, in case of Auto or LoadBalancer type. // Optional IP used to configure a load-balancer on, in case of Auto or LoadBalancer type.
LoadBalancerIP *string `json:"loadBalancerIP,omitempty"` 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. // GetType returns the value of type.
@ -51,11 +56,27 @@ func (s ExternalAccessSpec) GetLoadBalancerIP() string {
return util.StringOrDefault(s.LoadBalancerIP) 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 // Validate the given spec
func (s ExternalAccessSpec) Validate() error { func (s ExternalAccessSpec) Validate() error {
if err := s.GetType().Validate(); err != nil { if err := s.GetType().Validate(); err != nil {
return maskAny(err) 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 return nil
} }
@ -74,6 +95,9 @@ func (s *ExternalAccessSpec) SetDefaultsFrom(source ExternalAccessSpec) {
if s.LoadBalancerIP == nil { if s.LoadBalancerIP == nil {
s.LoadBalancerIP = util.NewStringOrNil(source.LoadBalancerIP) 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. // ResetImmutableFields replaces all immutable fields in the given target with values from the source spec.

View file

@ -37,11 +37,7 @@ func (s LicenseSpec) HasSecretName() bool {
// GetSecretName returns the license key if set. Empty string otherwise. // GetSecretName returns the license key if set. Empty string otherwise.
func (s LicenseSpec) GetSecretName() string { func (s LicenseSpec) GetSecretName() string {
if s.HasSecretName() { return util.StringOrDefault(s.SecretName)
return *s.SecretName
}
return ""
} }
// Validate validates the LicenseSpec // Validate validates the LicenseSpec

View file

@ -397,6 +397,11 @@ func (in *ExternalAccessSpec) DeepCopyInto(out *ExternalAccessSpec) {
*out = new(string) *out = new(string)
**out = **in **out = **in
} }
if in.AdvertisedEndpoint != nil {
in, out := &in.AdvertisedEndpoint, &out.AdvertisedEndpoint
*out = new(string)
**out = **in
}
return return
} }

View file

@ -61,6 +61,10 @@ func (o optionPair) CompareTo(other optionPair) int {
return strings.Compare(o.Value, other.Value) 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. // createArangodArgs creates command line arguments for an arangod server in the given group.
func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup, func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup,
agents api.MemberStatusList, id string, version driver.Version, autoUpgrade bool) []string { 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 { /* if config.ServerThreads != 0 {
options = append(options, options = append(options,
optionPair{"--server.threads", strconv.Itoa(config.ServerThreads)}) 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{"--foxx.queues", "true"},
optionPair{"--server.statistics", "true"}, optionPair{"--server.statistics", "true"},
) )
if deplSpec.ExternalAccess.HasAdvertisedEndpoint() && versionHasAdvertisedEndpoint {
options = append(options,
optionPair{"--cluster.my-advertised-endpoint", deplSpec.ExternalAccess.GetAdvertisedEndpoint()},
)
}
case api.ServerGroupSingle: case api.ServerGroupSingle:
options = append(options, options = append(options,
optionPair{"--foxx.queues", "true"}, 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-address", myTCPURL},
optionPair{"--cluster.my-role", "SINGLE"}, optionPair{"--cluster.my-role", "SINGLE"},
) )
if deplSpec.ExternalAccess.HasAdvertisedEndpoint() && versionHasAdvertisedEndpoint {
options = append(options,
optionPair{"--cluster.my-advertised-endpoint", deplSpec.ExternalAccess.GetAdvertisedEndpoint()},
)
}
} }
} }
if addAgentEndpoints { if addAgentEndpoints {