kube

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfigDir  = filepath.Join(homedir.HomeDir(), ".kube")
	DefaultConfigFile = filepath.Join(DefaultConfigDir, "config")
	DefaultNamespace  = "default"
)

Functions

func CheckOrInitConfig

func CheckOrInitConfig()

CheckOrInitConfig checks if the kubeconfig exists, if not, create it

func Client

func Client(kubeConfigFile, ctx string) (kubernetes.Interface, error)

Client creates a new kubernetes client from the given kubeconfig file and context.

func ClientOrDie

func ClientOrDie(kubeConfigFile, ctx string) kubernetes.Interface

ClientOrDie creates a new kubernetes client from the given kubeconfig file and context, and panics if it fails.

func CreateSecret

func CreateSecret(kubeClientset kubernetes.Interface, secret *v1.Secret, namespace string) *v1.Secret

CreateSecret creates a secret

func CreateServiceAccountTokenSecret

func CreateServiceAccountTokenSecret(kubeClientset kubernetes.Interface, serviceAccountName, namespace string) *v1.Secret

CreateServiceAccountTokenSecret creates a secret for a service account

func DiscoveryClient

func DiscoveryClient(kubeConfigFile, ctx string) (discovery.DiscoveryInterface, error)

DiscoveryClient creates a new kubernetes discovery client from the given kubeconfig file and context.

func GenerateConfigForServiceAccount

func GenerateConfigForServiceAccount(kubeconfig, context, namespace, serviceAccount string) *clientcmdapi.Config

GenerateConfigForServiceAccount generates kubeconfig for service account

func GetSecret

func GetSecret(kubeClientset kubernetes.Interface, secretName, namespace string) *v1.Secret

GetSecret returns a secret

func GetServiceAccount

func GetServiceAccount(kubeClientset kubernetes.Interface, serviceAccountName, namespace string) *v1.ServiceAccount

GetServiceAccount returns a service account

func ListContexts

func ListContexts(config *clientcmdapi.Config) []*types.ContextProfile

ListContexts lists all contexts in the kubeconfig

func ListNamespaces

func ListNamespaces(kubeClientset kubernetes.Interface) []string

ListNamespaces returns a list of namespaces

func ListServiceAccounts

func ListServiceAccounts(kubeClientset kubernetes.Interface, namespace string) []string

ListServiceAccounts returns a list of service accounts

func LoadConfigFromFile

func LoadConfigFromFile(file string) *clientcmdapi.Config

LoadConfigFromFile loads the kubeconfig from the file

func NewConfig

func NewConfig() *clientcmdapi.Config

NewConfig returns a new kubeconfig

func PrintConfig

func PrintConfig(config *clientcmdapi.Config)

PrintConfig prints the kubeconfig

func SaveConfigToFile

func SaveConfigToFile(config *clientcmdapi.Config, file string)

SaveConfigToFile saves the kubeconfig to the file

func ServerVersion

func ServerVersion(discoveryClient discovery.DiscoveryInterface) (string, error)

ServerVersion returns the Kubernetes server version.

func StandardizeConfig

func StandardizeConfig(config *clientcmdapi.Config)

StandardizeConfig standardizes the cluster and user names in the kubeconfig

Types

This section is empty.

Jump to

Keyboard shortcuts

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