kubectl

package
v1.1.1-0...-9418116 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 49 Imported by: 3

Documentation

Index

Constants

View Source
const ClusterRoleBindingName = "devspace-user"

ClusterRoleBindingName is the name of the cluster role binding that ensures that the user has enough rights

Variables

View Source
var CriticalStatus = map[string]bool{
	"Error":                      true,
	"Unknown":                    true,
	"ImagePullBackOff":           true,
	"CrashLoopBackOff":           true,
	"RunContainerError":          true,
	"ErrImagePull":               true,
	"CreateContainerConfigError": true,
	"InvalidImageName":           true,
}

CriticalStatus container status

View Source
var OkayStatus = map[string]bool{
	"Completed": true,
	"Running":   true,
}

OkayStatus container status

View Source
var WaitStatus = []string{
	"ContainerCreating",
	"PodInitializing",
	"Pending",
	"Terminating",
}

WaitStatus are the status to wait

Functions

func GetPodStatus

func GetPodStatus(pod *k8sv1.Pod) string

GetPodStatus returns the pod status as a string Taken from https://github.com/kubernetes/kubernetes/pkg/printers/internalversion/printers.go

func GroupVersionExist

func GroupVersionExist(groupVersion string, resourceList []*metav1.APIResourceList) bool

GroupVersionExist checks if the given group version exists

func IsLocalKubernetes

func IsLocalKubernetes(context string) bool

IsLocalKubernetes returns true if the context belongs to a local Kubernetes cluster

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

IsPrivateIP checks if a given ip is private

func ResourceExist

func ResourceExist(groupVersion, name string, resourceList []*metav1.APIResourceList) bool

ResourceExist checks if the given resource exists in the group version

Types

type Client

type Client interface {
	CurrentContext() string
	KubeClient() kubernetes.Interface
	Namespace() string
	RestConfig() *rest.Config

	PrintWarning(generatedConfig *generated.Config, noWarning, shouldWait bool, log log.Logger) error
	CopyFromReader(pod *k8sv1.Pod, container, containerPath string, reader io.Reader) error
	Copy(pod *k8sv1.Pod, container, containerPath, localPath string, exclude []string) error

	ExecStreamWithTransport(transport http.RoundTripper, upgrader spdy.Upgrader, pod *k8sv1.Pod, container string, command []string, tty bool, stdin io.Reader, stdout io.Writer, stderr io.Writer, subResource SubResource) error
	ExecStream(pod *k8sv1.Pod, container string, command []string, tty bool, stdin io.Reader, stdout io.Writer, stderr io.Writer) error
	ExecBuffered(pod *k8sv1.Pod, container string, command []string, input io.Reader) ([]byte, []byte, error)

	GenericRequest(options *GenericRequestOptions) (string, error)

	ReadLogs(namespace, podName, containerName string, lastContainerLog bool, tail *int64) (string, error)
	LogMultipleTimeout(imageSelector []string, interrupt chan error, tail *int64, writer io.Writer, timeout time.Duration, log log.Logger) error
	LogMultiple(imageSelector []string, interrupt chan error, tail *int64, writer io.Writer, log log.Logger) error
	Logs(ctx context.Context, namespace, podName, containerName string, lastContainerLog bool, tail *int64, follow bool) (io.ReadCloser, error)

	GetUpgraderWrapper() (http.RoundTripper, *upgraderWrapper, error)

	EnsureDefaultNamespace(log log.Logger) error
	EnsureGoogleCloudClusterRoleBinding(log log.Logger) error
	GetRunningPodsWithImage(imageNames []string, namespace string, maxWaiting time.Duration) ([]*k8sv1.Pod, error)
	GetNewestRunningPod(labelSelector string, imageSelector []string, namespace string, maxWaiting time.Duration) (*k8sv1.Pod, error)
	NewPortForwarder(pod *k8sv1.Pod, ports []string, addresses []string, stopChan chan struct{}, readyChan chan struct{}, errorChan chan error) (*portforward.PortForwarder, error)
	IsLocalKubernetes() bool
}

Client holds all kubect functions

func NewClientBySelect

func NewClientBySelect(allowPrivate bool, switchContext bool, log log.Logger) (Client, error)

NewClientBySelect creates a new kubernetes client by user select @Factory

func NewClientFromContext

func NewClientFromContext(context, namespace string, switchContext bool) (Client, error)

NewClientFromContext creates a new kubernetes client from given context @Factory

func NewDefaultClient

func NewDefaultClient() (Client, error)

NewDefaultClient creates the new default kube client from the active context @Factory

type GenericRequestOptions

type GenericRequestOptions struct {
	Resource   string
	APIVersion string

	Name          string
	LabelSelector string
	Namespace     string
}

GenericRequestOptions are the options for the request

type SubResource

type SubResource string

SubResource specifies with sub resources should be used for the container connection (exec or attach)

const (
	// SubResourceExec creates a new process in the container and attaches to that
	SubResourceExec SubResource = "exec"

	// SubResourceAttach attaches to the top process of the container
	SubResourceAttach SubResource = "attach"
)

type UpgraderWrapper

type UpgraderWrapper interface {
	NewConnection(resp *http.Response) (httpstream.Connection, error)
	Close() error
}

UpgraderWrapper wraps the upgrader and adds a connections array

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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