k8s

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0, Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DistroIsUnknown       = "unknown"
	DistroIsK3s           = "k3s"
	DistroIsK3d           = "k3d"
	DistroIsKind          = "kind"
	DistroIsMicroK8s      = "microk8s"
	DistroIsEKSAnywhere   = "eksanywhere"
	DistroIsDockerDesktop = "dockerdesktop"
)
View Source
const (
	ZarfNamespace       = "zarf"
	ZarfStateSecretName = "zarf-state"
	ZarfStateDataKey    = "state"
)
View Source
const (
	PodResource  = "pod"
	SvcResource  = "svc"
	ZarfRegistry = "REGISTRY"
	ZarfLogging  = "LOGGING"
	ZarfGit      = "GIT"
)
View Source
const (
	PortRegistry = iota + 45001
	PortLogging
	PortGit
)

Variables

This section is empty.

Functions

func CreateNamespace added in v0.15.0

func CreateNamespace(name string, namespace *corev1.Namespace) (*corev1.Namespace, error)

func CreateSecret added in v0.15.0

func CreateSecret(secret *corev1.Secret) error

func DeleteSecret added in v0.15.0

func DeleteSecret(secret *corev1.Secret) error

func DeleteZarfNamespace added in v0.15.0

func DeleteZarfNamespace()

func DetectDistro added in v0.15.0

func DetectDistro() (string, error)

func GenerateRegistryPullCreds added in v0.15.0

func GenerateRegistryPullCreds(namespace string, name string) *corev1.Secret

func GenerateTLSSecret added in v0.15.0

func GenerateTLSSecret(namespace string, name string, certPath string, keyPath string) *corev1.Secret

func GetAllServiceAccounts added in v0.15.0

func GetAllServiceAccounts() (*corev1.ServiceAccountList, error)

func GetAvailablePort added in v0.15.0

func GetAvailablePort() (int, error)

GetAvailablePort retrieves an available port on the host machine. This delegates the port selection to the golang net library by starting a server and then checking the port that the server is using.

func GetContext added in v0.15.0

func GetContext() (string, error)

func GetNamespaces added in v0.15.0

func GetNamespaces() (*corev1.NamespaceList, error)

func GetNodes added in v0.15.0

func GetNodes() (*corev1.NodeList, error)

func GetSecret added in v0.15.0

func GetSecret(namespace string, name string) (*corev1.Secret, error)

func GetService added in v0.15.0

func GetService(namespace string, serviceName string) (*corev1.Service, error)

GetService returns a Kubernetes service resource in the provided namespace with the given name.

func GetServiceAccount added in v0.15.0

func GetServiceAccount(namespace string, name string) (*corev1.ServiceAccount, error)

func GetServiceAccounts added in v0.15.0

func GetServiceAccounts(namespace string) (*corev1.ServiceAccountList, error)

func GetServicesByLabel added in v0.15.0

func GetServicesByLabel(namespace string, label string, value string) (*corev1.ServiceList, error)

GetServicesByLabel returns a list of matched services given a label and value. To search all namespaces, pass "" in the namespace arg

func GetServicesByLabelExists added in v0.15.0

func GetServicesByLabelExists(namespace string, label string) (*corev1.ServiceList, error)

GetServicesByLabelExists returns a list of matched services given a label. To search all namespaces, pass "" in the namespace arg

func LoadZarfState added in v0.15.0

func LoadZarfState() types.ZarfState

LoadZarfState returns the current zarf/zarf-state secret data or an empty ZarfState

func ProcessYamlFilesInPath added in v0.15.0

func ProcessYamlFilesInPath(path string, componentImages []string) []string

ProcessYamlFilesInPath iterates over all yaml files in a given path and performs Zarf templating + image swapping

func ReplaceSecret added in v0.15.0

func ReplaceSecret(secret *corev1.Secret) error

func ReplaceTLSSecret

func ReplaceTLSSecret(namespace string, name string)

func SaveServiceAccount added in v0.15.0

func SaveServiceAccount(svcAccount *corev1.ServiceAccount) (*corev1.ServiceAccount, error)

func SaveZarfState added in v0.15.0

func SaveZarfState(state types.ZarfState) error

SaveZarfState takes a given state and makepersists it to the zarf/zarf-state secret

func SplitYAML added in v0.15.0

func SplitYAML(yamlData []byte) ([]*unstructured.Unstructured, error)

SplitYAML splits a YAML file into unstructured objects. Returns list of all unstructured objects found in the yaml. If an error occurs, returns objects that have been parsed so far too. Source: https://github.com/argoproj/gitops-engine/blob/v0.5.2/pkg/utils/kube/kube.go#L286

func WaitForPodsAndContainers

func WaitForPodsAndContainers(target types.ZarfContainerTarget, waitForAllPods bool) []string

WaitForPodsAndContainers holds execution up to 30 seconds waiting for health pods and containers (if specified)

Types

type DockerConfig added in v0.15.0

type DockerConfig struct {
	Auths DockerConfigEntry `json:"auths"`
}

type DockerConfigEntry added in v0.15.0

type DockerConfigEntry map[string]DockerConfigEntryWithAuth

type DockerConfigEntryWithAuth added in v0.15.0

type DockerConfigEntryWithAuth struct {
	Auth string `json:"auth"`
}

type ImageSwap added in v0.15.0

type ImageSwap struct {
	// contains filtered or unexported fields
}

ImageSwap Pre-compute all the replacements for the embedded registry

type Tunnel added in v0.15.0

type Tunnel struct {
	// contains filtered or unexported fields
}

Tunnel is the main struct that configures and manages port forwading tunnels to Kubernetes resources.

func NewTunnel added in v0.15.0

func NewTunnel(namespace string, resourceType string, resourceName string, local int, remote int) *Tunnel

NewTunnel will create a new Tunnel struct Note that if you use 0 for the local port, an open port on the host system will be selected automatically, and the Tunnel struct will be updated with the selected port.

func NewZarfTunnel added in v0.15.0

func NewZarfTunnel() *Tunnel

func (*Tunnel) Close added in v0.15.0

func (tunnel *Tunnel) Close()

Close disconnects a tunnel connection by closing the StopChan, thereby stopping the goroutine.

func (*Tunnel) Connect added in v0.15.0

func (tunnel *Tunnel) Connect(target string, blocking bool)

func (*Tunnel) Endpoint added in v0.15.0

func (tunnel *Tunnel) Endpoint() string

Endpoint returns the tunnel endpoint

func (*Tunnel) Establish added in v0.15.0

func (tunnel *Tunnel) Establish() (string, error)

Establish opens a tunnel to a kubernetes resource, as specified by the provided tunnel struct.

Jump to

Keyboard shortcuts

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