kubecfg

package
v1.1.50 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kubeconfig

type Kubeconfig interface {
	// ConfigFile path to the .kubecfg file where context entries are generated
	ConfigFile() string
	// ForRelease returns the name of the kubectx to use for executing commands against this release
	ForRelease(terra.Release) (Kubectx, error)
	// ForReleases returns a kubectx for each given release
	ForReleases(releases ...terra.Release) ([]ReleaseKtx, error)
	// ForEnvironment returns all kubectxs for all releases in an environment
	ForEnvironment(env terra.Environment) ([]Kubectx, error)
	// ForCluster returns the name of the kubectx to use for executing commands against the cluster (without any awareness of environment/releases)
	ForCluster(cluster terra.Cluster) (Kubectx, error)
}

Kubeconfig manages entries in a `kubectl` config file (traditionally ~/.kube/config) for Terra environments & releases. It creates context entries for environments and releases. It works like `gcloud container clusters get-credentials`, except:

  • Users don't have to specify a project or location (because thelma already knows where clusters live)
  • Context entries are named in a more user-friendly fashion. For example, the context for the "alpha" environment is called `alpha`, instead of `gke_broad-dsde-alpha_us-central1-a_terra-alpha`. This makes it possible to quickly run a kubectl command against the alpha environment using `kubectl -c alpha` (no need to specify a namespace).

Read more about kubectl contexts here: https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#define-clusters-users-and-contexts

Q: Why not just shell out to gcloud? Because `gcloud` is a big ol' Python app. Thelma is designed to run on developer laptops and depending on users having the correct version of gcloud and Python installed is more brittle than just generating GKE credentials ourselves.

func New

func New(file string, gkeClient *container.ClusterManagerClient, tokenSource oauth2.TokenSource) Kubeconfig

New constructs a Kubeconfig

type Kubectx

type Kubectx interface {
	// ContextName name of the run context in the kubecfg file
	ContextName() string
	// Namespace kubectl command should run against
	Namespace() string
}

Kubectx represents a run context for a kubectl command

type ReleaseKtx

type ReleaseKtx struct {
	Release terra.Release
	Kubectx Kubectx
}

ReleaseKtx is a convenience type that bundles a terra.Release with its associated Kubectx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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