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
354 changes: 354 additions & 0 deletions README.md

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/bramvdbogaerde/go-scp v1.6.0
github.com/deckhouse/lib-dhctl v0.13.0
github.com/deckhouse/lib-gossh v0.3.0
github.com/flant/kube-client v1.5.1
github.com/go-openapi/spec v0.19.8
github.com/google/uuid v1.6.0
github.com/hashicorp/go-multierror v1.1.1
Expand All @@ -15,6 +16,7 @@ require (
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
golang.org/x/term v0.39.0
k8s.io/apimachinery v0.32.10
k8s.io/client-go v0.32.10
sigs.k8s.io/yaml v1.6.0
)
Expand All @@ -23,9 +25,14 @@ require (
github.com/DataDog/gostackparse v0.7.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/avelino/slugify v0.0.0-20180501145920-855f152bd774 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/analysis v0.19.10 // indirect
github.com/go-openapi/errors v0.19.7 // indirect
Expand All @@ -38,34 +45,56 @@ require (
github.com/go-openapi/validate v0.19.12 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gookit/color v1.5.2 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/werf/logboek v0.5.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.mongodb.org/mongo-driver v1.5.1 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.3 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.32.10 // indirect
k8s.io/api v0.32.10 // indirect
k8s.io/apiextensions-apiserver v0.32.10 // indirect
k8s.io/cli-runtime v0.32.10 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/kustomize/api v0.18.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.18.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
)
57 changes: 56 additions & 1 deletion go.sum

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions hack/kind/cluster-kube-proxy.yml

This file was deleted.

67 changes: 67 additions & 0 deletions pkg/kube.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2026 Flant JSC
//
// 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.

package pkg

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
)

type KubeClient interface {
kubernetes.Interface
Dynamic() dynamic.Interface
APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
APIResource(apiVersion, kind string) (*metav1.APIResource, error)
GroupVersionResource(apiVersion, kind string) (schema.GroupVersionResource, error)
InvalidateDiscoveryCache()
}

type KubeProvider interface {
// Client
// create new client and initialize it
// if it uses over ssh will use current ssh client
// Created client will cache
// if it uses client over ssh can create new client
// if ssh client was switched
// current client will stop if new client was created but not fully
// because if we use over ssh current client can used in another routines
Client(ctx context.Context) (KubeClient, error)

// NewAdditionalClient
// create new additional client and initialize it
// if use over ssh create new ssh client for it
// you should call kube.Stop if client does not need. kube.Stop
// save for all clients not only over ssh
// also provider save all these clients for stop in Cleanup
NewAdditionalClient(ctx context.Context) (KubeClient, error)

// NewAdditionalClientWithoutInitialize
// create new additional client without initialize
// if use over ssh create new ssh client for it
// you should call kube.Stop if client does not need. kube.Stop
// save for all clients not only over ssh
// also provider save all these clients for stop in Cleanup
NewAdditionalClientWithoutInitialize(ctx context.Context) (KubeClient, error)

// Cleanup
// Stops all additional clients got from NewAdditionalClient and NewAdditionalClientWithoutInitialize
// also current client also stop, but not fully
// because if we use over ssh current client can used in another routines
Cleanup(ctx context.Context) error
}
Loading