Currently the rules_k8s e2e tests can only be run in a Linux environment. To be able to run the tests locally, it's required to set up minikube and docker. Minikube is a tool that enables running Kubernetes locally and docker allows to set up a local registry.
The main requirement to run the e2e tests is to use Linux. But for an easier setup, it's recommended to use an identical VM to the one for which this setup was tested.
If you are interested in using the same type of VM, then follow these instructions to create a Linux VM in the Google Compute Engine (GCE). Select the "Boot disk" to be of type "Google Drawfork Ubuntu 16.04 LTS" with at least 30GB of storage. Also switch to the root user to avoid setting all the required permissions that will be required in the next steps.
If you decide to use any other Linux machine, then first install the Google Cloud SDK as described here.
- Install Bazel.
- Install docker. This must be a version
supported by minikube and is not necessarily the latest available version. The
latest supported docker version by minikube can be found in the
Minikube Release Notes.
- Run a local registry.
- Confirm that the local registry works properly by following these steps.
- Make a note of the name of your local registry. If followed the setup
steps exactly as described, then this should be
localhost:5000
- Install kubectl.
- Install minikube.
- Run Kubernetes locally via minikube with the following command:
minikube start --vm-driver=none
- You can confirm that Kubernetes is running locally with
minikube status
- Clone the rules_k8s repo and make
the following code changes in the WORKSPACE file:
- Change the value of the
_CLUSTER
variable to
_CLUSTER = “minikube”
- Change the value of the
image_chroot
attribute in thek8s_object
andk8s_deploy
targets to start with the name of your local registry from step 2(iii)
image_chroot = “localhost:5000/rules_k8s”
- Change the value of the
From the project's root directory, run the test script
./test-e2e-local.sh
- When tests run locally they create (and when finished, delete) a namespace
called
build-0
. So be cautious when naming new namespaces inside the same local Kubernetes cluster used for local testing. - After running the e2e tests locally, it's expected that a few changes will be made to some files inside the project. This has no harm unless you decide to re-run the tests. Please undo the local changes created by the e2e tests run if you plan on re-running the tests.
- Running the e2e tests locally will consume a substantial amount of storage (∼20GB), so make sure you have enough space before running these tests.
Apologies for any inconveniences these caveats or prerequisites may cause you.