Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- (Feature) (Platform) Chart Integration
- (Maintenance) Switch to google.golang.org/protobuf
- (Feature) Add DebugPackage to the OPS Binary
- (Feature) (Networking) ArangoRoute Protocol

## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
- (Feature) ArangoRoute CRD
Expand Down
30 changes: 27 additions & 3 deletions docs/api/ArangoRoute.V1Alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,34 @@ UID keeps the information about object UID

### .spec.destination.path

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_spec_destination.go#L39)</sup>
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_spec_destination.go#L46)</sup>

Path defines service path used for overrides

***

### .spec.destination.protocol

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_spec_destination.go#L40)</sup>

Protocol defines http protocol used for the route

Possible Values:
* `"http1"` (default) - HTTP 1.1 Protocol
* `"http2"` - HTTP 2 Protocol

***

### .spec.destination.schema

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_spec_destination.go#L33)</sup>
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_spec_destination.go#L35)</sup>

Schema defines HTTP/S schema used for connection

Possible Values:
* `"http"` (default) - HTTP Connection
* `"https"` - HTTPS Connection (HTTP with TLS)

***

### .spec.destination.service.checksum
Expand Down Expand Up @@ -238,12 +254,20 @@ Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.

### .status.target.path

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_status_target.go#L43)</sup>
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_status_target.go#L46)</sup>

Path specifies request path override

***

### .status.target.protocol

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

Protocol defines http protocol used for the route

***

### .status.target.TLS.insecure

Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.43/pkg/apis/networking/v1alpha1/route_status_target_tls.go#L27)</sup>
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/networking/v1alpha1/route_spec_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ type ArangoRouteSpecDestination struct {
Endpoints *ArangoRouteSpecDestinationEndpoints `json:"endpoints,omitempty"`

// Schema defines HTTP/S schema used for connection
// +doc/enum: http|HTTP Connection
// +doc/enum: https|HTTPS Connection (HTTP with TLS)
Schema *ArangoRouteSpecDestinationSchema `json:"schema,omitempty"`

// Protocol defines http protocol used for the route
// +doc/enum: http1|HTTP 1.1 Protocol
// +doc/enum: http2|HTTP 2 Protocol
Protocol *ArangoRouteDestinationProtocol `json:"protocol,omitempty"`

// TLS defines TLS Configuration
TLS *ArangoRouteSpecDestinationTLS `json:"tls,omitempty"`

Expand All @@ -58,6 +65,14 @@ func (a *ArangoRouteSpecDestination) GetEndpoints() *ArangoRouteSpecDestinationE
return a.Endpoints
}

func (a *ArangoRouteSpecDestination) GetProtocol() *ArangoRouteDestinationProtocol {
if a == nil || a.Schema == nil {
return nil
}

return a.Protocol
}

func (a *ArangoRouteSpecDestination) GetSchema() *ArangoRouteSpecDestinationSchema {
if a == nil || a.Schema == nil {
return nil
Expand Down Expand Up @@ -100,6 +115,7 @@ func (a *ArangoRouteSpecDestination) Validate() error {
shared.ValidateOptionalInterfacePath("service", a.Service),
shared.ValidateOptionalInterfacePath("endpoints", a.Endpoints),
shared.ValidateOptionalInterfacePath("schema", a.Schema),
shared.ValidateOptionalInterfacePath("protocol", a.Protocol),
shared.ValidateOptionalInterfacePath("tls", a.TLS),
shared.ValidateOptionalInterfacePath("authentication", a.Authentication),
shared.PrefixResourceError("path", shared.ValidateAPIPath(a.GetPath())),
Expand Down
55 changes: 55 additions & 0 deletions pkg/apis/networking/v1alpha1/route_spec_protocol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1alpha1

import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/strings"
)

type ArangoRouteDestinationProtocol string

const (
ArangoRouteDestinationProtocolHTTP1 ArangoRouteDestinationProtocol = "http1"
ArangoRouteDestinationProtocolHTTP2 ArangoRouteDestinationProtocol = "http2"
ArangoRouteDestinationProtocolDefault = ArangoRouteDestinationProtocolHTTP1
)

func (a *ArangoRouteDestinationProtocol) Get() ArangoRouteDestinationProtocol {
if a == nil {
return ArangoRouteDestinationProtocolDefault
}

return ArangoRouteDestinationProtocol(strings.ToLower(string(*a)))
}

func (a *ArangoRouteDestinationProtocol) String() string {
return string(a.Get())
}

func (a *ArangoRouteDestinationProtocol) Validate() error {
switch x := a.Get(); x {
case ArangoRouteDestinationProtocolHTTP1, ArangoRouteDestinationProtocolHTTP2:
return nil
default:
return errors.Errorf("Invalid schema: %s", x.String())
}
}
3 changes: 3 additions & 0 deletions pkg/apis/networking/v1alpha1/route_status_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type ArangoRouteStatusTarget struct {
// TLS Keeps target TLS Settings (if not nil, TLS is enabled)
TLS *ArangoRouteStatusTargetTLS `json:"TLS,omitempty"`

// Protocol defines http protocol used for the route
Protocol ArangoRouteDestinationProtocol `json:"protocol,omitempty"`

// Authentication specifies the authentication details
Authentication ArangoRouteStatusTargetAuthentication `json:"authentication,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go

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

9 changes: 9 additions & 0 deletions pkg/crd/crds/networking-route.schema.generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,17 @@ v1alpha1:
path:
description: Path defines service path used for overrides
type: string
protocol:
description: Protocol defines http protocol used for the route
enum:
- http1
- http2
type: string
schema:
description: Schema defines HTTP/S schema used for connection
enum:
- http
- https
type: string
service:
description: Service defines service upstream reference
Expand Down
21 changes: 4 additions & 17 deletions pkg/deployment/resources/gateway/gateway_config_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ import (
"time"

clusterAPI "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
coreAPI "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
endpointAPI "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
routeAPI "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
upstreamHttpApi "github.com/envoyproxy/go-control-plane/envoy/extensions/upstreams/http/v3"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/durationpb"

Expand Down Expand Up @@ -63,6 +61,8 @@ type ConfigDestination struct {

Type *ConfigDestinationType `json:"type,omitempty"`

Protocol *ConfigDestinationProtocol `json:"protocol,omitempty"`

Path *string `json:"path,omitempty"`

AuthExtension *ConfigAuthZExtension `json:"authExtension,omitempty"`
Expand All @@ -77,6 +77,7 @@ func (c *ConfigDestination) Validate() error {
return shared.WithErrors(
shared.PrefixResourceError("targets", c.Targets.Validate()),
shared.PrefixResourceError("type", c.Type.Validate()),
shared.PrefixResourceError("protocol", c.Protocol.Validate()),
shared.PrefixResourceError("path", shared.ValidateAPIPath(c.GetPath())),
shared.PrefixResourceError("authExtension", c.AuthExtension.Validate()),
shared.PrefixResourceError("upgradeConfigs", c.UpgradeConfigs.Validate()),
Expand Down Expand Up @@ -130,21 +131,7 @@ func (c *ConfigDestination) getUpgradeConfigs() ConfigDestinationsUpgrade {
}

func (c *ConfigDestination) RenderCluster(name string) (*clusterAPI.Cluster, error) {
hpo, err := anypb.New(&upstreamHttpApi.HttpProtocolOptions{
UpstreamProtocolOptions: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_{
ExplicitHttpConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig{
ProtocolConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_Http2ProtocolOptions{
Http2ProtocolOptions: &coreAPI.Http2ProtocolOptions{
ConnectionKeepalive: &coreAPI.KeepaliveSettings{
Interval: durationpb.New(15 * time.Second),
Timeout: durationpb.New(30 * time.Second),
ConnectionIdleInterval: durationpb.New(60 * time.Second),
},
},
},
},
},
})
hpo, err := anypb.New(c.Protocol.Options())
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package gateway

import (
"time"

coreAPI "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
upstreamHttpApi "github.com/envoyproxy/go-control-plane/envoy/extensions/upstreams/http/v3"
"google.golang.org/protobuf/types/known/durationpb"

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

type ConfigDestinationProtocol int

const (
ConfigDestinationProtocolHTTP1 ConfigDestinationProtocol = iota
ConfigDestinationProtocolHTTP2
)

func (c *ConfigDestinationProtocol) Get() ConfigDestinationProtocol {
if c == nil {
return ConfigDestinationProtocolHTTP1
}

switch v := *c; v {
case ConfigDestinationProtocolHTTP1, ConfigDestinationProtocolHTTP2:
return v
default:
return ConfigDestinationProtocolHTTP1
}
}

func (c *ConfigDestinationProtocol) Options() *upstreamHttpApi.HttpProtocolOptions {
switch c.Get() {
case ConfigDestinationProtocolHTTP1:
return &upstreamHttpApi.HttpProtocolOptions{
UpstreamProtocolOptions: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_{
ExplicitHttpConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig{
ProtocolConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_HttpProtocolOptions{
HttpProtocolOptions: &coreAPI.Http1ProtocolOptions{},
},
},
},
}
case ConfigDestinationProtocolHTTP2:
return &upstreamHttpApi.HttpProtocolOptions{
UpstreamProtocolOptions: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_{
ExplicitHttpConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig{
ProtocolConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_Http2ProtocolOptions{
Http2ProtocolOptions: &coreAPI.Http2ProtocolOptions{
ConnectionKeepalive: &coreAPI.KeepaliveSettings{
Interval: durationpb.New(15 * time.Second),
Timeout: durationpb.New(30 * time.Second),
ConnectionIdleInterval: durationpb.New(60 * time.Second),
},
},
},
},
},
}
default:
return &upstreamHttpApi.HttpProtocolOptions{
UpstreamProtocolOptions: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_{
ExplicitHttpConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig{
ProtocolConfig: &upstreamHttpApi.HttpProtocolOptions_ExplicitHttpConfig_HttpProtocolOptions{
HttpProtocolOptions: &coreAPI.Http1ProtocolOptions{},
},
},
},
}
}
}

func (c *ConfigDestinationProtocol) Validate() error {
switch c.Get() {
case ConfigDestinationProtocolHTTP1, ConfigDestinationProtocolHTTP2:
return nil
default:
return errors.Errorf("Invalid destination protocol")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (h *handler) HandleArangoDestinationEndpoints(ctx context.Context, item ope

target.Path = dest.GetPath()
target.Type = networkingApi.ArangoRouteStatusTargetEndpointsType
target.Protocol = dest.GetProtocol().Get()

// Render Auth Settings

Expand Down
Loading