kubectl

package
v0.0.2-0...-dd1b7fa Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Index

Examples

Constants

View Source
const Command = "kubectl"

Command is the name of kubectl command

Variables

This section is empty.

Functions

func Apply

func Apply(c Client, f string) error

Apply applies via kubectl

func CreateClusterRoleBinding

func CreateClusterRoleBinding(c Client, name, role, user string) error

CreateClusterRoleBinding creates a new cluster role binding

func CreateNamespace

func CreateNamespace(c Client, namespace string) (bool, error)

CreateNamespace creates a new namespace and returns whether it was created or not

func CreateSecretFromLiteral

func CreateSecretFromLiteral(c Client, namespace, name, key, value string, override bool) (bool, error)

CreateSecretFromLiteral creates a new secret with a single (key,value) pair.

func DeleteResource

func DeleteResource(c Client, resourceType, namespace, resourceName string) error

DeleteResource deletes a resource

func Execute

func Execute(c Client, args ...string) (string, error)

Execute executes kubectl <args> and returns the combined stdout/err output.

func ExecuteJSON

func ExecuteJSON(c Client, o interface{}, args ...string) error

ExecuteJSON execute kubectl <args> and returns the combined json stdout and err output.

func GetContainerRuntimeName

func GetContainerRuntimeName(c Client) (string, error)

GetContainerRuntimeName returns the container runtime name the node uses.

func GetSecretValue

func GetSecretValue(c Client, namespace, name, key string) (string, error)

GetSecretValue returns the value of a secret

func GetVersionInfo

func GetVersionInfo(c Client) (string, string, error)

GetVersionInfo returns the version metadata from kubectl May return a value for the kubectl client version, despite also returning an error

func ResourceExists

func ResourceExists(c Client, resourceType, namespace, resourceName string) (bool, error)

ResourceExists return true if the resource exists

func TestDNS

func TestDNS(c Client, domain string) (bool, error)

TestDNS creates a pod where a nslookup is called on a provided domain. It returns true only if the pod was successful.

Types

type Client

type Client interface {
	Execute(args ...string) (string, error)
	ExecuteOutputMatrix(args ...string) (stdout, stderr string, err error)
}

Client implements a kubectl client to execute commands

type ClusterInfo

type ClusterInfo struct {
	Name          string
	ServerAddress string
}

ClusterInfo describes a Kubernetes cluster

func GetClusterInfo

func GetClusterInfo(c Client) (ClusterInfo, error)

GetClusterInfo gets the current Kubernetes cluster information

type LocalClient

type LocalClient struct {
	GlobalArgs []string
	Env        []string
}

LocalClient implements Kubectl

Example
local := LocalClient{}
local.Execute("apply", "-f", "service.yaml")
Output:

func (LocalClient) Execute

func (k LocalClient) Execute(args ...string) (string, error)

Execute executes kubectl <args> and returns the combined stdout/err output.

func (LocalClient) ExecuteOutputMatrix

func (k LocalClient) ExecuteOutputMatrix(args ...string) (stdout, stderr string, err error)

ExecuteOutputMatrix executes kubectl <args> and returns stdout and stderr

func (LocalClient) IsPresent

func (k LocalClient) IsPresent() bool

IsPresent returns true if there's a kubectl command in the PATH.

func (LocalClient) LookPath

func (k LocalClient) LookPath() (string, error)

LookPath conveniently wraps exec.LookPath(Command)

Jump to

Keyboard shortcuts

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