multicluster

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 16 Imported by: 21

Documentation

Index

Constants

View Source
const (
	// Local is the name of the local cluster in KubeVela
	Local string = "local"
)

Variables

View Source
var DefaultClusterGatewayClientOptions = ClusterGatewayClientOptions{}

DefaultClusterGatewayClientOptions the default ClusterGatewayClientOptions

Functions

func AddClusterGatewayClientFlags

func AddClusterGatewayClientFlags(set *pflag.FlagSet)

AddClusterGatewayClientFlags add flags for default cluster-gateway client

func AddFlags

func AddFlags(set *pflag.FlagSet)

AddFlags add flags for multicluster

func ClusterFrom

func ClusterFrom(ctx context.Context) (string, bool)

ClusterFrom returns the value of the cluster key on the ctx

func IsLocal

func IsLocal(cluster string) bool

IsLocal check if cluster is local cluster

func NewClient

func NewClient(config *rest.Config, options ClientOptions) (client.Client, error)

NewClient create a multi-cluster client for handling multi-cluster requests If ClusterGatewayURL is not set, the client will use the Kubernetes aggregated api directly. All multi-cluster requests will be directed to the hub Kubernetes APIServer. The managed cluster requests will be redirected from the Kubernetes APIServer to cluster-gateway. If ClusterGatewayURL is set, the client will directly call cluster-gateway for managed cluster requests, instead of calling the hub Kubernetes APIServer.

func NewDefaultClient

func NewDefaultClient(config *rest.Config, options client.Options) (client.Client, error)

NewDefaultClient create default client with default DefaultClusterGatewayClientOptions

func NewTransportWrapper

func NewTransportWrapper(options ...TransportOption) transport.WrapperFunc

NewTransportWrapper create a WrapperFunc for wrapping RoundTripper with multi-cluster transport

func WithCluster

func WithCluster(parent context.Context, cluster string) context.Context

WithCluster returns a copy of parent in which the cluster value is set

Types

type ClientOptions

type ClientOptions struct {
	client.Options
	ClusterGateway ClusterGatewayClientOptions
}

ClientOptions the options for creating multi-cluster gatedClient

type ClusterGatewayClientOptions

type ClusterGatewayClientOptions struct {
	// URL the url for cluster-gateway. If empty, multi-cluster request will use
	// the Kubernetes aggregated api.
	URL string
	// CAFile the CA file for cluster-gateway. If neither ClusterGatewayURL nor
	// ClusterGatewayCAFile is empty, the CA file will be used when accessing
	// cluster-gateway.
	CAFile string
}

ClusterGatewayClientOptions the options for creating the gateway client

type ForCluster

type ForCluster string

ForCluster create transport for specified cluster

func (ForCluster) ApplyToTransport

func (op ForCluster) ApplyToTransport(t *Transport)

ApplyToTransport .

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport the transport for multi-cluster request

func NewTransport

func NewTransport(rt http.RoundTripper) *Transport

NewTransport create a transport instance for handling multi-cluster request

func (*Transport) CancelRequest

func (t *Transport) CancelRequest(req *http.Request)

CancelRequest will try cancel request with the inner round tripper

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is the main function for the re-write API path logic

func (*Transport) WrappedRoundTripper

func (t *Transport) WrappedRoundTripper() http.RoundTripper

WrappedRoundTripper can get the wrapped RoundTripper

type TransportOption

type TransportOption interface {
	ApplyToTransport(*Transport)
}

TransportOption option for creating transport

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL