Documentation ¶
Overview ¶
Package k8s spins up a Kubernetes cluster for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster is a Kubernetes cluster that runs inside of a k3s Docker container. Call GetConfig to retrieve a Kubernetes *rest.Config to use to connect to the cluster.
Cluster also runs an NGINX ingress controller which is exposed to the host. Call GetHTTPAddr to get the address for making requests against the server.
Set E2E_K8S_USE_DOCKER_NETWORK in your environment variables if you are running tests from inside of a Docker container. This environment variable configures the k3s Docker container to join the same network as the container tests are running in. When this environment variable isn't set, the exposed ports on the Docker host are used for cluster communication.
Note that k3s uses containerd as its runtime, which means local Docker images are not immediately available for use. To push local images to a container, call PushImages. It's recommended that tests use image names that are not available on Docker Hub to avoid accidentally testing against the wrong image.
Cluster should be stopped by calling Stop, otherwise running Docker containers will leak.
func (*Cluster) GetConfig ¶
GetConfig returns a *rest.Config that can be used to connect to the Kubernetes cluster. The returned Config is a copy and is safe for modification.
func (*Cluster) GetHTTPAddr ¶
GetHTTPAddr returns the host:port address that can be used to connect to the cluster's NGINX server.
func (*Cluster) PushImages ¶
PushImages push images from the local Docker host into the Cluster. If the specified image does not have a tag, `:latest` is assumed.