utils

package
v1.2.3-fred.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOrSetKubeCluster

func CheckOrSetKubeCluster(ctx context.Context, p KubeServicesPresence, kubeClusterName, teleportClusterName string) (string, error)

CheckOrSetKubeCluster validates kubeClusterName if it's set, or a sane default based on registered clusters.

If no clusters are registered, a NotFound error is returned.

func EncodeClusterName

func EncodeClusterName(clusterName string) string

EncodeClusterName encodes cluster name for SNI matching

For example:

* Main cluster is main.example.com * Remote cluster is remote.example.com

After 'tsh login' the URL of the Kubernetes endpoint of 'remote.example.com' when accessed 'via main.example.com' looks like this:

'k72656d6f74652e6578616d706c652e636f6d0a.main.example.com'

For this to work, users have to add this address in public_addr section of kubernetes service to include 'main.example.com' in X509 '*.main.example.com' domain name

where part '72656d6f74652e6578616d706c652e636f6d0a' is a hex encoded remote.example.com

It is hex encoded to allow wildcard matching to work. In DNS wildcard match include only one '.'

func GetKubeClient

func GetKubeClient(configPath string) (client *kubernetes.Clientset, config *rest.Config, err error)

GetKubeClient returns instance of client to the kubernetes cluster using in-cluster configuration if available and falling back to configuration file under configPath otherwise

func KubeClusterNames

func KubeClusterNames(ctx context.Context, p KubeServicesPresence) ([]string, error)

KubeClusterNames returns a sorted list of unique kubernetes cluster names registered in p.

DELETE IN 11.0.0, replaced by ListKubeClustersWithFilters

func KubeClusters

func KubeClusters(ctx context.Context, p KubeServicesPresence) ([]types.KubeCluster, error)

KubeClusters returns a sorted list of unique kubernetes clusters registered in p.

DELETE IN 11.0.0, replaced by ListKubeClustersWithFilters

func ListKubeClustersWithFilters

func ListKubeClustersWithFilters(ctx context.Context, p client.ListResourcesClient, req proto.ListResourcesRequest) ([]types.KubeCluster, error)

ListKubeClusterWithFilters returns a sorted list of unique kubernetes clusters registered in p.

Types

type KubeServicesPresence

type KubeServicesPresence interface {
	// GetKubernetesServers returns a list of registered kubernetes servers.
	GetKubernetesServers(context.Context) ([]types.KubeServer, error)
}

KubeServicesPresence fetches a list of registered kubernetes servers. It's a subset of services.Presence.

type Kubeconfig

type Kubeconfig struct {
	CurrentContext string
	Contexts       map[string]*rest.Config
}

Kubeconfig is a parsed kubeconfig file representation.

func GetKubeConfig

func GetKubeConfig(configPath string, allConfigEntries bool, clusterName string) (*Kubeconfig, error)

GetKubeConfig returns kubernetes configuration from configPath file or, by default reads in-cluster configuration. If allConfigEntries is set, the returned Kubeconfig will contain all contexts from the kubeconfig file; otherwise it only contains the current context.

TODO(awly): unit test this

Jump to

Keyboard shortcuts

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