kubectl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package kubectl provides function for using the kubectl commands

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kubectl

type Kubectl struct {
	Kubeconfig string
	Directory  string
}

Kubeconfig - the kubeconfig of the cluster as a string when left empty, kuber uses default kubeconfig

func (*Kubectl) KubectlAnnotate

func (k *Kubectl) KubectlAnnotate(resource, resourceName, annotation string) error

KubectlAnnotate runs kubectl annotate in k.Directory, with the specified annotation on a specified resource and resource name example: kubectl annotate node node-1 node.longhorn.io/default-node-tags='["zone2"]' -> k.KubectlAnnotate("node","node-1","node.longhorn.io/default-node-tags='["zone2"]")

func (*Kubectl) KubectlApply

func (k *Kubectl) KubectlApply(manifest, namespace string) error

KubectlApply runs kubectl apply in k.Directory directory, with specified manifest and specified namespace if namespace is empty string, the kubectl apply will not use -n flag example: kubectl apply -f test.yaml -> k.KubectlApply("test.yaml", "") example: kubectl apply -f test.yaml -n test -> k.KubectlApply("test.yaml", "test")

func (*Kubectl) KubectlApplyString

func (k *Kubectl) KubectlApplyString(str, namespace string) error

KubectlApplyString runs kubectl apply in k.Directory directory, with specified string data and specified namespace if namespace is empty string, the kubectl apply will not use -n flag example: echo 'Kind: Pod ...' | kubectl apply -f - -> k.KubectlApply("Kind: Pod ...", "")

func (*Kubectl) KubectlDeleteManifest

func (k *Kubectl) KubectlDeleteManifest(manifest, namespace string) error

KubectlDeleteManifest runs kubectl delete in k.Directory, with specified manifest and specified namespace if namespace is empty string, the kubectl apply will not use -n flag example: kubectl delete -f test.yaml -> k.KubectlDelete("test.yaml", "") example: kubectl delete -f test.yaml -n test -> k.KubectlDelete("test.yaml", "test")

func (*Kubectl) KubectlDeleteResource

func (k *Kubectl) KubectlDeleteResource(resource, resourceName, namespace string) error

KubectlDeleteResource runs kubectl delete in k.Directory, with specified resource, resource name and specified namespace if namespace is empty string, the kubectl apply will not use -n flag example: kubectl delete ns test -> k.KubectlDeleteResource("ns","test", "") example: kubectl delete pod busy-box -n test -> k.KubectlDeleteResource("pod","busy-box", "test")

func (*Kubectl) KubectlDescribe

func (k *Kubectl) KubectlDescribe(resource, resourceName, namespace string) error

KubectlDescribe runs kubectl describe in k.Directory, on a specified resource, resource name and specified namespace if namespace is empty string, the kubectl apply will not use -n flag example: kubectl describe pod test -> k.KubectlDescribe("pod","test", "") example: kubectl describe pod busy-box -n test -> k.KubectlDescribe("pod","busy-box", "test")

func (*Kubectl) KubectlDrain

func (k *Kubectl) KubectlDrain(nodeName string) error

KubectlDrain runs kubectl drain in k.Directory, on a specified node with flags --ignore-daemonsets --delete-emptydir-data example: kubectl drain node1 -> k.KubectlDrain("node1")

func (*Kubectl) KubectlExecEtcd

func (k *Kubectl) KubectlExecEtcd(etcdPod, etcdctlCmd string) ([]byte, error)

func (*Kubectl) KubectlGet

func (k *Kubectl) KubectlGet(resource, namespace string) ([]byte, error)

KubectlGet runs kubectl get in k.Directory, on a specified resource and specified namespace if namespace is empty string, the kubectl apply will not use -n flag example: kubectl get ns -> k.KubectlGet("ns", "") example: kubectl get pods -n test -> k.KubectlGet("pods", "test")

func (*Kubectl) KubectlGetEtcdPods

func (k *Kubectl) KubectlGetEtcdPods(masterNodeName string) ([]byte, error)

getEtcdPods finds all etcd pods in cluster returns slice of pod names and nil if successful, nil and error otherwise

func (*Kubectl) KubectlGetNodeNames

func (k *Kubectl) KubectlGetNodeNames() ([]byte, error)

KubectlGetNodeNames will find a node names for a particular cluster return slice of node names and nil if successful, nil and error otherwise

func (*Kubectl) KubectlLabel

func (k *Kubectl) KubectlLabel(resource, resourceName, label string, overwrite bool) error

KubectlLabel runs kubectl label in k.Directory, with the specified label on a specified resource and resource name example: kubectl label node node-1 label=value -> k.KubectlLabel("node","node-1","label=value")

Jump to

Keyboard shortcuts

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