Configuring Kubernetes on Vagrant
One of the most frequent questions I see about setting up Kubernetes is how one can modify the configuration of a Vagrant/VirtualBox cluster. This, for example, is required to set up an insecure Docker registry or to use Kubernetes extensions like DaemonSets.
Running Kubernetes on Vagrant
Running Kubernetes on Vagrant is straightforward, and the directions for this are on the k8s.io site. The really short version goes like this:
- Go to the place where you installed Kubernetes
- Run a couple of commands
$ export KUBERNETES_PROVIDER=vagrant $ cluster/kube-up.sh
After several minutes (or more), you'll have a local 2-node Kubernetes cluster running.
Kubernetes is not tremendously consistent when it comes to modifying configuration. Configuration data is spread all over the place, and different clusters expose different configuration.
The Vagrant configuration is no exception. However, a number of configuration options are set in a file called
If you need to set up Docker to use an insecure registry or enable additional API server features like DaemonSets, this file defines the information that you need to modify.
However, instead of modifying the file, you should copy it and then set an additional environment variable:
$ cd cluster/vagrant $ cp config-default.sh config-mine.sh $ export KUBE_CONFIG_FILE=config-mine.sh
It is important to note that the config file is loaded relative to the
Editing the Configuration
With that done, we can now edit the
config-mine.sh configuration file. For example, to set an insecure registry, we could change the line that says this:
Or to enable DaemonSets, we could find the
RUNTIME_CONFIG and set it to this:
Note that any time you change this file, you will have to stop and start your cluster again using the