1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Feature] DebugPackage ArangoRoutes (#1719)

This commit is contained in:
Adam Janikowski 2024-09-10 11:01:52 +02:00 committed by GitHub
parent fe97fc3cc0
commit 6404de3ce4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 127 additions and 0 deletions

View file

@ -27,6 +27,7 @@
- (Feature) Scheduler Handler
- (Feature) (Gateway) ArangoDB Auth Token
- (Feature) (Gateway) Dynamic Configuration
- (Feature) DebugPackage ArangoRoutes
## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries

View file

@ -39611,6 +39611,11 @@ v2alpha1:
gateway:
description: Gateway defined main Gateway configuration.
properties:
dynamic:
description: |-
Dynamic setting enables/disables support dynamic configuration of the gateway in the cluster.
When enabled, gateway config will be reloaded by ConfigMap live updates.
type: boolean
enabled:
description: |-
Enabled setting enables/disables support for gateway in the cluster.

View file

@ -46,6 +46,7 @@ var rootFactories = []shared.Factory{
kubernetes.Analytics(),
kubernetes.Backup(),
kubernetes.Scheduler(),
kubernetes.Networking(),
}
func InitCommand(cmd *cobra.Command) {

View file

@ -0,0 +1,47 @@
//
// 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 kubernetes
import (
"github.com/rs/zerolog"
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
)
func Networking() shared.Factory {
return shared.NewFactory("networking", true, networking)
}
func networking(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Errorf("Client is not initialised")
}
if err := networkingArangoRoutes(logger, files, k); err != nil {
logger.Err(err).Msgf("Error while collecting networking arango routes")
return err
}
return nil
}

View file

@ -0,0 +1,73 @@
//
// 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 kubernetes
import (
"context"
"fmt"
"github.com/rs/zerolog"
networkingApi "github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1"
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
)
func networkingArangoRoutes(logger zerolog.Logger, files chan<- shared.File, client kclient.Client) error {
arangoRoutes, err := listNetowkingArangoRoutes(client)
if err != nil {
if kerrors.IsForbiddenOrNotFound(err) {
return nil
}
return err
}
if err := errors.ExecuteWithErrorArrayP2(networkingArangoRoute, client, files, arangoRoutes...); err != nil {
logger.Err(err).Msgf("Error while collecting networking arango routes")
return err
}
return nil
}
func networkingArangoRoute(client kclient.Client, files chan<- shared.File, ext *networkingApi.ArangoRoute) error {
files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/arango/networking/arangoroutes/%s.yaml", ext.GetName()), func() ([]interface{}, error) {
return []interface{}{ext}, nil
})
return nil
}
func listNetowkingArangoRoutes(client kclient.Client) ([]*networkingApi.ArangoRoute, error) {
return ListObjects[*networkingApi.ArangoRouteList, *networkingApi.ArangoRoute](context.Background(), client.Arango().NetworkingV1alpha1().ArangoRoutes(cli.GetInput().Namespace), func(result *networkingApi.ArangoRouteList) []*networkingApi.ArangoRoute {
q := make([]*networkingApi.ArangoRoute, len(result.Items))
for id, e := range result.Items {
q[id] = e.DeepCopy()
}
return q
})
}