multicluster

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0 Imports: 16 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// ClusterContextKey is the name of cluster using in client http context
	ClusterContextKey = contextKey("ClusterName")
	// ClusterLabelKey specifies which cluster the target k8s object should locate
	ClusterLabelKey = "cluster.oam.dev/clusterName"
	// ClusterLocalName specifies the local cluster
	ClusterLocalName = "local"
)

Variables

View Source
var (
	// ClusterGatewaySecretNamespace the namespace where cluster-gateway secret locates
	ClusterGatewaySecretNamespace string
)

Functions

func Context

Context create context with multi-cluster

func ContextWithClusterName

func ContextWithClusterName(ctx context.Context, clusterName string) context.Context

ContextWithClusterName create context with multi-cluster by cluster name

func FormatProxyURL

func FormatProxyURL(clusterName, originalPath string) string

FormatProxyURL will format the request API path by the cluster gateway resources rule

func GetClusterGatewayService

func GetClusterGatewayService(ctx context.Context, c client.Client) (*apiregistrationv1.ServiceReference, error)

GetClusterGatewayService get cluster gateway backend service reference if service is ready, service is returned and no error is returned if service exists but is not ready, both service and error are returned if service does not exist, only error is returned

func Initialize

func Initialize(restConfig *rest.Config) error

Initialize prepare multicluster environment by checking cluster gateway service in clusters and hack rest config to use cluster gateway if cluster gateway service is not ready, it will wait up to 5 minutes

func NewSecretModeMultiClusterRoundTripper

func NewSecretModeMultiClusterRoundTripper(rt http.RoundTripper) http.RoundTripper

NewSecretModeMultiClusterRoundTripper will re-write the API path to one of the multi-cluster resource for a request if context has the value

func SetClusterName

func SetClusterName(obj *unstructured.Unstructured, clusterName string)

SetClusterName set cluster name for object

func WaitUntilClusterGatewayReady

func WaitUntilClusterGatewayReady(ctx context.Context, c client.Client, maxRetry int, interval time.Duration) (svc *apiregistrationv1.ServiceReference, err error)

WaitUntilClusterGatewayReady wait cluster gateway service to be ready to serve

Types

This section is empty.

Jump to

Keyboard shortcuts

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