NAME

kube_test_minikube - Run a command against a throwaway minikube cluster

VERSION

version 1.108

SYNOPSIS

# Run this distribution's test suite against a live minikube cluster
kube_test_minikube prove -lr t/

# A single test file
kube_test_minikube perl t/05_api_operations.t

# Stop the cluster afterwards (delete it with --delete)
kube_test_minikube --stop prove -lr t/

# Tear down only
kube_test_minikube --stop
kube_test_minikube --delete

# No command: bring the cluster up and print the environment for eval
eval "$(kube_test_minikube)"

# An interactive shell with the environment exported
kube_test_minikube -- bash

# Pin versions, size the cluster, add a gate variable of your own
kube_test_minikube --minikube-version v1.38.1 -k v1.34.0 -c 4 -m 8g \
    -e TEST_MY_DIST_KUBECONFIG prove -lr t/

DESCRIPTION

kube_test_minikube is a test-cluster runner for the Kubernetes::REST family of distributions: Kubernetes::REST, Net::Async::Kubernetes, IO::K8s and Kubernetes-REST-Deprecated. Their test suites are mock-driven and skip the live tests unless a gate variable names a kubeconfig; this tool provides that kubeconfig. It

  1. makes sure a minikube binary is available - one on PATH is used as-is, otherwise a release is downloaded into a cache directory and verified against its published SHA-256 checksum before it is installed;

  2. brings up a minikube profile (default kube-rest-test, docker driver), skipping minikube start when the profile already reports a running host and API server;

  3. exports KUBECONFIG, TEST_KUBERNETES_REST_KUBECONFIG, TEST_IO_K8S_KUBECONFIG and every --env name, all pointing at the cluster's kubeconfig, and runs the command it was given.

The tool is deliberately generic: it knows nothing about the distribution it is run from, so the same invocation works in all four checkouts, and a distribution with a gate variable of its own passes it with --env.

Isolation

The cluster's kubeconfig is written to its own file (<install_dir>/<profile>.kubeconfig by default, see --kubeconfig), and every minikube invocation runs with KUBECONFIG pointing at it. The user's ~/.kube/config is never read or written, and the current context of any other cluster stays untouched.

Teardown

The cluster is left running by default, so the next run finds it up and skips the start - fast iteration is the point. --stop and --delete tear it down after the command; given without a command they only tear down. --delete also removes the kubeconfig file. Teardown never masks the command's exit status.

OPTIONS

Options come first; the command starts at the first argument that is not an option, or after --. Anything after that point is passed to the command untouched.

-p, --profile=NAME

minikube profile to use. Default: kube-rest-test.

-d, --driver=NAME

minikube driver, passed as --driver. Default: docker.

-k, --kubernetes-version=VERSION

Kubernetes version for the cluster, passed as --kubernetes-version to minikube start when set.

--minikube-version=VERSION

Pin the minikube release to download and use, as tagged upstream (v1.38.1). With a pin, a minikube on PATH is ignored and the binary in --install-dir is used only if it reports exactly that version. Default: the latest release.

-c, --cpus=N

CPUs for the cluster, passed as --cpus when set.

-m, --memory=SIZE

Memory for the cluster (4g, 4096mb, or megabytes), passed as --memory when set.

--install-dir=DIR

Where a downloaded minikube goes, and where the default kubeconfig lives. Default: $XDG_CACHE_HOME/kube_test_minikube, or ~/.cache/kube_test_minikube. When the binary in use comes from here the directory is also prepended to the command's PATH.

--kubeconfig=FILE

The isolated kubeconfig file. Default: <install_dir>/<profile>.kubeconfig.

-e, --env=NAME

Additional environment variable to set to the kubeconfig path. Repeatable.

--context=NAME

Also export TEST_KUBERNETES_REST_CONTEXT with this value. Not exported otherwise.

-s, --stop

Run minikube stop after the command, or only stop without a command.

-D, --delete

Run minikube delete after the command and remove the kubeconfig file, or only delete without a command. Wins over --stop.

-r, --restart

Run minikube start even when the profile is already running.

-v, --verbose

Print every minikube command line to STDERR before running it.

ENVIRONMENT

The command runs with these variables set, and without a command they are printed to STDOUT as export NAME='value' lines:

KUBECONFIG
TEST_KUBERNETES_REST_KUBECONFIG
TEST_IO_K8S_KUBECONFIG
every --env NAME

The absolute path of the cluster's kubeconfig file.

TEST_KUBERNETES_REST_CONTEXT

Only with --context, set to that value.

PATH

With the install directory prepended when the minikube in use was downloaded there.

Read by the tool itself: XDG_CACHE_HOME and HOME for the default install directory, PATH to find an existing minikube.

EXIT STATUS

The command's: its exit code, 128 plus the signal number when it died from a signal, or 127 when it could not be started. Teardown failures are reported on STDERR and do not change it. Without a command, 0 - or, with --stop or --delete, minikube's exit status. When minikube start fails the tool dies with a message naming the profile and driver and exits with minikube's exit code.

SEE ALSO

Kubernetes::REST::CLI::Minikube, Kubernetes::REST, kube_client, kube_watch

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/pplu/kubernetes-rest/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHORS

  • Torsten Raudssus <getty@cpan.org>

  • Jose Luis Martinez Torres <jlmartin@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019-2026 by Jose Luis Martinez Torres <jlmartin@cpan.org>.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004