Documentation
¶
Index ¶
- Constants
- Variables
- func GetPodStatus(pod *k8sv1.Pod) string
- func GroupVersionExist(groupVersion string, resourceList []*metav1.APIResourceList) bool
- func IsLocalKubernetes(context string) bool
- func IsPrivateIP(ip net.IP) bool
- func ResourceExist(groupVersion, name string, resourceList []*metav1.APIResourceList) bool
- type Client
- type GenericRequestOptions
- type SubResource
- type UpgraderWrapper
Constants ¶
const ClusterRoleBindingName = "devspace-user"
ClusterRoleBindingName is the name of the cluster role binding that ensures that the user has enough rights
Variables ¶
var CriticalStatus = map[string]bool{ "Error": true, "Unknown": true, "ImagePullBackOff": true, "CrashLoopBackOff": true, "RunContainerError": true, "ErrImagePull": true, "CreateContainerConfigError": true, "InvalidImageName": true, }
CriticalStatus container status
var OkayStatus = map[string]bool{ "Completed": true, "Running": true, }
OkayStatus container status
var WaitStatus = []string{
"ContainerCreating",
"PodInitializing",
"Pending",
"Terminating",
}
WaitStatus are the status to wait
Functions ¶
func GetPodStatus ¶
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 ¶
IsLocalKubernetes returns true if the context belongs to a local Kubernetes cluster
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 ¶
NewClientBySelect creates a new kubernetes client by user select @Factory
func NewClientFromContext ¶
NewClientFromContext creates a new kubernetes client from given context @Factory
func NewDefaultClient ¶
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