Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

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 @@ -18,6 +18,7 @@
- (Bugfix) (Platform) Installer move to OCI
- (Bugfix) (Platform) Fix Monitoring RBAC
- (Feature) (Platform) Do not require LM during install commands
- (Feature) (Platform) ArangoRoute Redirect

## [1.3.1](https://github.com/arangodb/kube-arangodb/tree/1.3.1) (2025-10-07)
- (Documentation) Add ArangoPlatformStorage Docs & Examples
Expand Down
18 changes: 14 additions & 4 deletions docs/api/ArangoRoute.V1Beta1.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ Port defines Port or Port Name used as destination

### .spec.destination.path

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

Path defines service path used for overrides

***

### .spec.destination.protocol

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

Protocol defines http protocol used for the route

Expand All @@ -91,9 +91,19 @@ Possible Values:

***

### .spec.destination.redirect.code

Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.1/pkg/apis/networking/v1beta1/route_spec_destination_redirect.go#L33)</sup>

Code the redirection response status code

Default Value: `307`

***

### .spec.destination.schema

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

Schema defines HTTP/S schema used for connection

Expand Down Expand Up @@ -133,7 +143,7 @@ Port defines Port or Port Name used as destination

### .spec.destination.timeout

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

Timeout specify the upstream request timeout

Expand Down
16 changes: 15 additions & 1 deletion pkg/apis/networking/v1beta1/route_spec_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ type ArangoRouteSpecDestination struct {
// Endpoints defines service upstream reference - which is used to find endpoints
Endpoints *ArangoRouteSpecDestinationEndpoints `json:"endpoints,omitempty"`

// Redirect defines redirect instruction
Redirect *ArangoRouteSpecDestinationRedirect `json:"redirect,omitempty"`

// Schema defines HTTP/S schema used for connection
// +doc/default: http
// +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/default: http1
// +doc/enum: http1|HTTP 1.1 Protocol
// +doc/enum: http2|HTTP 2 Protocol
Protocol *ArangoRouteDestinationProtocol `json:"protocol,omitempty"`
Expand Down Expand Up @@ -68,6 +73,14 @@ func (a *ArangoRouteSpecDestination) GetService() *ArangoRouteSpecDestinationSer
return a.Service
}

func (a *ArangoRouteSpecDestination) GetRedirect() *ArangoRouteSpecDestinationRedirect {
if a == nil || a.Redirect == nil {
return nil
}

return a.Redirect
}

func (a *ArangoRouteSpecDestination) GetEndpoints() *ArangoRouteSpecDestinationEndpoints {
if a == nil || a.Endpoints == nil {
return nil
Expand Down Expand Up @@ -132,9 +145,10 @@ func (a *ArangoRouteSpecDestination) Validate() error {
}

if err := shared.WithErrors(
shared.ValidateExclusiveFields(a, 1, "Service", "Endpoints"),
shared.ValidateExclusiveFields(a, 1, "Service", "Endpoints", "Redirect"),
shared.ValidateOptionalInterfacePath("service", a.Service),
shared.ValidateOptionalInterfacePath("endpoints", a.Endpoints),
shared.ValidateOptionalInterfacePath("redirect", a.Redirect),
shared.ValidateOptionalInterfacePath("schema", a.Schema),
shared.ValidateOptionalInterfacePath("protocol", a.Protocol),
shared.ValidateOptionalInterfacePath("tls", a.TLS),
Expand Down
71 changes: 71 additions & 0 deletions pkg/apis/networking/v1beta1/route_spec_destination_redirect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// DISCLAIMER
//
// Copyright 2025 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 v1beta1

import (
goHttp "net/http"

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

type ArangoRouteSpecDestinationRedirect struct {
// Code the redirection response status code
// +doc/default: 307
Code *int `json:"code,omitempty"`
}

func (a *ArangoRouteSpecDestinationRedirect) GetCode() int {
if a == nil || a.Code == nil {
return goHttp.StatusTemporaryRedirect
}
return *a.Code
}

func (a *ArangoRouteSpecDestinationRedirect) Validate() error {
if a == nil {
a = &ArangoRouteSpecDestinationRedirect{}
}

if err := shared.WithErrors(
shared.ValidateOptionalPath("code", a.Code, func(i int) error {
if i == goHttp.StatusTemporaryRedirect || i == goHttp.StatusMovedPermanently {
return nil
}

return errors.Errorf("Invalid code. Got %d, allowed 301 & 307", i)
}),
); err != nil {
return err
}

return nil
}

func (a *ArangoRouteSpecDestinationRedirect) AsStatus() ArangoRouteStatusTargetRedirect {
if a == nil {
return ArangoRouteStatusTargetRedirect{}
}

return ArangoRouteStatusTargetRedirect{
Code: a.GetCode(),
}
}
5 changes: 4 additions & 1 deletion pkg/apis/networking/v1beta1/route_status_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ type ArangoRouteStatusTarget struct {

// Timeout specify the upstream request timeout
Timeout meta.Duration `json:"timeout,omitempty"`

// Redirect defines the route status
Redirect ArangoRouteStatusTargetRedirect `json:"redirect,omitempty"`
}

func (a *ArangoRouteStatusTarget) RenderURLs() []string {
Expand All @@ -81,5 +84,5 @@ func (a *ArangoRouteStatusTarget) Hash() string {
if a == nil {
return ""
}
return util.SHA256FromStringArray(a.Destinations.Hash(), a.Type.Hash(), a.TLS.Hash(), a.Protocol.String(), a.Path, a.Authentication.Hash(), a.Options.Hash(), a.Timeout.String(), a.Route.Hash())
return util.SHA256FromNonEmptyStringArray(a.Destinations.Hash(), a.Type.Hash(), a.TLS.Hash(), a.Protocol.String(), a.Path, a.Authentication.Hash(), a.Options.Hash(), a.Timeout.String(), a.Route.Hash(), a.Redirect.Hash())
}
35 changes: 35 additions & 0 deletions pkg/apis/networking/v1beta1/route_status_target_redirect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// DISCLAIMER
//
// Copyright 2025 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 v1beta1

import (
"fmt"

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

type ArangoRouteStatusTargetRedirect struct {
Code int `json:"code,omitempty"`
}

func (a ArangoRouteStatusTargetRedirect) Hash() string {
return util.SHA256FromStringArray(fmt.Sprintf("%d", a.Code))
}
1 change: 1 addition & 0 deletions pkg/apis/networking/v1beta1/route_status_target_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ func (a ArangoRouteStatusTargetType) Hash() string {
const (
ArangoRouteStatusTargetServiceType ArangoRouteStatusTargetType = "service"
ArangoRouteStatusTargetEndpointsType ArangoRouteStatusTargetType = "endpoints"
ArangoRouteStatusTargetRedirectType ArangoRouteStatusTargetType = "redirect"
)
43 changes: 43 additions & 0 deletions pkg/apis/networking/v1beta1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions pkg/apis/shared/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ func ValidatePath[T any](path string, in T, validator func(T) error) error {
return PrefixResourceErrors(path, validator(in))
}

// ValidateMultiPath Validates object
func ValidateMultiPath[T any](path string, in T, validators ...func(T) error) error {
return PrefixResourceErrors(path, util.FormatList(validators, func(a func(T) error) error {
return a(in)
})...)
}

// ValidateRequiredPath Validates object and required not nil value
func ValidateRequiredPath[T any](path string, in *T, validator func(T) error) error {
return PrefixResourceErrors(path, ValidateRequired(in, validator))
Expand Down
8 changes: 8 additions & 0 deletions pkg/crd/crds/networking-route.schema.generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ v1beta1:
- http1
- http2
type: string
redirect:
description: Redirect defines redirect instruction
properties:
code:
description: Code the redirection response status code
format: int32
type: integer
type: object
schema:
description: Schema defines HTTP/S schema used for connection
enum:
Expand Down
Loading