utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOrRemoveCloudAccount added in v0.5.0

func AddOrRemoveCloudAccount(kubeCtl *KubeCtl, params k8stemplates.CloudAccountParameters, delete bool) error

AddOrRemoveCloudAccount adds or removes CloudProviderAccount CR and Secret from a namespace.

func CheckCloudResourceNetworkPolicies

func CheckCloudResourceNetworkPolicies(kubeCtl *KubeCtl, k8sClient client.Client, kind, namespace string, ids, anps []string,
	withAgent bool) error

CheckCloudResourceNetworkPolicies checks NetworkPolicies has been applied to cloud resources.

func CheckDeploymentConfigured added in v0.6.0

func CheckDeploymentConfigured(k8sClient client.Client, name, namespace string) error

CheckDeploymentConfigured checks if the deployment is configured or not. Return nil if configured.

func CheckRestart

func CheckRestart(kubctl *KubeCtl) error

CheckRestart returns error if nephe controller has restarted.

func CheckVirtualMachinePolicies added in v0.4.0

func CheckVirtualMachinePolicies(k8sClient client.Client, namespace string, num int) error

CheckVirtualMachinePolicies checks the number of vmp in a given namespace matches expected num and all in success state.

func CollectAgentInfo

func CollectAgentInfo(kubctl *KubeCtl, dir string) error

CollectAgentInfo collect ovs dump-flows from all bridges.

func CollectCRDs

func CollectCRDs(kubectl *KubeCtl, dir string) error

CollectCRDs collects related CRDs in the cluster.

func CollectControllerLogs

func CollectControllerLogs(kubctl *KubeCtl, dir string) error

CollectControllerLogs collect logs from controllers.

func CollectSupportBundle

func CollectSupportBundle(kubctl *KubeCtl, dir string, cloudVPC CloudVPC, withAgent bool, withWindows bool)

CollectSupportBundle collect antrea and nephe logs.

func CollectVMAgentLog added in v0.2.0

func CollectVMAgentLog(cloudVPC CloudVPC, dir string, withWindows bool) error

CollectVMAgentLog collects VM agent log from all imported VMs.

func ConfigANPApplyTo added in v0.6.0

func ConfigANPApplyTo(kind, instanceName, vpc, tagKey, tagVal string) *k8stemplates.EntitySelectorParameters

ConfigANPApplyTo helper function to configure appliedTo in Antrea NetworkPolicy.

func ConfigANPToFrom added in v0.6.0

func ConfigANPToFrom(kind, instanceName, vpc, tagKey, tagVal, ipBlock, nsName string, ports []string,
	denyAll bool) *k8stemplates.ToFromParameters

ConfigANPToFrom helper function to configure to and from fields in Antrea NetworkPolicy.

func ConfigureEntitySelectorAndWait

func ConfigureEntitySelectorAndWait(kubeCtl *KubeCtl, k8sClient client.Client, params k8stemplates.CloudEntitySelectorParameters,
	kind string, num int, namespace string, isDelete bool) error

ConfigureEntitySelectorAndWait configures EntitySelector for cloud resources, and wait for them to be imported.

func ConfigureK8s

func ConfigureK8s(kubeCtl *KubeCtl, params interface{}, yaml string, isDelete bool) error

ConfigureK8s create or delete an configuration in yaml.

func DeleteHelmChart added in v0.6.0

func DeleteHelmChart() error

DeleteHelmChart uninstall helm chart from nephe-system namespace.

func ExecuteCmd added in v0.6.0

func ExecuteCmd(timeout time.Duration, cmds []string) (string, error)

ExecuteCmd helper for command execution.

func ExecuteCmds

func ExecuteCmds(vpc CloudVPC, kubctl *KubeCtl, srcIDs []string, ns string, cmds [][]string, oks []bool, retries int) error

ExecuteCmds excutes cmds on resource srcIDs in parallel, and returns error if oks mismatch.

func ExecuteCurlCmds

func ExecuteCurlCmds(vpc CloudVPC, kubctl *KubeCtl,
	srcIDs []string, ns string, destIPs []string, port string, oks []bool, retries int) error

ExecuteCurlCmds executes curl on resource srcIDs in parallel, and returns error if oks mismatch.

func GenerateNameFromText

func GenerateNameFromText(fullText string, focus []string) string

GenerateNameFromText returns a name derived from test.FullContext. Stripping space and focus.

func GetPodsFromDeployment

func GetPodsFromDeployment(k8sClient client.Client, name, namespace string) ([]string, error)

GetPodsFromDeployment returns Pods of Deployment.

func GetServiceClusterIPPort

func GetServiceClusterIPPort(k8sClient client.Client, name, namespace string) (string, int32, error)

GetServiceClusterIPPort returns clusterIP and first port of a service.

func GetVirtualMachinePolicy added in v0.4.0

func GetVirtualMachinePolicy(k8sClient client.Client, id, namespace string) (*runtimev1alpha1.VirtualMachinePolicy, error)

GetVirtualMachinePolicy gets vmp corresponding to id and namespace.

func InstallHelmChart added in v0.6.0

func InstallHelmChart(k8sClient client.Client, version string) error

InstallHelmChart install helm chart in nephe-system namespace.

func NewK8sClient

func NewK8sClient(scheme *runtime.Scheme, cluster string) (client.Client, error)

NewK8sClient returns K8s client interface.

func RestartOrWaitDeployment

func RestartOrWaitDeployment(k8sClient client.Client, name, namespace string, timeout time.Duration, restart bool) error

RestartOrWaitDeployment restarts an existing deployment.

func SetAgentConfig added in v0.2.0

func SetAgentConfig(c client.Client, ns *corev1.Namespace, cloudProviders, antreaVersion, kubeconfig, dir string, withWindows bool) error

SetAgentConfig configures the cluster, generates agent kubeconfigs and sets terraform env vars.

func StartOrWaitDeployment

func StartOrWaitDeployment(k8sClient client.Client, name, namespace string, replicas int32, timeout time.Duration) error

StartOrWaitDeployment start a stopped deployment with number of replicas. Or wait for the deployment to complete if replicas is 0.

func StopDeployment

func StopDeployment(k8sClient client.Client, name, namespace string, timeout time.Duration) (int32, error)

StopDeployment stops an deployment..

func UpgradeHelmChart added in v0.6.0

func UpgradeHelmChart(k8sClient client.Client, toVersion string, chartDir string) error

UpgradeHelmChart upgrade helm chart in nephe-system namespace.

func WaitApiServer

func WaitApiServer(k8sClient client.Client, timeout time.Duration) error

WaitApiServer wait for aggregated api server to be ready.

Types

type CloudVPC

type CloudVPC interface {
	GetVPCID() string
	GetVPCName() string
	GetCRDVPCID() string
	GetVMs() []string
	GetVMIDs() []string
	GetVMNames() []string
	GetVMIPs() []string
	GetVMPrivateIPs() []string
	GetPrimaryNICs() []string
	GetNICs() []string
	GetTags() []map[string]string
	IsConfigured() bool

	VMCmd(vm string, vmCmd []string, timeout time.Duration) (string, error)
	Delete(duration time.Duration) error
	Reapply(duration time.Duration, withAgent bool) error
	GetCloudAccountParameters(name, namespace string, useInvalidCred bool) k8stemplates.CloudAccountParameters
	GetEntitySelectorParameters(name, namespace, kind string, vms []string) k8stemplates.CloudEntitySelectorParameters
}

func NewCloudVPC

func NewCloudVPC(provider runtimev1alpha1.CloudProvider) (CloudVPC, error)

type KubeCtl

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

func NewKubeCtl

func NewKubeCtl(config string) (*KubeCtl, error)

func (*KubeCtl) Apply

func (c *KubeCtl) Apply(path string, content []byte) error

Apply calls "kubectl apply".

func (*KubeCtl) Cmd

func (c *KubeCtl) Cmd(inCmd string) (string, error)

Cmd calls arbitrary kubectl commands.

func (*KubeCtl) Delete

func (c *KubeCtl) Delete(path string, content []byte) error

Delete calls "kubectl delete".

func (*KubeCtl) IsPresent

func (c *KubeCtl) IsPresent() error

IsPresent returns error if kubectl cannot connect to K8s.

func (*KubeCtl) Patch

func (c *KubeCtl) Patch(path string, content []byte, kind, name string) error

Patch calls "kubectl patch".

func (*KubeCtl) PodCmd

func (c *KubeCtl) PodCmd(pod *types.NamespacedName, podCmd []string, timeout time.Duration) (string, error)

PodCmd execute podCmd on pod.

func (*KubeCtl) SetContext

func (c *KubeCtl) SetContext(clusterCtx string)

Jump to

Keyboard shortcuts

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