kind

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package kind contains functions for deploying and managing Kubernetes in Docker (Kind) clusters for integration testing.

Index

Constants

View Source
const (
	// EnvKeepCluster is the environment variable that can be set to "true" in order
	// to circumvent teardown during cleanup of clusters in order to allow a user to inspect them instead.
	EnvKeepCluster = "KIND_KEEP_CLUSTER"

	// DefaultKindDockerNetwork is the Docker network that a kind cluster uses by default.
	DefaultKindDockerNetwork = "kind"
)

Variables

View Source
var (
	// ProxyReadinessWaitTick is the amount of time to wait between status checks for a Kind cluster.
	ProxyReadinessWaitTick = time.Millisecond * 200

	// ProxyAdminPort is the port on the service at which the Kong Admin API can be reached by default.
	ProxyAdminPort = 8001

	// ProxyPort is the port on the service at which the Kong proxy can be reached by default.
	ProxyPort = 80

	// ProxyNamespace is the default namespace where the Kong proxy is expected to be deployed
	ProxyNamespace = "kong-system"

	// ProxyDeploymentName is the default name of the Kong proxy deployment
	ProxyDeploymentName = "ingress-controller-kong"

	// ProxyAdminServiceName indicates the name of the Service that's serving the Admin API
	ProxyAdminServiceName = fmt.Sprintf("%s-admin", ProxyDeploymentName)

	// ProxyServiceName indicates the name of the Service that's serving the Proxy
	ProxyServiceName = fmt.Sprintf("%s-proxy", ProxyDeploymentName)

	// ProxyUDPServiceName provides the name of the LoadBalancer service the proxy uses for UDP traffic.
	// TODO: this is a hack in place to workaround problems in the Kong helm chart when UDP ports are in use:
	//       See: https://github.com/Kong/charts/issues/329
	ProxyUDPServiceName = fmt.Sprintf("%s-udp", ProxyDeploymentName)
)

Functions

func ClientForCluster

func ClientForCluster(name string) (*rest.Config, *kubernetes.Clientset, error)

ClientForCluster provides a *kubernetes.Clientset for a KIND cluster provided the cluster name.

func CreateCluster

func CreateCluster(name string) error

CreateCluster creates a new cluster using Kubernetes in Docker (KIND).

func DeleteKindCluster

func DeleteKindCluster(name string) error

DeleteKindCluster deletes an existing KIND cluster.

Types

type Cluster

type Cluster interface {
	// Name indicates the kind cluster name of the running cluster.
	Name() string

	// Client is the configured *kubernetes.Clientset which can be used to access the Cluster's API
	Client() *kubernetes.Clientset

	// Config provides the *rest.Config for the cluster which is convenient for initiating custom kubernetes.Clientsets.
	Config() *rest.Config

	// Cleanup obliterates the cluster and all of its resources, leaving no garbage behind, unless `KIND_KEEP_CLUSTER` is set.
	Cleanup() error
}

Cluster objects represent a running Kind cluster on the local container runtime.

func GetExistingCluster added in v0.0.8

func GetExistingCluster(name string) (Cluster, error)

GetExistingCluster provides a Cluster object for a given kind cluster by name.

type ClusterConfigurationWithKongProxy

type ClusterConfigurationWithKongProxy struct {
	// DockerNetwork indicates the name of the Docker network to use for LoadBalancer IPs
	DockerNetwork string

	// EnableMetalLB instructions the deployment of MetalLB to support provisioning LoadBalancer Services in the cluster.
	EnableMetalLB bool

	// DBMode indicates which database backend to use for the proxy ("off" and "postgres" are the only supported options currently)
	// Note: leaving this blank is equivalent to "off" and will deploy in DBLESS mode.
	DBMode string
}

ClusterConfigurationWithKongProxy is an object representing a Kind cluster's configuration and can effectively be used as a factory for kind cluster deployments. Clusters created from these configurations are opinionated, and will always automatically pre-deploy a Kong proxy service.

func (*ClusterConfigurationWithKongProxy) Deploy

Deploy is a factory method to generate kind.Cluster objects given the configuration, with new names being selected on each deploy.

func (*ClusterConfigurationWithKongProxy) DeployWithName added in v0.0.8

DeployWithName is a factory method to generate kind.Cluster objects given the configuration with a custom name provided.

type ProxyReadinessEvent

type ProxyReadinessEvent struct {
	// ProxyAdminURL indicates the URL at which the Kong Proxy Admin API can be reached.
	ProxyAdminURL *url.URL

	// ProxyURL indicates the URL at which the Kong proxy can be reached.
	ProxyURL *url.URL

	// ProxyUDPUrl indicates the URL at which UDP traffic the Kong proxy goes.
	// TODO: this is a hack in place to workaround problems in the Kong helm chart when UDP ports are in use:
	//       See: https://github.com/Kong/charts/issues/329
	ProxyUDPUrl *url.URL

	// Err provides any errors that have occurred that have made it impossible for the Proxy
	// to become ready, receivers should consider any errors received this way as a critical
	// failure that can not be automatically recovered from (e.g. the tests have failed).
	Err error
}

ProxyReadinessEvent indicates the result of exposing the Kong proxy service in a Cluster

Jump to

Keyboard shortcuts

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