kubectl

package
v2.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KindDeployment name of Deployment resource type
	KindDeployment = "deployment"

	// KindReplicaSet name of ReplicaSet resource type
	KindReplicaSet = "replicaset"

	// KindNamespace name of Namespace resource type
	KindNamespace = "namespace"

	// KindPod name of Pod resource type
	KindPod = "pod"

	// KindList name of List resource type
	KindList = "list"

	// PodStatusRunning string representation of running pod
	PodStatusRunning = "Running"

	// ClusterContextEnv is the name of environment variable to get kubectl requested context
	ClusterContextEnv = "CLUSTER_CONTEXT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Deployment

type Deployment struct {
	Kind     string           `yaml:"kind"`
	Metadata resourceMetadata `yaml:"metadata"`
	Spec     resourceSpec     `yaml:"spec"`
	Status   resourceStatus   `yaml:"status"`
}

Deployment is k8s Deployment resource

func (*Deployment) GetGeneration

func (d *Deployment) GetGeneration() int

GetGeneration will return current deployment generation

func (*Deployment) GetKey

func (d *Deployment) GetKey() string

GetKey will return unique name within a cluster

func (*Deployment) GetKind

func (d *Deployment) GetKind() string

GetKind interface method support, returns string "deployment"

func (*Deployment) GetName

func (d *Deployment) GetName() string

GetName return name of Deployment

func (*Deployment) GetNamespace

func (d *Deployment) GetNamespace() string

GetNamespace return deployment namespace

func (*Deployment) GetPodSelector

func (d *Deployment) GetPodSelector() []string

GetPodSelector return slice of selectors associated with Deployment Spec template

func (*Deployment) GetSelector

func (d *Deployment) GetSelector() []string

GetSelector return slice of selectors associated with Deployment

func (*Deployment) GetStatusString

func (d *Deployment) GetStatusString() string

GetStatusString return deployment status message

func (*Deployment) GetUUID

func (d *Deployment) GetUUID() string

GetUUID return UUID of deployment

func (*Deployment) IsReady

func (d *Deployment) IsReady() bool

IsReady check deploy has been rolled out @see https://kubernetes.io/docs/user-guide/deployments/#the-status-of-a-deployment

func (*Deployment) ToDeployment

func (d *Deployment) ToDeployment() (*Deployment, error)

ToDeployment interface method

type KubeCall

type KubeCall struct {
	Cmd    kubeCommandInterface
	Parser kubeResourceParserInterface
}

KubeCall is kubectl wrapper combined with parser

func CommandApply

func CommandApply(configurationYaml string) *KubeCall

CommandApply apply new yaml configuration to cluster

func CommandDeploymentInfo

func CommandDeploymentInfo(namespace string, name string) *KubeCall

CommandDeploymentInfo get information about single deployment

func CommandDeploymentList

func CommandDeploymentList(namespace string) *KubeCall

CommandDeploymentList return call which return list of deployments registered in kubernetes clusted

func CommandDeploymentListBySelector

func CommandDeploymentListBySelector(namespace string, selector []string) *KubeCall

CommandDeploymentListBySelector fetch deployments by provided selector

func CommandExec

func CommandExec(namespace, pod, container, command string) *KubeCall

CommandExec execute command in container of pod

func CommandNamespaceList

func CommandNamespaceList() *KubeCall

CommandNamespaceList return call which will return list of namespaces registered in kubernetes cluster

func CommandPodListBySelector

func CommandPodListBySelector(namespace string, selector []string) *KubeCall

CommandPodListBySelector return list of pods in namespace with selector

func CommandPodLogs

func CommandPodLogs(namespace, name string, container string) *KubeCall

CommandPodLogs return logs for pod

func CommandReplicaSetList

func CommandReplicaSetList(namespace string) *KubeCall

CommandReplicaSetList return call which return list of replicasets registered in kubernetes cluster

func CommandReplicaSetListBySelector

func CommandReplicaSetListBySelector(namespace string, selector []string) *KubeCall

CommandReplicaSetListBySelector get replica set list by selector

func CommandRollback

func CommandRollback(namespace, kind, name string) *KubeCall

CommandRollback allow to rollback any resource to previous version

func (*KubeCall) RunAndParse

func (c *KubeCall) RunAndParse() (ResourceList, error)

RunAndParse run command and try to parse output with provided parser

func (*KubeCall) RunAndParseFirst

func (c *KubeCall) RunAndParseFirst() (KubeResourceInterface, error)

RunAndParseFirst run command, parse output and return first element of decoded items

func (*KubeCall) RunPlain

func (c *KubeCall) RunPlain() ([]byte, error)

RunPlain run command and just return command output

type KubeResourceInterface

type KubeResourceInterface interface {
	GetKind() string
	GetName() string
	ToDeployment() (*Deployment, error)
}

KubeResourceInterface is common interface to all k8s resource types

type Namespace

type Namespace struct {
	Kind     string           `yaml:"kind"`
	Metadata resourceMetadata `yaml:"metadata"`
}

Namespace is k8s Namespace resource

func (*Namespace) GetKind

func (n *Namespace) GetKind() string

GetKind interface method support, returns string "namespace"

func (*Namespace) GetName

func (n *Namespace) GetName() string

GetName return name of Namespace

func (*Namespace) ToDeployment

func (n *Namespace) ToDeployment() (*Deployment, error)

ToDeployment interface method

type Pod

type Pod struct {
	Kind     string                `yaml:"kind"`
	Metadata resourceMetadata      `yaml:"metadata"`
	Spec     resourceContainerSpec `yaml:"spec"`
	Status   resourceStatus        `yaml:"status"`
}

Pod is k8s Pod resource

func (*Pod) GetKey

func (p *Pod) GetKey() string

GetKey will return unique name within a cluster

func (*Pod) GetKind

func (p *Pod) GetKind() string

GetKind is an interface method

func (*Pod) GetName

func (p *Pod) GetName() string

GetName is an interface method

func (*Pod) GetNamespace

func (p *Pod) GetNamespace() string

GetNamespace return namespace name for pod

func (*Pod) ToDeployment

func (p *Pod) ToDeployment() (*Deployment, error)

ToDeployment interface method

type ReplicaSet

type ReplicaSet struct {
	Kind     string           `yaml:"kind"`
	Metadata resourceMetadata `yaml:"metadata"`
	Spec     resourceSpec     `yaml:"spec"`
	Status   resourceStatus   `yaml:"status"`
}

ReplicaSet is k8s ReplicaSet resource

func (*ReplicaSet) GetImages

func (r *ReplicaSet) GetImages() []string

GetImages return list of docker images registered in ReplicaSet

func (*ReplicaSet) GetKind

func (r *ReplicaSet) GetKind() string

GetKind interface method support, returns string "replicaset"

func (*ReplicaSet) GetName

func (r *ReplicaSet) GetName() string

GetName return name of ReplicaSet

func (*ReplicaSet) ToDeployment

func (r *ReplicaSet) ToDeployment() (*Deployment, error)

ToDeployment interface method

type ResourceList

type ResourceList []KubeResourceInterface

ResourceList is an alias for []KubeResourceInterface

func ParseLocalFile

func ParseLocalFile(filename string) (ResourceList, error)

ParseLocalFile will allow to parse local file and fetch all resources defined there

func (ResourceList) FilteredByKind

func (rl ResourceList) FilteredByKind(kind string) ResourceList

FilteredByKind return filtered slice of resources by kind

func (ResourceList) ToDeploymentList

func (rl ResourceList) ToDeploymentList() []Deployment

ToDeploymentList is helper to convert []KubeResourceInterface to []Deployment

func (ResourceList) ToNamespaceList

func (rl ResourceList) ToNamespaceList() []Namespace

ToNamespaceList is helper to convert []KubeResourceInterface type to []Namespace

func (ResourceList) ToPodList

func (rl ResourceList) ToPodList() []Pod

ToPodList is helper to convert []KubeResourceInterface type to []Pod

func (ResourceList) ToReplicaSetList

func (rl ResourceList) ToReplicaSetList() []ReplicaSet

ToReplicaSetList is helper to convert []KubeResourceInterface to []ReplicaSet

Jump to

Keyboard shortcuts

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