Documentation ¶
Index ¶
- Constants
- func ExecCmd(command string) error
- func ExecCmdWithOptions(command string, outputFunction func(string)) error
- func GetLocalK8sDeps() (*kubernetes.Clientset, *rest.Config, error)
- type Chaos
- type ChaosState
- type ConnectionInfo
- type ConnectionMode
- type Forwarder
- type K8sClient
- func (m *K8sClient) AddLabel(namespace string, selector string, label string) error
- func (m *K8sClient) AddPodAnnotation(namespace string, pod v1.Pod, key, value string) error
- func (m *K8sClient) AddPodLabel(namespace string, pod v1.Pod, key, value string) error
- func (m *K8sClient) AddPodsAnnotations(namespace, labelSelector string, annotations map[string]string) error
- func (m *K8sClient) Apply(manifest string) error
- func (m *K8sClient) CopyToPod(namespace, src, destination, containername string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)
- func (m *K8sClient) Create(manifest string) error
- func (m *K8sClient) DeleteResource(namespace string, resource string, instance string) error
- func (m *K8sClient) DryRun(manifest string) error
- func (m *K8sClient) EnumerateInstances(namespace string, selector string) error
- func (m *K8sClient) ExecuteInPod(namespace, podName, containerName string, command []string) ([]byte, []byte, error)
- func (m *K8sClient) LabelChaosGroup(namespace string, startInstance int, endInstance int, group string) error
- func (m *K8sClient) LabelChaosGroupByLabels(namespace string, labels map[string]string, group string) error
- func (m *K8sClient) ListNamespaces(selector string) (*v1.NamespaceList, error)
- func (m *K8sClient) ListPods(namespace, selector string) (*v1.PodList, error)
- func (m *K8sClient) NamespaceExists(namespace string) bool
- func (m *K8sClient) RemoveNamespace(namespace string) error
- func (m *K8sClient) RolloutRestartBySelector(namespace string, resource string, selector string) error
- func (m *K8sClient) RolloutStatefulSets(namespace string) error
- func (m *K8sClient) UniqueLabels(namespace string, selector string) ([]string, error)
- func (m *K8sClient) WaitForJob(namespaceName string, jobName string, fundReturnStatus func(string)) error
- func (m *K8sClient) WaitPodsReady(ns string, rcd *ReadyCheckData, expectedPodCount int) error
- type Protocol
- type ReadyCheckData
- type URLConverter
Constants ¶
const ( TempDebugManifest = "tmp-manifest-%s.yaml" K8sStatePollInterval = 2 * time.Second JobFinalizedTimeout = 2 * time.Minute AppLabel = "app" )
Variables ¶
This section is empty.
Functions ¶
func ExecCmdWithOptions ¶
func GetLocalK8sDeps ¶
func GetLocalK8sDeps() (*kubernetes.Clientset, *rest.Config, error)
GetLocalK8sDeps get local k8s context config
Types ¶
type Chaos ¶
Chaos is controller that manages Chaosmesh CRD instances to run experiments
func (*Chaos) WaitForAllRecovered ¶
type ChaosState ¶
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 (*Forwarder) FindPort ¶
func (m *Forwarder) FindPort(ks ...string) *URLConverter
func (*Forwarder) PrintLocalPorts ¶
func (m *Forwarder) PrintLocalPorts()
PrintLocalPorts prints all local forwarded ports
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) AddPodAnnotation ¶
AddPodAnnotation adds an annotation to a pod
func (*K8sClient) AddPodLabel ¶
AddPodLabel adds a label to a pod
func (*K8sClient) AddPodsAnnotations ¶
func (m *K8sClient) AddPodsAnnotations(namespace, labelSelector string, annotations map[string]string) error
AddPodsAnnotations adds map of annotations to all pods selected by selector
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) DeleteResource ¶
DeleteResource deletes resource
func (*K8sClient) EnumerateInstances ¶
EnumerateInstances enumerate pods with instance label
func (*K8sClient) ExecuteInPod ¶
func (m *K8sClient) ExecuteInPod(namespace, podName, containerName string, command []string) ([]byte, []byte, error)
ExecuteInPod is similar to kubectl exec
func (*K8sClient) LabelChaosGroup ¶
func (*K8sClient) LabelChaosGroupByLabels ¶
func (*K8sClient) ListNamespaces ¶
func (m *K8sClient) ListNamespaces(selector string) (*v1.NamespaceList, error)
ListNamespaces lists k8s namespaces
func (*K8sClient) NamespaceExists ¶
NamespaceExists check if namespace exists
func (*K8sClient) RemoveNamespace ¶
RemoveNamespace removes namespace
func (*K8sClient) RolloutRestartBySelector ¶
func (m *K8sClient) RolloutRestartBySelector(namespace string, resource string, selector string) error
RolloutRestartBySelector rollouts and restarts object by selector
func (*K8sClient) RolloutStatefulSets ¶
RolloutStatefulSets applies "rollout statefulset" to all existing statefulsets in that namespace
func (*K8sClient) UniqueLabels ¶
UniqueLabels gets all unique application labels
func (*K8sClient) WaitForJob ¶
func (m *K8sClient) WaitForJob(namespaceName string, jobName string, fundReturnStatus func(string)) error
WaitForJob wait for job execution, follow logs and returns an error if job failed
func (*K8sClient) WaitPodsReady ¶
func (m *K8sClient) WaitPodsReady(ns string, rcd *ReadyCheckData, expectedPodCount int) error
WaitPodsReady waits until all pods are ready
type Protocol ¶
type Protocol int
Protocol represents a URL scheme to use when fetching connection details
type ReadyCheckData ¶
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