The Local Framework is used to run end to end and integration tests on Crossplane. The framework depends on a running instance of Kubernetes.
The framework also provides scripts for starting Kubernetes using minikube
so users can
quickly spin up a Kubernetes cluster.The Local framework is designed to install Crossplane, run tests, and uninstall Crossplane.
- Docker version => 1.2 && < 17.0
- Ubuntu 16, Fedora 29 (the framework has only been tested on these versions of linux distributions)
- Kubernetes with kubectl configured
- Crossplane
You can choose any Kubernetes flavor of your choice. The test framework only depends on kubectl being configured. The framework also provides scripts to install Kubernetes.
- Minikube (recommended for MacOS): Run minikube.sh to setup a single-node Minikube Kubernetes.
- Minikube v0.28.2 and higher is supported
- MicroK8s (recommended for Linux): Run microk8s.sh to setup a single-node Microk8s Kubernetes.
- MicroK8s v1.14 (move from dockerd to containerd) and higher is supported
Starting the cluster on Minikube is as simple as running:
cluster/local/minikube.sh up
To copy Crossplane image generated from your local build into the Minikube VM, run the following commands after minikube.sh up
succeeded:
cluster/local/minikube.sh helm-install
Stopping the cluster and destroying the Minikube VM can be done with:
cluster/local/minikube.sh clean
For complete list of subcommands supported by minikube.sh
, run:
cluster/local/minikube.sh
Starting the cluster on MicroK8s is as simple as running:
cluster/local/microk8s.sh up
To copy Crossplane image generated from your local build into the MicroK8s container registry, run the following commands after microk8s.sh up
succeeded:
cluster/local/microk8s.sh helm-install
Resetting the MicroK8s cluster can be done with:
cluster/local/microk8s.sh clean
Stopping the MicroK8s cluster can be done with:
cluster/local/microk8s.sh down
For complete list of subcommands supported by microk8s.sh
, run:
cluster/local/microk8s.sh
For convenience and speed of development, it can be a good option to run crossplane locally, out-of-cluster. To do that, there is a target in the Makefile:
make run
For preserving the logs, something like the following command could be used:
make run 2>&1 | tee -a local-log
If running crossplane locally out-of-cluster, it is important to make
sure crossplane is not also running in-cluster, because the two
crossplanes could interfere with each other. This can be done by either
deleting or scaling down the crossplane
deployment in the namespace
crossplane-system
.
The following sections provide commands helpful for development environments. minikube.sh
may be replaced with local.sh
or microk8s.sh
in those environments. These commands expect to be run from the project root.
make build
cluster/local/minikube.sh up
cluster/local/minikube.sh helm-install
Use kubectl
to create and/or delete external resources CRD's in your Minikube cluster
make test
cluster/local/minikube.sh helm-delete
cluster/local/minikube.sh down
In addition to the minikube.sh
tests described above which gives some flexibility on interacting with the cluster, one could also test the integration of the built artifacts with the cluster in a single command.
This will create a new Kubernetes cluster using kind
tool, and then installs Crossplane and checks a few assertions, and finally destructs the cluster.
make build
make e2e
This step is also included in CI workflow.