Skip to content

Commit eb67490

Browse files
author
Lars Maier
authored
Merge pull request #299 from arangodb/feature/advertised-endpoints
Advertised Endpoints
2 parents e4ab08b + 21ffa3c commit eb67490

File tree

6 files changed

+112
-67
lines changed

6 files changed

+112
-67
lines changed

dashboard/assets.go

Lines changed: 62 additions & 62 deletions
Large diffs are not rendered by default.

docs/Manual/Deployment/Kubernetes/DeploymentResource.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ This setting is used when `spec.externalAccess.type` is set to `NodePort` or `Au
165165

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

168+
### `spec.externalAccess.advertisedEndpoint: string`
169+
170+
This setting specifies the advertised endpoint for all coordinators.
171+
168172
### `spec.auth.jwtSecretName: string`
169173

170174
This setting specifies the name of a kubernetes `Secret` that contains

pkg/apis/deployment/v1alpha/external_access_spec.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
package v1alpha
2424

2525
import (
26+
"fmt"
27+
"net/url"
28+
2629
"github.com/arangodb/kube-arangodb/pkg/util"
2730
)
2831

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

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

59+
// GetAdvertisedEndpoint returns the advertised endpoint or empty string if none was specified
60+
func (s ExternalAccessSpec) GetAdvertisedEndpoint() string {
61+
return util.StringOrDefault(s.AdvertisedEndpoint)
62+
}
63+
64+
// HasAdvertisedEndpoint return whether an advertised endpoint was specified or not
65+
func (s ExternalAccessSpec) HasAdvertisedEndpoint() bool {
66+
return s.AdvertisedEndpoint != nil
67+
}
68+
5469
// Validate the given spec
5570
func (s ExternalAccessSpec) Validate() error {
5671
if err := s.GetType().Validate(); err != nil {
5772
return maskAny(err)
5873
}
74+
if s.AdvertisedEndpoint != nil {
75+
ep := s.GetAdvertisedEndpoint()
76+
if _, err := url.Parse(ep); err != nil {
77+
return maskAny(fmt.Errorf("Failed to parse advertised endpoint '%s': %s", ep, err))
78+
}
79+
}
5980
return nil
6081
}
6182

@@ -74,6 +95,9 @@ func (s *ExternalAccessSpec) SetDefaultsFrom(source ExternalAccessSpec) {
7495
if s.LoadBalancerIP == nil {
7596
s.LoadBalancerIP = util.NewStringOrNil(source.LoadBalancerIP)
7697
}
98+
if s.AdvertisedEndpoint == nil {
99+
s.AdvertisedEndpoint = source.AdvertisedEndpoint
100+
}
77101
}
78102

79103
// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec.

pkg/apis/deployment/v1alpha/license_spec.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ func (s LicenseSpec) HasSecretName() bool {
3737

3838
// GetSecretName returns the license key if set. Empty string otherwise.
3939
func (s LicenseSpec) GetSecretName() string {
40-
if s.HasSecretName() {
41-
return *s.SecretName
42-
}
43-
44-
return ""
40+
return util.StringOrDefault(s.SecretName)
4541
}
4642

4743
// Validate validates the LicenseSpec

pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/resources/pod_creator.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ func (o optionPair) CompareTo(other optionPair) int {
6161
return strings.Compare(o.Value, other.Value)
6262
}
6363

64+
func versionHasAdvertisedEndpoint(v driver.Version) bool {
65+
return v.CompareTo("3.4.0") >= 0
66+
}
67+
6468
// createArangodArgs creates command line arguments for an arangod server in the given group.
6569
func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup,
6670
agents api.MemberStatusList, id string, version driver.Version, autoUpgrade bool) []string {
@@ -135,6 +139,8 @@ func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, gro
135139
)
136140
}
137141

142+
versionHasAdvertisedEndpoint := versionHasAdvertisedEndpoint(version)
143+
138144
/* if config.ServerThreads != 0 {
139145
options = append(options,
140146
optionPair{"--server.threads", strconv.Itoa(config.ServerThreads)})
@@ -180,6 +186,11 @@ func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, gro
180186
optionPair{"--foxx.queues", "true"},
181187
optionPair{"--server.statistics", "true"},
182188
)
189+
if deplSpec.ExternalAccess.HasAdvertisedEndpoint() && versionHasAdvertisedEndpoint {
190+
options = append(options,
191+
optionPair{"--cluster.my-advertised-endpoint", deplSpec.ExternalAccess.GetAdvertisedEndpoint()},
192+
)
193+
}
183194
case api.ServerGroupSingle:
184195
options = append(options,
185196
optionPair{"--foxx.queues", "true"},
@@ -192,6 +203,11 @@ func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, gro
192203
optionPair{"--cluster.my-address", myTCPURL},
193204
optionPair{"--cluster.my-role", "SINGLE"},
194205
)
206+
if deplSpec.ExternalAccess.HasAdvertisedEndpoint() && versionHasAdvertisedEndpoint {
207+
options = append(options,
208+
optionPair{"--cluster.my-advertised-endpoint", deplSpec.ExternalAccess.GetAdvertisedEndpoint()},
209+
)
210+
}
195211
}
196212
}
197213
if addAgentEndpoints {

0 commit comments

Comments
 (0)