kubectl

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 9 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
	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

func (k *Kubectl) KubectlApply(manifest string, options ...string) error

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

func (k *Kubectl) KubectlApplyString(str string, options ...string) error

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

func (k *Kubectl) KubectlCordon(nodeName string, options ...string) error

KubectlCordon runs kubectl cordon <node name> for a particular node in cluster

func (*Kubectl) KubectlDeleteManifest

func (k *Kubectl) KubectlDeleteManifest(manifest string, options ...string) error

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

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

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

func (k *Kubectl) KubectlDeleteString(str string, options ...string) error

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

func (k *Kubectl) KubectlDescribe(resource, resourceName string, options ...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", "-n", "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 string, options ...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","-n", "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 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, options ...string) 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")

func (*Kubectl) KubectlPatch

func (k *Kubectl) KubectlPatch(resource, resourceName, patchPath string, options ...string) error

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\"")

func (Kubectl) RolloutRestart added in v0.5.0

func (k Kubectl) RolloutRestart(resource string, options ...string) error

Jump to

Keyboard shortcuts

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