kubernetes

package
v0.5.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MiniKubeIPEnvVar is the environment variable name which will have Minikube node IP
	MiniKubeIPEnvVar = "DAPR_TEST_MINIKUBE_IP"

	// PollInterval is how frequently e2e tests will poll for updates.
	PollInterval = 1 * time.Second
	// PollTimeout is how long e2e tests will wait for resource updates when polling.
	PollTimeout = 10 * time.Minute
)
View Source
const (
	// TestAppLabelKey is the label key for Kubernetes label selector
	TestAppLabelKey = "testapp"
	// DaprSideCarName is the Pod name of Dapr side car
	DaprSideCarName = "daprd"

	// DefaultContainerPort is the default container port exposed from test app
	DefaultContainerPort = 3000
	// DefaultExternalPort is the default external port exposed by load balancer ingress
	DefaultExternalPort = 3000

	// DaprComponentsKind is component kind
	DaprComponentsKind = "components.dapr.io"

	// DaprTestNamespaceEnvVar is the environment variable for setting the Kubernetes namespace for e2e tests
	DaprTestNamespaceEnvVar = "DAPR_TEST_NAMESPACE"
)

Variables

View Source
var DaprTestNamespace = "dapr-tests"

DaprTestNamespace is the default Kubernetes namespace for e2e tests

Functions

This section is empty.

Types

type AppDescription

type AppDescription struct {
	AppName        string
	AppPort        int
	AppProtocol    string
	DaprEnabled    bool
	ImageName      string
	RegistryName   string
	Replicas       int32
	IngressEnabled bool
	MetricsPort    string
}

AppDescription holds the deployment information of test app

type AppManager

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

AppManager holds Kubernetes clients and namespace used for test apps and provides the helpers to manage the test apps

func NewAppManager

func NewAppManager(kubeClients *KubeClient, namespace string, app AppDescription) *AppManager

NewAppManager creates AppManager instance

func (*AppManager) AcquireExternalURL

func (m *AppManager) AcquireExternalURL() string

AcquireExternalURL gets external ingress endpoint from service when it is ready

func (*AppManager) AcquireExternalURLFromService

func (m *AppManager) AcquireExternalURLFromService(svc *apiv1.Service) string

AcquireExternalURLFromService gets external url from Service Object.

func (*AppManager) App added in v0.3.0

func (m *AppManager) App() AppDescription

App returns app description

func (*AppManager) CreateIngressService

func (m *AppManager) CreateIngressService() (*apiv1.Service, error)

CreateIngressService creates Ingress endpoint for test app

func (*AppManager) DeleteDeployment

func (m *AppManager) DeleteDeployment(ignoreNotFound bool) error

DeleteDeployment deletes deployment for the test app

func (*AppManager) DeleteService

func (m *AppManager) DeleteService(ignoreNotFound bool) error

DeleteService deletes deployment for the test app

func (*AppManager) Deploy

func (m *AppManager) Deploy() (*appsv1.Deployment, error)

Deploy deploys app based on app description

func (*AppManager) Dispose

func (m *AppManager) Dispose() error

Dispose deletes deployment and service

func (*AppManager) DoPortForwarding added in v0.4.0

func (m *AppManager) DoPortForwarding(podName string, targetPorts ...int) ([]int, error)

DoPortForwarding performs port forwarding for given podname to access test apps in the cluster

func (*AppManager) GetOrCreateNamespace

func (m *AppManager) GetOrCreateNamespace() (*apiv1.Namespace, error)

GetOrCreateNamespace gets or creates namespace unless namespace exists

func (*AppManager) Init

func (m *AppManager) Init() error

Init installs app by AppDescription

func (*AppManager) IsDeploymentDeleted

func (m *AppManager) IsDeploymentDeleted(deployment *appsv1.Deployment, err error) bool

IsDeploymentDeleted returns true if deployment does not exist or current pod replica is zero

func (*AppManager) IsDeploymentDone

func (m *AppManager) IsDeploymentDone(deployment *appsv1.Deployment, err error) bool

IsDeploymentDone returns true if deployment object completes pod deployments

func (*AppManager) IsServiceDeleted

func (m *AppManager) IsServiceDeleted(svc *apiv1.Service, err error) bool

IsServiceDeleted returns true if service does not exist

func (*AppManager) IsServiceIngressReady

func (m *AppManager) IsServiceIngressReady(svc *apiv1.Service, err error) bool

IsServiceIngressReady returns true if external ip is available

func (*AppManager) Name

func (m *AppManager) Name() string

Name returns app name

func (*AppManager) ScaleDeploymentReplica added in v0.3.0

func (m *AppManager) ScaleDeploymentReplica(replicas int32) error

ScaleDeploymentReplica scales the deployment

func (*AppManager) ValidiateSideCar

func (m *AppManager) ValidiateSideCar() (bool, error)

ValidiateSideCar validates that dapr side car is running in dapr enabled pods

func (*AppManager) WaitUntilDeploymentState

func (m *AppManager) WaitUntilDeploymentState(isState func(*appsv1.Deployment, error) bool) (*appsv1.Deployment, error)

WaitUntilDeploymentState waits until isState returns true

func (*AppManager) WaitUntilServiceState

func (m *AppManager) WaitUntilServiceState(isState func(*apiv1.Service, error) bool) (*apiv1.Service, error)

WaitUntilServiceState waits until isState returns true

type ComponentDescription added in v0.3.0

type ComponentDescription struct {
	// Name is the name of dapr component
	Name string
	// Type contains component types (<type>.<component_name>)
	TypeName string
	// MetaData contains the metadata for dapr component
	MetaData map[string]string
}

ComponentDescription holds dapr component description

type DaprComponent added in v0.3.0

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

DaprComponent holds kubernetes client and component information

func NewDaprComponent added in v0.3.0

func NewDaprComponent(client *KubeClient, ns string, comp ComponentDescription) *DaprComponent

NewDaprComponent creates DaprComponent instance

func (*DaprComponent) Dispose added in v0.3.0

func (do *DaprComponent) Dispose() error

func (*DaprComponent) Init added in v0.3.0

func (do *DaprComponent) Init() error

func (*DaprComponent) Name added in v0.3.0

func (do *DaprComponent) Name() string

type KubeClient

type KubeClient struct {
	ClientSet     kubernetes.Interface
	DaprClientSet daprclient.Interface
	// contains filtered or unexported fields
}

KubeClient holds instances of Kubernetes clientset TODO: Add cluster management methods to clean up the old test apps

func NewKubeClient

func NewKubeClient(configPath string, clusterName string) (*KubeClient, error)

NewKubeClient creates KubeClient instance

func (*KubeClient) DaprComponents added in v0.3.0

func (c *KubeClient) DaprComponents(namespace string) componentsv1alpha1.ComponentInterface

DaprComponents gets Dapr component client for namespace

func (*KubeClient) Deployments

func (c *KubeClient) Deployments(namespace string) appv1.DeploymentInterface

Deployments gets Deployment client for namespace

func (*KubeClient) GetClientConfig added in v0.4.0

func (c *KubeClient) GetClientConfig() *rest.Config

GetClientConfig returns client configuration

func (*KubeClient) Namespaces

func (c *KubeClient) Namespaces() apiv1.NamespaceInterface

Namespaces gets Namespace client

func (*KubeClient) Pods

func (c *KubeClient) Pods(namespace string) apiv1.PodInterface

Pods gets Pod client for namespace

func (*KubeClient) Services

func (c *KubeClient) Services(namespace string) apiv1.ServiceInterface

Services gets Service client for namespace

type PortForwardRequest added in v0.4.0

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

Jump to

Keyboard shortcuts

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