Documentation ¶
Overview ¶
Package kubectl provides function for using the kubectl commands
Index ¶
- type Kubectl
- func (k *Kubectl) KubectlAnnotate(resource, resourceName, annotation string, options ...string) error
- func (k *Kubectl) KubectlApply(manifest string, options ...string) error
- func (k *Kubectl) KubectlApplyString(str string, options ...string) error
- func (k *Kubectl) KubectlCordon(nodeName string, options ...string) error
- func (k *Kubectl) KubectlDeleteManifest(manifest string, options ...string) error
- func (k *Kubectl) KubectlDeleteResource(resource, resourceName string, options ...string) error
- func (k *Kubectl) KubectlDeleteString(str string, options ...string) error
- func (k *Kubectl) KubectlDescribe(resource, resourceName string, options ...string) error
- func (k *Kubectl) KubectlDrain(nodeName string) error
- func (k *Kubectl) KubectlExecEtcd(etcdPod, etcdctlCmd string) ([]byte, error)
- func (k *Kubectl) KubectlGet(resource string, options ...string) ([]byte, error)
- func (k *Kubectl) KubectlGetEtcdPods(masterNodeName string) ([]byte, error)
- func (k *Kubectl) KubectlGetNodeNames() ([]byte, error)
- func (k *Kubectl) KubectlLabel(resource, resourceName, label string, options ...string) error
- func (k *Kubectl) KubectlPatch(resource, resourceName, patchPath string, options ...string) error
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 MaxKubectlRetries int Stdout io.Writer Stderr io.Writer }
Kubeconfig - the kubeconfig of the cluster as a string when left empty, kuber uses default kubeconfig, MaxKubectlRetries when unset/set=0 will use defaultMaxKubectlRetries = 10
func (*Kubectl) KubectlAnnotate ¶
func (k *Kubectl) KubectlAnnotate(resource, resourceName, annotation string, options ...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 ¶
KubectlApply runs kubectl apply in k.Directory directory, with specified manifest example: kubectl apply -f test.yaml -> k.KubectlApply("test.yaml") example: kubectl apply -f test.yaml -n test -> k.KubectlApply("test.yaml", "-n", "test")
func (*Kubectl) KubectlApplyString ¶
KubectlApplyString runs kubectl apply in k.Directory directory, with specified string data example: echo 'Kind: Pod ...' | kubectl apply -f - -> k.KubectlApply("Kind: Pod ...")
func (*Kubectl) KubectlCordon ¶ added in v0.3.1
KubectlCordon runs kubectl cordon <node name> for a particular node in cluster
func (*Kubectl) KubectlDeleteManifest ¶
KubectlDeleteManifest runs kubectl delete in k.Directory, with specified manifest example: kubectl delete -f test.yaml -> k.KubectlDelete("test.yaml") example: kubectl delete -f test.yaml -n test -> k.KubectlDelete("test.yaml", "-n", "test")
func (*Kubectl) KubectlDeleteResource ¶
KubectlDeleteResource runs kubectl delete in k.Directory, with specified resource, resource name example: kubectl delete ns test -> k.KubectlDeleteResource("ns","test") example: kubectl delete pod busy-box -n test -> k.KubectlDeleteResource("pod","busy-box", "-n","test")
func (*Kubectl) KubectlDeleteString ¶ added in v0.2.2
KubectlDeleteString runs kubectl delete in k.Directory, with specified resource, resource name example: echo 'kind: Namespace...' | kubectl delete -f - -> k.KubectlDeleteResource("kind: Namespace ...") example: echo 'kind: Namespace...' | kubectl delete -f - -n test -> k.KubectlDeleteResource("kind: Namespace ...", "-n","test")
func (*Kubectl) KubectlDescribe ¶
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", "-n", "test")
func (*Kubectl) KubectlDrain ¶
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 (*Kubectl) KubectlGet ¶
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","-n", "test")
func (*Kubectl) KubectlGetEtcdPods ¶
getEtcdPods finds all etcd pods in cluster returns slice of pod names and nil if successful, nil and error otherwise
func (*Kubectl) KubectlGetNodeNames ¶
KubectlGetNodeNames will find node names for a particular cluster return slice of node names and nil if successful, nil and error otherwise
func (*Kubectl) KubectlLabel ¶
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")
func (*Kubectl) KubectlPatch ¶
KubectlPatch runs kubectl patch <resource> <resource name> -p <patch path> on specified resource example: kubectl patch node node-1 -p {\"spec\":{\"providerID\":\"claudie://node-1\"}} -> KubectlPatch("node", "node-1", "{\"spec\":{\"providerID\":\"claudie://node-1\"}}") example: kubectl patch node node-1 -p {\"spec\":{\"providerID\":\"claudie://node-1\"}} --type="strategic" -> KubectlPatch("node", "node-1", "{\"spec\":{\"providerID\":\"claudie://node-1\"}}", "--type=\"strategic\"")