kubeconfig

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(cfg *Config) ([]byte, error)

Encode encodes the cfg to yaml

func KINDClusterKey

func KINDClusterKey(clusterName string) string

KINDClusterKey identifies kind clusters in kubeconfig files

func RemoveKIND

func RemoveKIND(kindClusterName string, explicitPath string) error

RemoveKIND removes the kind cluster kindClusterName from the KUBECONFIG files at configPaths

func WriteMerged

func WriteMerged(kindConfig *Config, explicitConfigPath string) error

WriteMerged writes a kind kubeconfig (see KINDFromRawKubeadm) into configPath merging with the existing contents if any and setting the current context to the kind config's current context.

Types

type Cluster

type Cluster struct {
	// Server is the address of the kubernetes cluster (https://hostname:port).
	Server string `yaml:"server,omitempty"`
	// OtherFields contains fields kind does not inspect or modify, these are
	// read purely for writing back
	OtherFields map[string]interface{} `yaml:",inline,omitempty"`
}

Cluster contains information about how to communicate with a kubernetes cluster

type Config

type Config struct {
	// Clusters is a map of referenceable names to cluster configs
	Clusters []NamedCluster `yaml:"clusters,omitempty"`
	// Users is a map of referenceable names to user configs
	Users []NamedUser `yaml:"users,omitempty"`
	// Contexts is a map of referenceable names to context configs
	Contexts []NamedContext `yaml:"contexts,omitempty"`
	// CurrentContext is the name of the context that you would like to use by default
	CurrentContext string `yaml:"current-context,omitempty"`
	// OtherFields contains fields kind does not inspect or modify, these are
	// read purely for writing back
	OtherFields map[string]interface{} `yaml:",inline,omitempty"`
}

Config represents a KUBECONFIG, with the fields kind is likely to use Other fields are handled as unstructured data purely read for writing back to disk via the OtherFields field

func KINDFromRawKubeadm

func KINDFromRawKubeadm(rawKubeadmKubeConfig, clusterName, server string) (*Config, error)

KINDFromRawKubeadm returns a kind kubeconfig derived from the raw kubeadm kubeconfig, the kind clusterName, and the server. server is ignored if unset.

type Context

type Context struct {
	// Cluster is the name of the cluster for this context
	Cluster string `yaml:"cluster"`
	// User is the name of the User for this context
	User string `yaml:"user"`
	// OtherFields contains fields kind does not inspect or modify, these are
	// read purely for writing back
	OtherFields map[string]interface{} `yaml:",inline,omitempty"`
}

Context is a tuple of references to a cluster (how do I communicate with a kubernetes cluster), a user (how do I identify myself), and a namespace (what subset of resources do I want to work with)

type NamedCluster

type NamedCluster struct {
	// Name is the nickname for this Cluster
	Name string `yaml:"name"`
	// Cluster holds the cluster information
	Cluster Cluster `yaml:"cluster"`
}

NamedCluster relates nicknames to cluster information

type NamedContext

type NamedContext struct {
	// Name is the nickname for this Context
	Name string `yaml:"name"`
	// Context holds the context information
	Context Context `yaml:"context"`
}

NamedContext relates nicknames to context information

type NamedUser

type NamedUser struct {
	// Name is the nickname for this User
	Name string `yaml:"name"`
	// User holds the user information
	// We do not touch this and merely write it back
	User map[string]interface{} `yaml:"user"`
}

NamedUser relates nicknames to user information

Jump to

Keyboard shortcuts

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