k8s

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(data []byte, namespace string, args ...string) (err error)

Apply `kubectl apply` data to a given namespace. Specify output or any other flags as args. Uses a stdin pipe to include the content of the data slice

func CanI added in v1.0.9

func CanI(namespace string, verb string, objectType string, args ...string) (bool, error)

CanI is for authorization checks

func CanIAllNamespaces added in v1.0.9

func CanIAllNamespaces(verb string, objectType string, args ...string) (bool, error)

func Create

func Create(namespace string, resourceAndArgs ...string) (err error)

Create `kubectl create` a resource. Some resources take multiple args (like secrets), so both the resource type and any flags are the variadic

func CreateEnv

func CreateEnv(appName string) error

CreateEnv creates a Secret for a new TuberApp, to store env vars

func CreateEnvFromFile

func CreateEnvFromFile(name string, path string) (err error)

CreateEnvFromFile replaces an apps env with data in a local file

func CreateTuberCredentials

func CreateTuberCredentials(path string, namespace string) (err error)

CreateTuberCredentials creates a secret based on the contents of a file

func CurrentCluster

func CurrentCluster() (string, error)

CurrentCluster the current configured kubectl cluster

func Delete

func Delete(kind string, name string, namespace string, args ...string) (err error)

Delete `kubectl delete` a resource. Specify output or any other flags as args

func Exec

func Exec(name string, namespace string, args ...string) error

Exec interactive exec into a pod with a series of args to run

func Exists

func Exists(kind string, name string, namespace string, args ...string) (bool, error)

Exists tells you if a given resource already exists. Errors if a get call fails for any reason other than Not Found

func Get

func Get(kind string, name string, namespace string, args ...string) ([]byte, error)

Get `kubectl get` a resource. Specify output or any other flags as args

func GetCollection

func GetCollection(kind string, namespace string, args ...string) ([]byte, error)

GetCollection gets for plural resource types break if given even an empty name

func PatchConfigMap

func PatchConfigMap(mapName string, namespace string, key string, value string) (err error)

PatchConfigMap gets, patches, and saves a configmap

func PatchSecret

func PatchSecret(mapName string, namespace string, key string, value string) (err error)

PatchSecret gets, patches, and saves a secret

func PortForward

func PortForward(podName string, namespace string, ports []string, args ...string) error

PortForward forward local requests to a running pod

func RemoveConfigMapEntry

func RemoveConfigMapEntry(mapName string, namespace string, key string) (err error)

RemoveConfigMapEntry removes an entry, from a configmap

func RemoveSecretEntry

func RemoveSecretEntry(mapName string, namespace string, key string) (err error)

RemoveSecretEntry removes an entry, from a secret

func Restart

func Restart(resource string, namespace string, args ...string) (err error)

Restart runs a rollout restart on a given resource type for a namespace For example, `Restart("deployments", "some-app")` will restart _all_ deployments in that namespace

func RolloutStatus

func RolloutStatus(kind string, name string, namespace string, timeout time.Duration, args ...string) error

RolloutStatus waits and watches a rollout's progress

func RolloutUndo

func RolloutUndo(kind string, name string, namespace string, args ...string) error

RolloutUndo runs undo on a rollout

func UseCluster

func UseCluster(cluster string) error

UseCluster switch current configured kubectl cluster

Types

type AlreadyExistsError

type AlreadyExistsError struct {
	K8sError
}

AlreadyExistsError resource already exists on kubernetes

type ClusterConfig

type ClusterConfig struct {
	Name        string
	AccessToken string
}

ClusterConfig returns config for a cluster

func GetConfig

func GetConfig() (*ClusterConfig, error)

GetConfig returns `kubectl config view`

type ConfigResource

type ConfigResource struct {
	Data map[string]string
	// contains filtered or unexported fields
}

ConfigResource represents the editable portion of a configmap

func GetConfigResource

func GetConfigResource(name string, namespace string, kind string) (config *ConfigResource, err error)

GetConfigResource returns a ConfigResource struct with a Data element containing config map entries

func GetConfigResourceWithToken added in v1.0.9

func GetConfigResourceWithToken(name string, namespace string, kind string, token string) (config *ConfigResource, err error)

GetConfigResourceWithToken is a step toward a larger refactor

func GetSecret

func GetSecret(namespace string, secretName string) (*ConfigResource, error)

func (*ConfigResource) Save

func (c *ConfigResource) Save(namespace string) (err error)

Save persists updates to a configmap to k8s

type K8sError

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

K8sError generic kubectl error, which also provides the error interface for AlreadyExistsError and NotFoundError

func (K8sError) Error

func (e K8sError) Error() string

type List

type List struct {
	Items [][]byte
}

List represents a nested list of Items

func ListKind

func ListKind(kind string, namespace string, args ...string) (List, error)

ListKind returns a List resource, with an Items slice of raw yamls

type NotFoundError

type NotFoundError struct {
	K8sError
}

NotFoundError requested kubernetes resource not found

Jump to

Keyboard shortcuts

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