k8s

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKubeConfig

func CreateKubeConfig(clusterName string, ca certs.CertificateAuthority, endpoint string, group string, user string, expiry time.Duration) ([]byte, error)

func CreateOIDCKubeConfig

func CreateOIDCKubeConfig(clusterName string, ca certs.CertificateAuthority, endpoint, idpURL, idToken, accessToken, refreshToken string) ([]byte, error)

func GetNodeStatus

func GetNodeStatus(node v1.Node) string

func GetUnstructuredObjects

func GetUnstructuredObjects(data []byte) ([]unstructured.Unstructured, error)

func GetValidName

func GetValidName(name string) string

func IsDeleted

func IsDeleted(object metav1.Object) bool

func IsMasterNode

func IsMasterNode(node v1.Node) bool

func IsPodCrashLoopBackoff

func IsPodCrashLoopBackoff(pod v1.Pod) bool

func IsPodDaemonSet

func IsPodDaemonSet(pod v1.Pod) bool

func IsPodFinished

func IsPodFinished(pod v1.Pod) bool

func IsPodHealthy

func IsPodHealthy(pod v1.Pod) bool

func IsPodPending

func IsPodPending(pod v1.Pod) bool

func LowResourceRequirements

func LowResourceRequirements() v1.ResourceRequirements

func NewCommandJob

func NewCommandJob(node, command string) v1.PodSpec

func NewDeployment

func NewDeployment(ns, name, image string, labels map[string]string, port int32, args ...string) *apps.Deployment

func NewObjectMeta

func NewObjectMeta(ns, name string) metav1.ObjectMeta

func TestNamespace

func TestNamespace(client kubernetes.Interface, ns string, t *console.TestResults)

func WaitForNamespace

func WaitForNamespace(client kubernetes.Interface, ns string, timeout time.Duration)

Types

type Builder

type Builder struct {
	Objects     []runtime.Object
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
}

func (*Builder) AddAnnotations

func (b *Builder) AddAnnotations(annotations map[string]string) *Builder

func (*Builder) AddLabels

func (b *Builder) AddLabels(labels map[string]string) *Builder

func (*Builder) Append

func (b *Builder) Append(objects ...runtime.Object) *Builder

func (*Builder) ConfigMap

func (b *Builder) ConfigMap(name string, data map[string]string) *Builder

func (*Builder) Deployment

func (b *Builder) Deployment(name, image string) *DeploymentBuilder

func (*Builder) ObjectMeta

func (b *Builder) ObjectMeta(name string) metav1.ObjectMeta

func (*Builder) Secret

func (b *Builder) Secret(name string, data map[string][]byte) *Builder

func (*Builder) ServiceAccount

func (b *Builder) ServiceAccount(name string) *ServiceAccountBuilder

func (*Builder) SetNamespace

func (b *Builder) SetNamespace(namespace string) *Builder

type CRD

type CRD struct {
	Kind       string                 `yaml:"kind,omitempty"`
	APIVersion string                 `yaml:"apiVersion,omitempty"`
	Metadata   Metadata               `yaml:"metadata,omitempty"`
	Spec       map[string]interface{} `yaml:"spec,omitempty"`
}

type Client

type Client struct {
	logger.Logger
	GetKubeConfigBytes  func() ([]byte, error)
	ApplyDryRun         bool
	Trace               bool
	GetKustomizePatches func() ([]string, error)
	// contains filtered or unexported fields
}

func (*Client) Annotate

func (c *Client) Annotate(obj runtime.Object, annotations map[string]string) error

func (*Client) Apply

func (c *Client) Apply(namespace string, objects ...runtime.Object) error

func (*Client) ApplyUnstructured

func (c *Client) ApplyUnstructured(namespace string, objects ...*unstructured.Unstructured) error

func (*Client) Cordon

func (c *Client) Cordon(nodeName string) error

func (*Client) CreateOrUpdateConfigMap

func (c *Client) CreateOrUpdateConfigMap(name, ns string, data map[string]string) error

func (*Client) CreateOrUpdateNamespace

func (c *Client) CreateOrUpdateNamespace(name string, labels map[string]string, annotations map[string]string) error

func (*Client) CreateOrUpdateSecret

func (c *Client) CreateOrUpdateSecret(name, ns string, data map[string][]byte) error

func (*Client) Drain

func (c *Client) Drain(nodeName string, timeout time.Duration) error

func (*Client) EvictNode

func (c *Client) EvictNode(nodeName string) error

func (*Client) EvictPod

func (c *Client) EvictPod(pod v1.Pod) error

func (*Client) ExecutePodf

func (c *Client) ExecutePodf(namespace, pod, container string, command ...string) (string, string, error)

ExecutePodf runs the specified shell command inside a container of the specified pod

func (*Client) Executef

func (c *Client) Executef(node string, timeout time.Duration, command string, args ...interface{}) (string, error)

Executef runs the specified shell command on a node by creating a pre-scheduled pod that runs in the host namespace

func (*Client) ExposeIngress

func (c *Client) ExposeIngress(namespace, service string, domain string, port int, annotations map[string]string) error

func (*Client) Get

func (c *Client) Get(namespace string, name string, obj runtime.Object) error

func (*Client) GetClientset

func (c *Client) GetClientset() (*kubernetes.Clientset, error)

GetClientset creates a new k8s client

func (*Client) GetConditionsForNode

func (c *Client) GetConditionsForNode(name string) (map[v1.NodeConditionType]v1.ConditionStatus, error)

func (*Client) GetConfigMap

func (c *Client) GetConfigMap(namespace, name string) *map[string]string

GetConfigMap returns the data of a secret or nil for any error

func (*Client) GetDynamicClient

func (c *Client) GetDynamicClient() (dynamic.Interface, error)

GetDynamicClient creates a new k8s client

func (*Client) GetEtcdClientGenerator

func (c *Client) GetEtcdClientGenerator(ca *certs.Certificate) (*etcd.EtcdClientGenerator, error)

func (*Client) GetFirstPodByLabelSelector

func (c *Client) GetFirstPodByLabelSelector(namespace string, labelSelector string) (*v1.Pod, error)

Returns the first pod found by label

func (*Client) GetHealth

func (c *Client) GetHealth() Health

func (*Client) GetKustomize

func (c *Client) GetKustomize() (*kustomize.Manager, error)

func (*Client) GetMasterNode

func (c *Client) GetMasterNode() (string, error)

GetMasterNode returns the name of the first node found labelled as a master

func (*Client) GetOrCreatePVC

func (c *Client) GetOrCreatePVC(namespace, name, size, class string) error

func (*Client) GetOrCreateSecret

func (c *Client) GetOrCreateSecret(name, ns string, data map[string][]byte) error

func (*Client) GetPodReplicas

func (c *Client) GetPodReplicas(pod v1.Pod) (int, error)

func (*Client) GetProxyDialer

func (c *Client) GetProxyDialer(p proxy.Proxy) (*proxy.Dialer, error)

func (*Client) GetRESTConfig

func (c *Client) GetRESTConfig() (*rest.Config, error)

func (*Client) GetRestClient

func (c *Client) GetRestClient(obj unstructured.Unstructured) (*cliresource.Helper, error)

func (*Client) GetRestMapper

func (c *Client) GetRestMapper() (meta.RESTMapper, error)

func (*Client) GetSecret

func (c *Client) GetSecret(namespace, name string) *map[string][]byte

GetSecret returns the data of a secret or nil for any error

func (*Client) HasConfigMap

func (c *Client) HasConfigMap(ns, name string) bool

func (*Client) HasSecret

func (c *Client) HasSecret(ns, name string) bool

func (*Client) Label

func (c *Client) Label(obj runtime.Object, labels map[string]string) error

func (*Client) PingMaster

func (c *Client) PingMaster() bool

PingMaster attempts to connect to the API server and list nodes and services to ensure the API server is ready to accept any traffic

func (*Client) ResetConnection

func (c *Client) ResetConnection()

func (*Client) ScalePod

func (c *Client) ScalePod(pod v1.Pod, replicas int32) error

func (*Client) StreamLogs

func (c *Client) StreamLogs(namespace, name string) error

func (*Client) Uncordon

func (c *Client) Uncordon(nodeName string) error

func (*Client) WaitForNode

func (c *Client) WaitForNode(name string, timeout time.Duration, condition v1.NodeConditionType, statii ...v1.ConditionStatus) (map[v1.NodeConditionType]v1.ConditionStatus, error)

WaitForNode waits for a pod to be in the specified phase, or returns an error if the timeout is exceeded

func (*Client) WaitForPod

func (c *Client) WaitForPod(ns, name string, timeout time.Duration, phases ...v1.PodPhase) error

WaitForPod waits for a pod to be in the specified phase, or returns an error if the timeout is exceeded

func (*Client) WaitForPodCommand

func (c *Client) WaitForPodCommand(ns, name string, container string, timeout time.Duration, command ...string) error

WaitForPodCommand waits for a command executed in pod to succeed with an exit code of 9 error if the timeout is exceeded

type DeploymentBuilder

type DeploymentBuilder struct {
	Builder     *Builder
	Name, Image string
	// contains filtered or unexported fields
}

func Deployment

func Deployment(name, image string) *DeploymentBuilder

func (*DeploymentBuilder) Annotations

func (d *DeploymentBuilder) Annotations(annotations map[string]string) *DeploymentBuilder

func (*DeploymentBuilder) Args

func (d *DeploymentBuilder) Args(args ...string) *DeploymentBuilder

func (*DeploymentBuilder) AsCronJob

func (d *DeploymentBuilder) AsCronJob(schedule string) *batchv1beta1.CronJob

func (*DeploymentBuilder) AsOneShotJob

func (d *DeploymentBuilder) AsOneShotJob() *v1.Pod

func (*DeploymentBuilder) Build

func (d *DeploymentBuilder) Build() *Builder

func (*DeploymentBuilder) Command

func (d *DeploymentBuilder) Command(cmd ...string) *DeploymentBuilder

func (*DeploymentBuilder) EnvVarFromConfigMap

func (d *DeploymentBuilder) EnvVarFromConfigMap(env, configmap, key string) *DeploymentBuilder

func (*DeploymentBuilder) EnvVarFromField

func (d *DeploymentBuilder) EnvVarFromField(env, field string) *DeploymentBuilder

func (*DeploymentBuilder) EnvVarFromSecret

func (d *DeploymentBuilder) EnvVarFromSecret(env, secret, key string) *DeploymentBuilder

func (*DeploymentBuilder) EnvVars

func (d *DeploymentBuilder) EnvVars(env map[string]string) *DeploymentBuilder

func (*DeploymentBuilder) Expose

func (d *DeploymentBuilder) Expose(ports ...int32) *DeploymentBuilder

func (*DeploymentBuilder) GetLabels

func (d *DeploymentBuilder) GetLabels() map[string]string

func (*DeploymentBuilder) Labels

func (d *DeploymentBuilder) Labels(labels map[string]string) *DeploymentBuilder

func (*DeploymentBuilder) MountConfigMap

func (d *DeploymentBuilder) MountConfigMap(cm, path string) *DeploymentBuilder

func (*DeploymentBuilder) MountSecret

func (d *DeploymentBuilder) MountSecret(secret, path string, mode int32) *DeploymentBuilder

func (*DeploymentBuilder) NodeAffinity

func (d *DeploymentBuilder) NodeAffinity(nodeReadinessLabel map[string]string) *DeploymentBuilder

func (*DeploymentBuilder) ObjectMeta

func (d *DeploymentBuilder) ObjectMeta() metav1.ObjectMeta

func (*DeploymentBuilder) PodAffinity

func (d *DeploymentBuilder) PodAffinity(labels map[string]string, topologyKey string) *DeploymentBuilder

func (*DeploymentBuilder) PodSpec

func (d *DeploymentBuilder) PodSpec() v1.PodSpec

func (*DeploymentBuilder) PodTemplate

func (d *DeploymentBuilder) PodTemplate() v1.PodTemplateSpec

func (*DeploymentBuilder) Ports

func (d *DeploymentBuilder) Ports(ports ...int32) *DeploymentBuilder

func (*DeploymentBuilder) Replicas

func (d *DeploymentBuilder) Replicas(replicas int) *DeploymentBuilder

func (*DeploymentBuilder) Resources

func (*DeploymentBuilder) ServiceAccount

func (d *DeploymentBuilder) ServiceAccount(name string) *DeploymentBuilder

type DynamicKind

type DynamicKind struct {
	APIVersion, Kind string
}

func (DynamicKind) GroupVersionKind

func (dk DynamicKind) GroupVersionKind() schema.GroupVersionKind

func (DynamicKind) SetGroupVersionKind

func (dk DynamicKind) SetGroupVersionKind(gvk schema.GroupVersionKind)

type Health

type Health struct {
	RunningPods, PendingPods, ErrorPods, CrashLoopBackOff int
	ReadyNodes, UnreadyNodes                              int
	Error                                                 error
}

func (Health) IsDegradedComparedTo

func (h Health) IsDegradedComparedTo(h2 Health) bool

func (Health) String

func (h Health) String() string

type Metadata

type Metadata struct {
	Name        string            `yaml:"name,omitempty"`
	Namespace   string            `yaml:"namespace,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
}

type ServiceAccountBuilder

type ServiceAccountBuilder struct {
	*Builder
	Name string
}

func (*ServiceAccountBuilder) AddClusterRole

func (s *ServiceAccountBuilder) AddClusterRole(role string) *ServiceAccountBuilder

func (*ServiceAccountBuilder) AddRole

type Spec

type Spec struct {
	Path  string
	Items []unstructured.Unstructured
}

type Specs

type Specs []Spec

func Walk

func Walk(path string) (Specs, error)

Walk iterates recursively over each file in path and returns all of the objects contained

func (Specs) FilterBy

func (specs Specs) FilterBy(kind string) []unstructured.Unstructured

Directories

Path Synopsis
Package etcd provides a connection to an etcd member.
Package etcd provides a connection to an etcd member.
Package kustomize contains helpers for working with embedded kustomize commands Package kustomize contains helpers for working with embedded kustomize commands
Package kustomize contains helpers for working with embedded kustomize commands Package kustomize contains helpers for working with embedded kustomize commands

Jump to

Keyboard shortcuts

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