kubeconfig

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyNamespacedSecret

func ApplyNamespacedSecret(
	ctx context.Context,
	namespaceClient v1.NamespaceInterface,
	secretClinet v1.SecretInterface,
	config []byte,
) error

Generate a secret resource for the kubeconfig file.

func ExtractKubeconfig

func ExtractKubeconfig(path string, targetContext string) ([]byte, error)

Extract the kubeconfig file for the specified context.

func GenerateConfigFile

func GenerateConfigFile(path string, cluster string) error

Generate a toml file that stores the path and cluster name of the kubeconfig file.

func GeneratePrimaryConfig

func GeneratePrimaryConfig(clientset *kubernetes.Clientset, restConfig *rest.Config) ([]byte, error)

Generate a kubeconfig file for the primary cluster.

func MargeKubeconfig

func MargeKubeconfig(source clientcmdapi.Config, target clientcmdapi.Config) ([]byte, error)

Merge the kubeconfig.

func ReadKubeconfigFromByte

func ReadKubeconfigFromByte(config []byte) (*clientcmdapi.Config, error)

Read the kubeconfig file.

func ReadKubeconfigFromClient

func ReadKubeconfigFromClient(cli client.Client) (*clientcmdapi.Config, error)

Read the kubeconfig file registered for the Secret Resource and register the necessary information for apiServers and clusters, respectively. At this time, a slice element is created for each Kubernetes cluster. kubeconfig must be created in advance as a secret resource.

func ReadKubeconfigFromFile

func ReadKubeconfigFromFile(path string) (*clientcmdapi.Config, error)

Read the kubeconfig file.

func RemoveContext

func RemoveContext(config *corev1.Secret, removeTarget string) ([]byte, error)

func ViewContext

func ViewContext(config *corev1.Secret) ([][]string, error)

Types

type Config

type Config struct {
	Path    string
	Cluster string
}

func GetPathAndCluster

func GetPathAndCluster() (Config, error)

Get the path and cluster name from the toml file.

Jump to

Keyboard shortcuts

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