Documentation ¶
Index ¶
- Constants
- Variables
- func BuildRemoteCfg(remoteCluster *api.Cluster, remoteCtx *api.Context, clusterName, token string) api.Config
- func GetClientConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (clientcmd.ClientConfig, error)
- func GetRawConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (clientcmdapi.Config, error)
- func GetRestConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (*rest.Config, error)
- func SecretObjMeta(namespace string, cluster string, resourceLabels map[string]string) metav1.ObjectMeta
- func SecretToConfig(secret *kubev1.Secret) (clusterName string, config clientcmd.ClientConfig, err error)
- func ToSecret(namespace string, cluster string, resourceLabels map[string]string, ...) (*kubev1.Secret, error)
- type KubeLoader
Constants ¶
const ( // SecretType is used to indicate which kubernetes secrets contain a KubeConfig. SecretType = "solo.io/kubeconfig" // Key is the KubeConfig's key in the KubeConfig secret data. Key = "kubeconfig" )
Variables ¶
var ( FailedToConvertKubeConfigToSecret = func(err error) error { return eris.Wrap(err, "Could not serialize KubeConfig to yaml while generating secret.") } FailedToConvertSecretToKubeConfig = func(err error) error { return eris.Wrapf(err, "Could not deserialize string to KubeConfig while generating KubeConfig") } FailedToConvertSecretToClientConfig = func(err error) error { return eris.Wrap(err, "Could not convert config to ClientConfig") } SecretHasNoKubeConfig = func(meta metav1.ObjectMeta) error { return eris.Errorf("kube config secret %s.%s has no KubeConfig value for key %v", meta.Namespace, meta.Name, Key) } FailedToConvertSecretToRestConfig = func(err error) error { return eris.Wrap(err, "Could not convert config to *rest.Config") } )
var ( FailedToReadCAFile = func(err error, fileName string) error { return eris.Wrapf(err, "Failed to read kubeconfig CA file: %s", fileName) } )
var Predicate = predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { return isKubeConfigSecret(e.Object) }, DeleteFunc: func(e event.DeleteEvent) bool { return isKubeConfigSecret(e.Object) }, UpdateFunc: func(e event.UpdateEvent) bool { if isKubeConfigSecret(e.ObjectNew) { oldSecret, newSecret := e.ObjectOld.(*corev1.Secret), e.ObjectNew.(*corev1.Secret) return !reflect.DeepEqual(oldSecret.Data, newSecret.Data) } return false }, GenericFunc: func(e event.GenericEvent) bool { return isKubeConfigSecret(e.Object) }, }
Functions ¶
func BuildRemoteCfg ¶
func GetClientConfigWithContext ¶ added in v0.7.17
func GetClientConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (clientcmd.ClientConfig, error)
Fetch ClientConfig. If kubeConfigPath is not specified, retrieve the kubeconfig from environment in which this is invoked. Override the API Server URL and current context if specified. Copied and modified from https://github.com/kubernetes-sigs/controller-runtime/blob/cb7f85860a8cde7259b35bb84af1fdcb02c098f2/pkg/client/config/config.go#L135
func GetRawConfigWithContext ¶ added in v0.7.17
func GetRawConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (clientcmdapi.Config, error)
Fetch raw Config for environment in which this is invoked, override the API Server URL and current context if specified.
func GetRestConfigWithContext ¶ added in v0.7.17
func GetRestConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (*rest.Config, error)
Fetch rest.Config for environment in which this is invoked, override the API Server URL and current context if specified.
func SecretObjMeta ¶ added in v0.7.17
func SecretToConfig ¶
func SecretToConfig(secret *kubev1.Secret) (clusterName string, config clientcmd.ClientConfig, err error)
SecretToConfig extracts the cluster name and *Config from a KubeConfig secret. If the provided secret is not a KubeConfig secret, an error is returned.
Types ¶
type KubeLoader ¶
type KubeLoader interface { GetRestConfigForContext(path string, context string) (*rest.Config, error) GetRawConfigForContext(path, context string) (clientcmdapi.Config, error) GetClientConfigForContext(path, context string) (clientcmd.ClientConfig, error) GetRestConfigFromBytes(config []byte) (*rest.Config, error) }