Documentation
¶
Overview ¶
Package kind contains functions for deploying and managing Kubernetes in Docker (Kind) clusters for integration testing.
Index ¶
Constants ¶
const (
// DefaultKindDockerNetwork is the Docker network that a kind cluster uses by default.
DefaultKindDockerNetwork = "kind"
)
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" )
Variables ¶
var ( // 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) )
var ( // ProxyReadinessWaitTick is the amount of time to wait between status checks ProxyReadinessWaitTick = time.Millisecond * 200 )
Functions ¶
func ClientForCluster ¶
ClientForCluster provides a *kubernetes.Clientset for a KIND cluster provided the cluster name.
func CreateCluster ¶
CreateCluster creates a new cluster using Kubernetes in Docker (KIND).
func DeleteKindCluster ¶
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.
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 }
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 ¶
func (c *ClusterConfigurationWithKongProxy) Deploy(ctx context.Context) (Cluster, chan ProxyReadinessEvent, error)
Deploy is a factory method to generate kind.Cluster objects given the configuration, with new names being selected on each deploy.
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