CoreOS + Kubernetes + Vagrant: Dev Environment Setup

Local Kubernetes installation

This post is a guide to installing a single-node kubernetes on your Ubuntu machine. As opposed to a vanilla kubernetes + virtualbox install, this install features:

  • CoreOS configured and ready to use
  • Local docker registry to cache kubernetes and docker images so that you don't have to download the Internet everytime you spin up a new VM

Step 1:

Install the following packages:

  • virtualbox
$ sudo apt-get install virtualbox
  • vagrant
$ sudo apt install vagrant
  • nfs-server (required to mount folders from host)
$ sudo apt install nfs-server
  • Install kubectl
$ wget
$ chmod +x kubectl
$ mv kubectl /usr/local/bin/   

After this you can start your own instance of virtualbox.

Step 2: Configure Vagrant

To run this VM you need a Vagrantfile and other configuration files. These can be found in this repo.

After cloning, go inside the vagrant folder and modify L64 of Vagrantfile to configure your local path (where the images will be persisted)

64: config.vm.synced_folder "/<path to your kubernetes_local_setup folder>/kubernetes_local_s...

Again, from the vagrant folder (in the cloned repo) and run the following command.

$ vagrant up

This starts our virtualbox VM, and the init script automatically starts downloading the required images and sets up Kubernetes.

Step 3: Configuring kubectl to interact to our kubernetes

From inside vagrant folder in the cloned repository, run the following commands:

$ export KUBECONFIG="${KUBECONFIG}:$(pwd)/kubeconfig"
$ kubectl config use-context vagrant-single


Read more posts by this author.

comments powered by Disqus