One popular way to try out Kubernetes easily is Minikube: this utility bootstraps a turn-key single-node Kubernetes cluster locally on your computer, which is a very easy and straightforward way to get your hands on a Kubernetes cluster without too much hassle.
However, in order to use it you’ll need to run a hypervisor on your computer, which is not necessarily something you can or want – as it can use a lot of resources you can’t spare. If this requirement doesn’t suit you, you’ll be happy to hear about what’s coming next.
The latest release of the exo CLI introduces a new lab section containing experimental functionalities. The first of these functionalities is the kube
command that lets you to bootstrap a standalone Kubernetes cluster node very much like Minikube does – but running securely on Exoscale virtual machines.
Thanks to this command, you are able to play with a fully-functional Kubernetes cluster within minutes without installing anything other than the kubectl
command.
Your first cluster
Let’s first have a look at the CLI command – executing exo lab kube
will show you all available sub-commands. Our first step is to create a cluster instance, using the create
sub-command. Under the hood, it provisions a new Exoscale compute instance and installs all necessary software to run a standalone Kubernetes master node on it.
At this stage, you can optionally specify the size of the instance (--size
) in case you plan to run large experiments involving lots of containers.
Within a few minutes, you should end up with a similar output:
$ exo lab kube create 1ptikub
Creating private SSH key
Deploying "1ptikub" 100 % [======================================]
Bootstrapping Kubernetes cluster (can take up to several minutes):
Instance system upgrade: success
Docker Engine installation: success
Kubernetes cluster node installation: success
Kubernetes cluster node initialization: success
Your Kubernetes cluster is ready. What to do now?
1. Install the "kubectl" command, if you don't have it already:
https://kubernetes.io/docs/tasks/tools/
2. Execute the following command:
eval $(exo lab kube env "1ptikub")
You might want to persist this change by adding it to your shell startup
configuration (e.g. ~/.bashrc, ~/.zshrc).
3. Check that your cluster is reachable:
kubectl cluster-info
4. When you're done with your cluster, you can either:
* stop it using the "exo lab kube stop" command
* restart it later using the "exo lab kube start" command
* delete it permanently using the "exo lab kube delete" command
As instructed, the next step is to execute the eval $(exo lab kube env "kub")
command: this command sets up various environment variables so that you can use the kubectl
and docker
commands without having to specify any specific options.
To install the kubectl
command, follow the official documentation instructions according to your current platform; when you’re ready, check that you can actually reach the cluster:
$ eval $(exo lab kube env "1ptikub")
$ kubectl cluster-info
Kubernetes master is running at https://185.19.29.121:6443
KubeDNS is running at https://185.19.29.121:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
At this point, you’re free to explore your cluster. For example, you can list the nodes:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
1ptikub Ready master 6m v1.13.1
$ kubectl describe node 1ptikub
Name: 1ptikub
Roles: master
...
Now that your Kubernetes cluster is up and running, a good first step is to install the official web dashboard, as it offers a good bird’s eye view of your cluster.
Once you’re done playing with your cluster instance, you can either destroy it using the delete
command, or if you plan to come back to it soon you can stop the instance using the stop
and restart it later using the start
command.
You can list all your existing cluster instances with the list
command:
$ exo lab kube list
┼───────────┼─────────────────┼────────┼─────────┼─────────┼
│ NAME │ IP ADDRESS │ SIZE │ VERSION │ STATE │
┼───────────┼─────────────────┼────────┼─────────┼─────────┼
│ 1ptikub │ 185.19.29.121 │ Small │ 1.13.1 │ Running │
│ 1groskub │ 159.100.241.129 │ Medium │ 1.12 │ Stopped │
│ aperikub │ 185.19.29.192 │ Large │ 1.13.1 │ Running │
┼───────────┼─────────────────┼────────┼─────────┼─────────┼
A good use case: integration testing with Kubernetes
A good use case for the exo CLI kube
command is integration testing.
Say you run a production infrastructure featuring multiple micro-services and associated components (e.g. databases, caches, queues…): after describing your whole infrastructure as Kubernetes resources (i.e. deployments, services, ingress etc.) you could schedule a nightly integration test running the latest version of all your software components running in containers.
You may then use exo lab kube
commands to automate the Kubernetes cluster provisioning, trigger your test suite and destroy the instance once the tests are done.