Skip to content

Commit

Permalink
[Feature] [Networking] Gateway options sync (#1780)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow authored Dec 10, 2024
1 parent c7cce48 commit 3993a0c
Show file tree
Hide file tree
Showing 20 changed files with 385 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- (Feature) (Platform) Shutdown migration to CE
- (Feature) (Scheduler) Shutdown Integration
- (Feature) CertManager Integration
- (Feature) (Networking) Gateway Options sync

## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
- (Feature) ArangoRoute CRD
Expand Down
27 changes: 23 additions & 4 deletions docs/api/ArangoRoute.V1Alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ Insecure allows Insecure traffic

### .spec.options.upgrade\[int\].enabled

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

Enabled defines if upgrade option is enabled

***

### .spec.options.upgrade\[int\].type

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

Type defines type of the Upgrade

Expand Down Expand Up @@ -252,9 +252,28 @@ Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.

***

### .status.target.options.upgrade\[int\].enabled

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

Enabled defines if upgrade option is enabled

***

### .status.target.options.upgrade\[int\].type

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

Type defines type of the Upgrade

Possible Values:
* `"websocket"` (default) - HTTP WebSocket Upgrade type

***

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

Path specifies request path override

Expand All @@ -268,7 +287,7 @@ Protocol defines http protocol used for the route

***

### .status.target.TLS.insecure
### .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
4 changes: 2 additions & 2 deletions docs/integration/shutdown.v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Example:
```yaml
metadata:
annotations:
core.shutdown.arangodb.com/app: "true"
core.shutdown.arangodb.com/app2: "true"
core.shutdown.arangodb.com/app: "wait"
core.shutdown.arangodb.com/app2: "wait"
container.shutdown.arangodb.com/app3: port1
spec:
containers:
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/networking/v1alpha1/route_spec_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ type ArangoRouteSpecOptions struct {
Upgrade ArangoRouteSpecOptionsUpgrade `json:"upgrade,omitempty"`
}

func (a *ArangoRouteSpecOptions) AsStatus() *ArangoRouteStatusTargetOptions {
if a == nil {
return nil
}

return &ArangoRouteStatusTargetOptions{
Upgrade: a.Upgrade.asStatus(),
}
}

func (a *ArangoRouteSpecOptions) Validate() error {
if a == nil {
a = &ArangoRouteSpecOptions{}
Expand Down
22 changes: 21 additions & 1 deletion pkg/apis/networking/v1alpha1/route_spec_options_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,27 @@

package v1alpha1

import shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
import (
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/util"
)

type ArangoRouteSpecOptionsUpgrade []ArangoRouteSpecOptionUpgrade

func (a ArangoRouteSpecOptionsUpgrade) Validate() error {
return shared.ValidateInterfaceList(a)
}

func (a ArangoRouteSpecOptionsUpgrade) asStatus() ArangoRouteStatusTargetOptionsUpgrade {
if len(a) == 0 {
return nil
}

return util.FormatList(a, func(a ArangoRouteSpecOptionUpgrade) ArangoRouteStatusTargetOptionUpgrade {
return a.asStatus()
})
}

type ArangoRouteSpecOptionUpgrade struct {
// Type defines type of the Upgrade
// +doc/enum: websocket|HTTP WebSocket Upgrade type
Expand All @@ -37,6 +50,13 @@ type ArangoRouteSpecOptionUpgrade struct {
Enabled *bool `json:"enabled,omitempty"`
}

func (a ArangoRouteSpecOptionUpgrade) asStatus() ArangoRouteStatusTargetOptionUpgrade {
return ArangoRouteStatusTargetOptionUpgrade{
Type: a.Type,
Enabled: util.NewType(util.WithDefault(a.Enabled)),
}
}

func (a ArangoRouteSpecOptionUpgrade) Validate() error {
if err := shared.WithErrors(
shared.ValidateRequiredInterfacePath("type", a.Type),
Expand Down
7 changes: 5 additions & 2 deletions pkg/apis/networking/v1alpha1/route_status_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ type ArangoRouteStatusTarget struct {
Type ArangoRouteStatusTargetType `json:"type,omitempty"`

// TLS Keeps target TLS Settings (if not nil, TLS is enabled)
TLS *ArangoRouteStatusTargetTLS `json:"TLS,omitempty"`
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"`

// Options defines connection upgrade options
Options *ArangoRouteStatusTargetOptions `json:"options,omitempty"`

// Path specifies request path override
Path string `json:"path,omitempty"`
}
Expand Down Expand Up @@ -70,5 +73,5 @@ func (a *ArangoRouteStatusTarget) Hash() string {
if a == nil {
return ""
}
return util.SHA256FromStringArray(a.Destinations.Hash(), a.Type.Hash(), a.TLS.Hash(), a.Path, a.Authentication.Hash())
return util.SHA256FromStringArray(a.Destinations.Hash(), a.Type.Hash(), a.TLS.Hash(), a.Protocol.String(), a.Path, a.Authentication.Hash(), a.Options.Hash())
}
36 changes: 36 additions & 0 deletions pkg/apis/networking/v1alpha1/route_status_target_options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// 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 Statusific 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"

type ArangoRouteStatusTargetOptions struct {
// Upgrade keeps the connection upgrade options
Upgrade ArangoRouteStatusTargetOptionsUpgrade `json:"upgrade,omitempty"`
}

func (a *ArangoRouteStatusTargetOptions) Hash() string {
if a == nil {
return ""
}

return util.SHA256FromStringArray(a.Upgrade.Hash())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// 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 Statusific 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"

type ArangoRouteStatusTargetOptionsUpgrade []ArangoRouteStatusTargetOptionUpgrade

func (a ArangoRouteStatusTargetOptionsUpgrade) Hash() string {
if len(a) == 0 {
return ""
}

return util.SHA256FromStringArray(util.FormatList(a, func(a ArangoRouteStatusTargetOptionUpgrade) string {
return a.Hash()
})...)
}

type ArangoRouteStatusTargetOptionUpgrade struct {
// Type defines type of the Upgrade
// +doc/enum: websocket|HTTP WebSocket Upgrade type
Type ArangoRouteUpgradeOptionType `json:"type"`

// Enabled defines if upgrade option is enabled
Enabled *bool `json:"enabled,omitempty"`
}

func (a *ArangoRouteStatusTargetOptionUpgrade) Hash() string {
if a == nil {
return ""
}

return util.SHA256FromStringArray(string(a.Type), util.BoolSwitch(util.WithDefault(a.Enabled), "true", "false"))
}
71 changes: 71 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.

15 changes: 15 additions & 0 deletions pkg/deployment/resources/config_map_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ func (r *Resources) renderGatewayConfig(cachedStatus inspectorInterface.Inspecto
}
if tls := target.TLS; tls != nil {
dest.Type = util.NewType(gateway.ConfigDestinationTypeHTTPS)
dest.TLS.Insecure = util.NewType(tls.IsInsecure())
}
switch target.Protocol {
case networkingApi.ArangoRouteDestinationProtocolHTTP1:
dest.Protocol = util.NewType(gateway.ConfigDestinationProtocolHTTP1)
case networkingApi.ArangoRouteDestinationProtocolHTTP2:
dest.Protocol = util.NewType(gateway.ConfigDestinationProtocolHTTP2)
}
if opts := target.Options; opts != nil {
for _, upgrade := range opts.Upgrade {
dest.UpgradeConfigs = append(dest.UpgradeConfigs, gateway.ConfigDestinationUpgrade{
Type: string(upgrade.Type),
Enabled: util.NewType(util.WithDefault(upgrade.Enabled)),
})
}
}
dest.Path = util.NewType(target.Path)
dest.AuthExtension = &gateway.ConfigAuthZExtension{
Expand Down
Loading

0 comments on commit 3993a0c

Please sign in to comment.