client

package
v0.2.45 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: MIT Imports: 37 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TempDebugManifest          = "tmp-manifest-%s.yaml"
	ContainerStatePollInterval = 3 * time.Second
	AppLabel                   = "app"
)

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(command string) error

func GetLocalK8sDeps

func GetLocalK8sDeps() (*kubernetes.Clientset, *rest.Config, error)

GetLocalK8sDeps get local k8s context config

Types

type Chaos added in v0.2.4

type Chaos struct {
	Client         *K8sClient
	ResourceByName map[string]string
	Namespace      string
}

Chaos is controller that manages Chaosmesh CRD instances to run experiments

func NewChaos added in v0.2.4

func NewChaos(client *K8sClient, namespace string) *Chaos

NewChaos creates controller to run and stop chaos experiments

func (*Chaos) Run added in v0.2.4

func (c *Chaos) Run(app cdk8s.App, id string, resource string) (string, error)

Run runs experiment and saves it's ID

func (*Chaos) Stop added in v0.2.4

func (c *Chaos) Stop(id string) error

Stop removes a chaos experiment

func (*Chaos) WaitForAllRecovered added in v0.2.44

func (c *Chaos) WaitForAllRecovered(id string) error

type ChaosState added in v0.2.44

type ChaosState struct {
	ChaosDetails v1alpha1.ChaosStatus `json:"status"`
}

type ConnectionInfo

type ConnectionInfo struct {
	Ports portforward.ForwardedPort
	Host  string
}

type ConnectionMode

type ConnectionMode int
const (
	LocalConnection ConnectionMode = iota
	RemoteConnection
)

type Forwarder

type Forwarder struct {
	Client *K8sClient

	KeepConnection bool
	Info           map[string]interface{}
	// contains filtered or unexported fields
}

func NewForwarder

func NewForwarder(client *K8sClient, keepConnection bool) *Forwarder

func (*Forwarder) Connect

func (m *Forwarder) Connect(namespaceName string, selector string, insideK8s bool) error

func (*Forwarder) FindPort

func (m *Forwarder) FindPort(ks ...string) *URLConverter

type K8sClient

type K8sClient struct {
	ClientSet  *kubernetes.Clientset
	RESTConfig *rest.Config
}

K8sClient high level k8s client

func NewK8sClient

func NewK8sClient() *K8sClient

NewK8sClient creates a new k8s client with a REST config

func (*K8sClient) AddLabel added in v0.2.2

func (m *K8sClient) AddLabel(namespace string, selector string, label string) error

AddLabel adds a new label to a group of pods defined by selector

func (*K8sClient) AddLabelByPod added in v0.2.14

func (m *K8sClient) AddLabelByPod(namespace string, pod v1.Pod, key, value string) error

AddLabelByPod adds a label to a pod

func (*K8sClient) Apply

func (m *K8sClient) Apply(manifest string) error

Apply applying a manifest to a currently connected k8s context

func (*K8sClient) CheckReady

func (m *K8sClient) CheckReady(namespace string, c *ReadyCheckData) error

CheckReady application heath check using ManifestOutputData params

func (*K8sClient) CopyToPod

func (m *K8sClient) CopyToPod(namespace, src, destination, containername string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)

CopyToPod copies src to a particular container. Destination should be in the form of a proper K8s destination path NAMESPACE/POD_NAME:folder/FILE_NAME

func (*K8sClient) Create

func (m *K8sClient) Create(manifest string) error

Create creating a manifest to a currently connected k8s context

func (*K8sClient) DeleteResource added in v0.2.4

func (m *K8sClient) DeleteResource(namespace string, resource string, instance string) error

DeleteResource deletes resource

func (*K8sClient) DryRun

func (m *K8sClient) DryRun(manifest string) error

DryRun generates manifest and writes it in a file

func (*K8sClient) EnumerateInstances added in v0.2.2

func (m *K8sClient) EnumerateInstances(namespace string, selector string) error

EnumerateInstances enumerate pods with instance label

func (*K8sClient) ExecuteInPod added in v0.2.3

func (m *K8sClient) ExecuteInPod(namespace, podName, containerName string, command []string) ([]byte, []byte, error)

ExecuteInPod is similar to kubectl exec

func (*K8sClient) LabelChaosGroup added in v0.2.14

func (m *K8sClient) LabelChaosGroup(namespace string, startInstance int, endInstance int, group string) error

func (*K8sClient) LabelChaosGroupByLabels added in v0.2.44

func (m *K8sClient) LabelChaosGroupByLabels(namespace string, labels map[string]string, group string) error

func (*K8sClient) ListNamespaces

func (m *K8sClient) ListNamespaces(selector string) (*v1.NamespaceList, error)

ListNamespaces lists k8s namespaces

func (*K8sClient) ListPods

func (m *K8sClient) ListPods(namespace, selector string) (*v1.PodList, error)

ListPods lists pods for a namespace and selector

func (*K8sClient) NamespaceExists

func (m *K8sClient) NamespaceExists(namespace string) bool

NamespaceExists check if namespace exists

func (*K8sClient) RemoveNamespace

func (m *K8sClient) RemoveNamespace(namespace string) error

RemoveNamespace removes namespace

func (*K8sClient) UniqueLabels added in v0.2.2

func (m *K8sClient) UniqueLabels(namespace string, selector string) ([]string, error)

UniqueLabels gets all unique application labels

func (*K8sClient) WaitContainersReady added in v0.2.1

func (m *K8sClient) WaitContainersReady(ns string, rcd *ReadyCheckData) error

WaitContainersReady waits until all containers ReadinessChecks are passed

func (*K8sClient) WaitForPodBySelectorRunning

func (m *K8sClient) WaitForPodBySelectorRunning(ns string, rcd *ReadyCheckData) error

WaitForPodBySelectorRunning Wait up to timeout seconds for all pods in 'namespace' with given 'selector' to enter running state. Returns an error if no pods are found or not all discovered pods enter running state.

type Protocol

type Protocol int

Protocol represents a URL scheme to use when fetching connection details

const (
	// WS : Web Socket Protocol
	WS Protocol = iota
	// WSSUFFIX : Web Socket Protocol
	WSSUFFIX
	// WSS : Web Socket Secure Protocol
	WSS
	// HTTP : Hypertext Transfer Protocol
	HTTP
	// HTTPS : Hypertext Transfer Protocol Secure
	HTTPS
)

type ReadyCheckData

type ReadyCheckData struct {
	ReadinessProbeCheckSelector string
	Timeout                     time.Duration
}

ReadyCheckData data to check if selected pods are running and all containers are ready ( readiness check ) are ready

type URLConverter

type URLConverter struct {
	// contains filtered or unexported fields
}

URLConverter converts ports to URLs

func NewURLConverter

func NewURLConverter(fp ConnectionInfo, err error) *URLConverter

NewURLConverter creates new URLConverter instance

func (*URLConverter) As

func (m *URLConverter) As(conn ConnectionMode, proto Protocol) (string, error)

As converts host/port to an URL

Jump to

Keyboard shortcuts

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