kubernetes

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: BSD-3-Clause Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetClient = func(cluster provTypes.Cluster) (kubernetes.Interface, error) {
	config, err := RestConfig(cluster)
	if err != nil {
		return nil, err
	}
	return kubernetes.NewForConfig(config)
}

GetClient func may be overridden in tests

View Source
var GetClientWithRestConfig = func(config *rest.Config) (kubernetes.Interface, error) {
	return kubernetes.NewForConfig(config)
}
View Source
var GetClientset = func(cluster provTypes.Cluster) (apiextensionsclientset.Interface, error) {
	config, err := RestConfig(cluster)
	if err != nil {
		return nil, err
	}
	return apiextensionsclientset.NewForConfig(config)
}

GetClientset func may be overridden in tests

View Source
var GetTsuruClient = func(cluster provTypes.Cluster) (tsuruv1clientset.Interface, error) {
	config, err := RestConfig(cluster)
	if err != nil {
		return nil, err
	}
	return tsuruv1clientset.NewForConfig(config)
}

GetTsuruClient func may be overridden in tests

View Source
var GetTsuruClientWithRestConfig = func(config *rest.Config) (tsuruv1clientset.Interface, error) {
	return tsuruv1clientset.NewForConfig(config)
}
View Source
var RestConfig = func(cluster provTypes.Cluster) (*rest.Config, error) {
	gv, err := schema.ParseGroupVersion("/v1")
	if err != nil {
		return nil, err
	}

	if cluster.KubeConfig != nil {
		return getRestConfigByKubeConfig(cluster)
	}

	cfg := &rest.Config{
		APIPath: "/api",
		ContentConfig: rest.ContentConfig{
			GroupVersion:         &gv,
			NegotiatedSerializer: serializer.WithoutConversionCodecFactory{CodecFactory: scheme.Codecs},
		},
		Timeout: viper.GetDuration("http.timeout"),
	}
	if len(cluster.Addresses) == 0 {
		return nil, errors.New("no addresses for cluster")
	}
	addr := cluster.Addresses[rand.Intn(len(cluster.Addresses))]
	var token, user, password string
	if cluster.CustomData != nil {
		token = cluster.CustomData[tokenClusterKey]
		user = cluster.CustomData[userClusterKey]
		password = cluster.CustomData[passwordClusterKey]
	}
	cfg.Host = addr
	cfg.TLSClientConfig = rest.TLSClientConfig{
		CAData:   cluster.CaCert,
		CertData: cluster.ClientCert,
		KeyData:  cluster.ClientKey,
	}
	if user != "" && password != "" {
		cfg.Username = user
		cfg.Password = password
	} else {
		cfg.BearerToken = token
	}
	cfg.Wrap(external.MetricsRoundTripper)
	return cfg, nil
}

Functions

func DefaultNamespace

func DefaultNamespace() string

Types

This section is empty.

Jump to

Keyboard shortcuts

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