Skip to content

Commit 706f957

Browse files
authored
[Feature] [Networking] Endpoints Destination (#1726)
1 parent 9255fde commit 706f957

33 files changed

+1820
-785
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- (Feature) (Scheduler) Add Status Conditions
3232
- (Bugfix) Versioning Alignment
3333
- (Feature) (Scheduler) Merge Strategy
34+
- (Feature) (Networking) Endpoints Destination
3435

3536
## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
3637
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries

docs/api/ArangoRoute.V1Alpha1.md

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,80 @@ Deployment specifies the ArangoDeployment object name
1818

1919
### .spec.destination.authentication.passMode
2020

21-
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination_authentication.go#L28)</sup>
21+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination_authentication.go#L32)</sup>
22+
23+
PassMode define authorization details pass mode when authorization was successful
24+
25+
Possible Values:
26+
* `"override"` (default) - Generates new token for the user
27+
* `"pass"` - Pass token provided by the user
28+
* `"remove"` - Removes authorization details from the request
2229

2330
***
2431

2532
### .spec.destination.authentication.type
2633

27-
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination_authentication.go#L29)</sup>
34+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination_authentication.go#L37)</sup>
35+
36+
Type of the authentication
37+
38+
Possible Values:
39+
* `"optional"` (default) - Authentication is header is validated and passed to the service. In case if is unauthorized, requests is still passed
40+
* `"required"` - Authentication is header is validated and passed to the service. In case if is unauthorized, returns 403
41+
42+
***
43+
44+
### .spec.destination.endpoints.checksum
45+
46+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/shared/v1/object.go#L61)</sup>
47+
48+
UID keeps the information about object Checksum
49+
50+
***
51+
52+
### .spec.destination.endpoints.name
53+
54+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/shared/v1/object.go#L52)</sup>
55+
56+
Name of the object
57+
58+
***
59+
60+
### .spec.destination.endpoints.namespace
61+
62+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/shared/v1/object.go#L55)</sup>
63+
64+
Namespace of the object. Should default to the namespace of the parent object
65+
66+
***
67+
68+
### .spec.destination.endpoints.port
69+
70+
Type: `intstr.IntOrString` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination_endpoint.go#L36)</sup>
71+
72+
Port defines Port or Port Name used as destination
73+
74+
***
75+
76+
### .spec.destination.endpoints.uid
77+
78+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/shared/v1/object.go#L58)</sup>
79+
80+
UID keeps the information about object UID
2881

2982
***
3083

3184
### .spec.destination.path
3285

33-
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination.go#L36)</sup>
86+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination.go#L39)</sup>
3487

3588
Path defines service path used for overrides
3689

3790
***
3891

3992
### .spec.destination.schema
4093

41-
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination.go#L30)</sup>
94+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination.go#L33)</sup>
4295

4396
Schema defines HTTP/S schema used for connection
4497

@@ -70,13 +123,10 @@ Namespace of the object. Should default to the namespace of the parent object
70123

71124
### .spec.destination.service.port
72125

73-
Type: `intstr.IntOrString` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination_service.go#L36)</sup>
126+
Type: `intstr.IntOrString` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_spec_destination_service.go#L35)</sup>
74127

75128
Port defines Port or Port Name used as destination
76129

77-
Links:
78-
* [Documentation](https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/)
79-
80130
***
81131

82132
### .spec.destination.service.uid
@@ -169,7 +219,7 @@ Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.
169219

170220
### .status.target.path
171221

172-
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_status_target.go#L40)</sup>
222+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_status_target.go#L43)</sup>
173223

174224
Path specifies request path override
175225

@@ -181,3 +231,11 @@ Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.
181231

182232
Insecure allows Insecure traffic
183233

234+
***
235+
236+
### .status.target.type
237+
238+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.42/pkg/apis/networking/v1alpha1/route_status_target.go#L34)</sup>
239+
240+
Type define destination type
241+

pkg/apis/networking/v1alpha1/route_spec_destination.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ type ArangoRouteSpecDestination struct {
2626
// Service defines service upstream reference
2727
Service *ArangoRouteSpecDestinationService `json:"service,omitempty"`
2828

29+
// Endpoints defines service upstream reference - which is used to find endpoints
30+
Endpoints *ArangoRouteSpecDestinationEndpoints `json:"endpoints,omitempty"`
31+
2932
// Schema defines HTTP/S schema used for connection
3033
Schema *ArangoRouteSpecDestinationSchema `json:"schema,omitempty"`
3134

@@ -47,6 +50,14 @@ func (a *ArangoRouteSpecDestination) GetService() *ArangoRouteSpecDestinationSer
4750
return a.Service
4851
}
4952

53+
func (a *ArangoRouteSpecDestination) GetEndpoints() *ArangoRouteSpecDestinationEndpoints {
54+
if a == nil || a.Endpoints == nil {
55+
return nil
56+
}
57+
58+
return a.Endpoints
59+
}
60+
5061
func (a *ArangoRouteSpecDestination) GetSchema() *ArangoRouteSpecDestinationSchema {
5162
if a == nil || a.Schema == nil {
5263
return nil
@@ -85,7 +96,9 @@ func (a *ArangoRouteSpecDestination) Validate() error {
8596
}
8697

8798
if err := shared.WithErrors(
99+
shared.ValidateExclusiveFields(a, 1, "Service", "Endpoints"),
88100
shared.ValidateOptionalInterfacePath("service", a.Service),
101+
shared.ValidateOptionalInterfacePath("endpoints", a.Endpoints),
89102
shared.ValidateOptionalInterfacePath("schema", a.Schema),
90103
shared.ValidateOptionalInterfacePath("tls", a.TLS),
91104
shared.ValidateOptionalInterfacePath("authentication", a.Authentication),

pkg/apis/networking/v1alpha1/route_spec_destination_authentication.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ import (
2525
)
2626

2727
type ArangoRouteSpecDestinationAuthentication struct {
28+
// PassMode define authorization details pass mode when authorization was successful
29+
// +doc/enum: override|Generates new token for the user
30+
// +doc/enum: pass|Pass token provided by the user
31+
// +doc/enum: remove|Removes authorization details from the request
2832
PassMode *ArangoRouteSpecAuthenticationPassMode `json:"passMode,omitempty"`
29-
Type *ArangoRouteSpecAuthenticationType `json:"type,omitempty"`
33+
34+
// Type of the authentication
35+
// +doc/enum: optional|Authentication is header is validated and passed to the service. In case if is unauthorized, requests is still passed
36+
// +doc/enum: required|Authentication is header is validated and passed to the service. In case if is unauthorized, returns 403
37+
Type *ArangoRouteSpecAuthenticationType `json:"type,omitempty"`
3038
}
3139

3240
func (a *ArangoRouteSpecDestinationAuthentication) GetType() ArangoRouteSpecAuthenticationType {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import (
24+
"k8s.io/apimachinery/pkg/util/intstr"
25+
26+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
27+
sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1"
28+
)
29+
30+
type ArangoRouteSpecDestinationEndpoints struct {
31+
// Keeps information on the service, which maps then to the endpoints
32+
*sharedApi.Object `json:",inline,omitempty"`
33+
34+
// Port defines Port or Port Name used as destination
35+
// +doc/type: intstr.IntOrString
36+
Port *intstr.IntOrString `json:"port,omitempty"`
37+
}
38+
39+
func (a *ArangoRouteSpecDestinationEndpoints) GetPort() *intstr.IntOrString {
40+
if a == nil || a.Port == nil {
41+
return nil
42+
}
43+
44+
return a.Port
45+
}
46+
47+
func (a *ArangoRouteSpecDestinationEndpoints) Validate() error {
48+
if a == nil {
49+
a = &ArangoRouteSpecDestinationEndpoints{}
50+
}
51+
52+
if err := shared.WithErrors(a.Object.Validate(), shared.ValidateRequiredPath("port", a.Port, func(i intstr.IntOrString) error {
53+
return nil
54+
})); err != nil {
55+
return err
56+
}
57+
58+
return nil
59+
}

pkg/apis/networking/v1alpha1/route_spec_destination_service.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ type ArangoRouteSpecDestinationService struct {
3232

3333
// Port defines Port or Port Name used as destination
3434
// +doc/type: intstr.IntOrString
35-
// +doc/link: Documentation|https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/
3635
Port *intstr.IntOrString `json:"port,omitempty"`
3736
}
3837

pkg/apis/networking/v1alpha1/route_status_target.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type ArangoRouteStatusTarget struct {
3030
// Destinations keeps target destinations
3131
Destinations ArangoRouteStatusTargetDestinations `json:"destinations,omitempty"`
3232

33+
// Type define destination type
34+
Type ArangoRouteStatusTargetType `json:"type,omitempty"`
35+
3336
// TLS Keeps target TLS Settings (if not nil, TLS is enabled)
3437
TLS *ArangoRouteStatusTargetTLS `json:"TLS,omitempty"`
3538

@@ -64,5 +67,5 @@ func (a *ArangoRouteStatusTarget) Hash() string {
6467
if a == nil {
6568
return ""
6669
}
67-
return util.SHA256FromStringArray(a.Destinations.Hash(), a.TLS.Hash(), a.Path, a.Authentication.Hash())
70+
return util.SHA256FromStringArray(a.Destinations.Hash(), a.Type.Hash(), a.TLS.Hash(), a.Path, a.Authentication.Hash())
6871
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import "github.com/arangodb/kube-arangodb/pkg/util"
24+
25+
type ArangoRouteStatusTargetType string
26+
27+
func (a ArangoRouteStatusTargetType) Hash() string {
28+
return util.SHA256FromString(string(a))
29+
}
30+
31+
const (
32+
ArangoRouteStatusTargetServiceType ArangoRouteStatusTargetType = "service"
33+
ArangoRouteStatusTargetEndpointsType ArangoRouteStatusTargetType = "endpoints"
34+
)

pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)