Documentation
¶
Index ¶
- Variables
- type Kubectl
- type KubectlRunner
- func (k *KubectlRunner) Annotate(namespace string, objType string, selector string, annotation string) error
- func (k *KubectlRunner) Create(namespace string, o *Object) error
- func (k *KubectlRunner) Delete(namespace string, o *Object) error
- func (k *KubectlRunner) Get(namespace string, objType string, selector string) ([]*Object, error)
- func (k *KubectlRunner) Label(namespace string, objType string, selector string, label string) error
- type Metadata
- type MetadataMD
- type Object
- func (o *Object) Bytes() ([]byte, error)
- func (o *Object) Metadata() (*Metadata, error)
- func (o *Object) SetAnnotations(annotations map[string]string) error
- func (o *Object) SetLabels(labels map[string]string) error
- func (o *Object) SetTemplateLabels(labels map[string]string) error
- func (o *Object) Status() (*PodStatus, error)
- func (o *Object) TemplateMetadata() (*Metadata, error)
- type PodPhase
- type PodStatus
Constants ¶
This section is empty.
Variables ¶
var ( // KubePath is the path to kubectl executable KubePath string // KubeConfig is the path to kubeconfig KubeConfig string )
Functions ¶
This section is empty.
Types ¶
type Kubectl ¶
type Kubectl interface {
// Get returns Objects with given selector
Get(namespace string, objType string, selector string) ([]*Object, error)
// Create creates a kubernetes objects
Create(namespace string, o *Object) error
// Delete deletes an object from kubernetes cluster
Delete(namespace string, o *Object) error
// Label label an kubernetes object
Label(namespace string, objType string, selector string, label string) error
// Annotate annotate an kubernetes object
Annotate(namespace string, objType string, selector string, annotation string) error
}
type KubectlRunner ¶
type KubectlRunner struct{}
KubectlRunner is a real implementation of Kubectl interface which uses kubectl executable
func NewKubectlRunner ¶
func NewKubectlRunner() (*KubectlRunner, error)
NewKubectlRunner returns a instance of KubectlRunner that uses kubectl external command to implement Kubectl interface
func (*KubectlRunner) Annotate ¶
func (k *KubectlRunner) Annotate(namespace string, objType string, selector string, annotation string) error
Annotate annotate an kubernetes object
func (*KubectlRunner) Create ¶
func (k *KubectlRunner) Create(namespace string, o *Object) error
Create implements Create of Kubectl interface
func (*KubectlRunner) Delete ¶
func (k *KubectlRunner) Delete(namespace string, o *Object) error
Delete implements Delete of Kubectl interface
type Metadata ¶
type Metadata struct {
Kind string `json:"kind,omitempty"`
APIVersion string `json:"apiVersion,omitempty"`
MetadataMD `json:"metadata,omitempty"`
}
Metadata of a object
type MetadataMD ¶
type MetadataMD struct {
Name string `json:"name,omitempty"`
GenerateName string `json:"generateName,omitempty"`
Namespace string `json:"namespace,omitempty"`
SelfLink string `json:"selfLink,omitempty"`
UID string `json:"uid,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty"`
Generation int64 `json:"generation,omitempty"`
CreationTimestamp time.Time `json:"creationTimestamp,omitempty"`
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
}
MetadataMD is inlined part of object Metadata which contains labels and annotations
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is a represention of a Kubernetes' object by using this it is possible to manipulate labels and annotations of the object
func (*Object) SetAnnotations ¶
SetAnnotations will replace annotations of the object
func (*Object) SetTemplateLabels ¶
SetTemplateLabels try to find template labels and replace it with labels return an error if there is no template
func (*Object) TemplateMetadata ¶
TemplateMetadata returns Metadata of objects that contain template like ReplicationControl
type PodPhase ¶
type PodPhase string
PodPhase is a label for the condition of a pod at the current time.
const ( // PodPending means the pod has been accepted by the system, but one or more of the containers // has not been started. This includes time before being bound to a node, as well as time spent // pulling images onto the host. PodPending PodPhase = "Pending" // PodRunning means the pod has been bound to a node and all of the containers have been started. // At least one container is still running or is in the process of being restarted. PodRunning PodPhase = "Running" // PodSucceeded means that all containers in the pod have voluntarily terminated // with a container exit code of 0, and the system is not going to restart any of these containers. PodSucceeded PodPhase = "Succeeded" // PodFailed means that all containers in the pod have terminated, and at least one container has // terminated in a failure (exited with a non-zero exit code or was stopped by the system). PodFailed PodPhase = "Failed" // PodUnknown means that for some reason the state of the pod could not be obtained, typically due // to an error in communicating with the host of the pod. PodUnknown PodPhase = "Unknown" )
These are the valid statuses of pods.
type PodStatus ¶
type PodStatus struct {
Phase PodPhase `json:"phase,omitempty"`
// A human readable message indicating details about why the pod is in this state.
Message string `json:"message,omitempty"`
// A brief CamelCase message indicating details about why the pod is in this state. e.g. 'OutOfDisk'
Reason string `json:"reason,omitempty"`
HostIP string `json:"hostIP,omitempty"`
PodIP string `json:"podIP,omitempty"`
// Date and time at which the object was acknowledged by the Kubelet.
// This is before the Kubelet pulled the container image(s) for the pod.
StartTime *time.Time `json:"startTime,omitempty"`
}
PodStatus represents information about the status of a pod. Status may trail the actual state of a system.