@@ -4,42 +4,54 @@ Running kubernetes with Vagrant (and VirtualBox) is an easy way to run/test/deve
...
@@ -4,42 +4,54 @@ Running kubernetes with Vagrant (and VirtualBox) is an easy way to run/test/deve
### Prerequisites
### Prerequisites
1. Install latest version >= 1.6.2 of vagrant from http://www.vagrantup.com/downloads.html
1. Install latest version >= 1.6.2 of vagrant from http://www.vagrantup.com/downloads.html
2. Install latest version of Virtual Box from https://www.virtualbox.org/wiki/Downloads
2. Install one of:
1. The latest version of Virtual Box from https://www.virtualbox.org/wiki/Downloads
2.[VMWare Fusion](https://www.vmware.com/products/fusion/) version 5 or greater as well as the appropriate [Vagrant VMWare Fusion provider](https://www.vagrantup.com/vmware)
3.[VMWare Workstation](https://www.vmware.com/products/workstation/) version 9 or greater as well as the [Vagrant VMWare Workstation provider](https://www.vagrantup.com/vmware)
4.[Parallels Desktop](https://www.parallels.com/products/desktop/) version 9 or greater as well as the [Vagrant Parallels provider](https://parallels.github.io/vagrant-parallels/)
3. Get or build a [binary release](../../getting-started-guides/binary_release.md)
3. Get or build a [binary release](../../getting-started-guides/binary_release.md)
### Setup
### Setup
By default, the Vagrant setup will create a single kubernetes-master and 1 kubernetes-minion. Each VM will take 1 GB, so make sure you have at least 2GB to 4GB of free memory (plus appropriate free disk space). To start your local cluster, open a shell and run:
By default, the Vagrant setup will create a single kubernetes-master and 1 kubernetes-minion. Each VM will take 1 GB, so make sure you have at least 2GB to 4GB of free memory (plus appropriate free disk space). To start your local cluster, open a shell and run:
```
```sh
cd kubernetes
cd kubernetes
export KUBERNETES_PROVIDER=vagrant
export KUBERNETES_PROVIDER=vagrant
cluster/kube-up.sh
./cluster/kube-up.sh
```
```
The `KUBERNETES_PROVIDER` environment variable tells all of the various cluster management scripts which variant to use. If you forget to set this, the assumption is you are running on Google Compute Engine.
The `KUBERNETES_PROVIDER` environment variable tells all of the various cluster management scripts which variant to use. If you forget to set this, the assumption is you are running on Google Compute Engine.
If you installed more than one Vagrant provider, Kubernetes will usually pick the appropriate one. However, you can override which one Kubernetes will use by setting the [`VAGRANT_DEFAULT_PROVIDER`](https://docs.vagrantup.com/v2/providers/default.html) environment variable:
```sh
export VAGRANT_DEFAULT_PROVIDER=parallels
export KUBERNETES_PROVIDER=vagrant
./cluster/kube-up.sh
```
Vagrant will provision each machine in the cluster with all the necessary components to run Kubernetes. The initial setup can take a few minutes to complete on each machine.
Vagrant will provision each machine in the cluster with all the necessary components to run Kubernetes. The initial setup can take a few minutes to complete on each machine.
By default, each VM in the cluster is running Fedora, and all of the Kubernetes services are installed into systemd.
By default, each VM in the cluster is running Fedora, and all of the Kubernetes services are installed into systemd.
To access the master or any minion:
To access the master or any minion:
```
```sh
vagrant ssh master
vagrant ssh master
vagrant ssh minion-1
vagrant ssh minion-1
```
```
If you are running more than one minion, you can access the others by:
If you are running more than one minion, you can access the others by:
```
```sh
vagrant ssh minion-2
vagrant ssh minion-2
vagrant ssh minion-3
vagrant ssh minion-3
```
```
To view the service status and/or logs on the kubernetes-master:
To view the service status and/or logs on the kubernetes-master:
```
```sh
vagrant ssh master
vagrant ssh master
[vagrant@kubernetes-master ~] $ sudo systemctl status kube-apiserver
[vagrant@kubernetes-master ~] $ sudo systemctl status kube-apiserver
With your Kubernetes cluster up, you can manage the nodes in your cluster with the regular Vagrant commands.
With your Kubernetes cluster up, you can manage the nodes in your cluster with the regular Vagrant commands.
To push updates to new Kubernetes code after making source changes:
To push updates to new Kubernetes code after making source changes:
```
```sh
cluster/kube-push.sh
./cluster/kube-push.sh
```
```
To stop and then restart the cluster:
To stop and then restart the cluster:
```
```sh
vagrant halt
vagrant halt
cluster/kube-up.sh
./cluster/kube-up.sh
```
```
To destroy the cluster:
To destroy the cluster:
```
```sh
vagrant destroy
vagrant destroy
```
```
...
@@ -84,14 +96,13 @@ Once your Vagrant machines are up and provisioned, the first thing to do is to c
...
@@ -84,14 +96,13 @@ Once your Vagrant machines are up and provisioned, the first thing to do is to c
You may need to build the binaries first, you can do this with ```make```
You may need to build the binaries first, you can do this with ```make```
```
```sh
$ ./cluster/kubectl.sh get minions
$ ./cluster/kubectl.sh get minions
NAME LABELS
NAME LABELS
10.245.1.4 <none>
10.245.1.4 <none>
10.245.1.5 <none>
10.245.1.5 <none>
10.245.1.3 <none>
10.245.1.3 <none>
```
```
### Interacting with your Kubernetes cluster with the `kube-*` scripts.
### Interacting with your Kubernetes cluster with the `kube-*` scripts.
...
@@ -100,39 +111,39 @@ Alternatively to using the vagrant commands, you can also use the `cluster/kube-
...
@@ -100,39 +111,39 @@ Alternatively to using the vagrant commands, you can also use the `cluster/kube-
All of these commands assume you have set `KUBERNETES_PROVIDER` appropriately:
All of these commands assume you have set `KUBERNETES_PROVIDER` appropriately:
```
```sh
export KUBERNETES_PROVIDER=vagrant
export KUBERNETES_PROVIDER=vagrant
```
```
Bring up a vagrant cluster
Bring up a vagrant cluster
```
```sh
cluster/kube-up.sh
./cluster/kube-up.sh
```
```
Destroy the vagrant cluster
Destroy the vagrant cluster
```
```sh
cluster/kube-down.sh
./cluster/kube-down.sh
```
```
Update the vagrant cluster after you make changes (only works when building your own releases locally):
Update the vagrant cluster after you make changes (only works when building your own releases locally):
```
```sh
cluster/kube-push.sh
./cluster/kube-push.sh
```
```
Interact with the cluster
Interact with the cluster
```
```sh
cluster/kubectl.sh
./cluster/kubectl.sh
```
```
### Authenticating with your master
### Authenticating with your master
When using the vagrant provider in Kubernetes, the `cluster/kubectl.sh` script will cache your credentials in a `~/.kubernetes_vagrant_auth` file so you will not be prompted for them in the future.
When using the vagrant provider in Kubernetes, the `cluster/kubectl.sh` script will cache your credentials in a `~/.kubernetes_vagrant_auth` file so you will not be prompted for them in the future.
#### I keep downloading the same (large) box all the time!
#### I keep downloading the same (large) box all the time!
By default the Vagrantfile will download the box from S3. You can change this (and cache the box locally) by providing an alternate URL when calling `kube-up.sh`
By default the Vagrantfile will download the box from S3. You can change this (and cache the box locally) by providing a name and an alternate URL when calling `kube-up.sh`
#### I just created the cluster, but I do not see my container running!
#### I just created the cluster, but I do not see my container running!
If this is your first time creating the cluster, the kubelet on each minion schedules a number of docker pull requests to fetch prerequisite images. This can take some time and as a result may delay your initial pod getting provisioned.
If this is your first time creating the cluster, the kubelet on each minion schedules a number of docker pull requests to fetch prerequisite images. This can take some time and as a result may delay your initial pod getting provisioned.
#### I changed Kubernetes code, but it's not running!
#### I changed Kubernetes code, but it's not running!
Are you sure there was no build error? After running `$ vagrant provision`, scroll up and ensure that each Salt state was completed successfully on each box in the cluster.
Are you sure there was no build error? After running `$ vagrant provision`, scroll up and ensure that each Salt state was completed successfully on each box in the cluster.
It's very likely you see a build error due to an error in your source files!
It's very likely you see a build error due to an error in your source files!
#### I have brought Vagrant up but the minions won't validate!
#### I have brought Vagrant up but the minions won't validate!
Are you sure you built a release first? Did you install `net-tools`? For more clues, login to one of the minions (`vagrant ssh minion-1`) and inspect the salt minion log (`sudo cat /var/log/salt/minion`).
Are you sure you built a release first? Did you install `net-tools`? For more clues, login to one of the minions (`vagrant ssh minion-1`) and inspect the salt minion log (`sudo cat /var/log/salt/minion`).
#### I want to change the number of minions!
#### I want to change the number of minions!
You can control the number of minions that are instantiated via the environment variable `NUM_MINIONS` on your host machine. If you plan to work with replicas, we strongly encourage you to work with enough minions to satisfy your largest intended replica size. If you do not plan to work with replicas, you can save some system resources by running with a single minion. You do this, by setting `NUM_MINIONS` to 1 like so:
You can control the number of minions that are instantiated via the environment variable `NUM_MINIONS` on your host machine. If you plan to work with replicas, we strongly encourage you to work with enough minions to satisfy your largest intended replica size. If you do not plan to work with replicas, you can save some system resources by running with a single minion. You do this, by setting `NUM_MINIONS` to 1 like so:
```
```sh
export NUM_MINIONS=1
export NUM_MINIONS=1
```
```
#### I want my VMs to have more memory!
#### I want my VMs to have more memory!
You can control the memory allotted to virtual machines with the `KUBERNETES_MEMORY` environment variable.
You can control the memory allotted to virtual machines with the `KUBERNETES_MEMORY` environment variable.
Just set it to the number of megabytes you would like the machines to have. For example:
Just set it to the number of megabytes you would like the machines to have. For example:
```
```sh
export KUBERNETES_MEMORY=2048
export KUBERNETES_MEMORY=2048
```
```
If you need more granular control, you can set the amount of memory for the master and minions independently. For example:
```sh
export KUBERNETES_MASTER_MEMORY=1536
export KUBERNETES_MASTER_MINION=2048
```
#### I ran vagrant suspend and nothing works!
#### I ran vagrant suspend and nothing works!
```vagrant suspend``` seems to mess up the network. It's not supported at this time.
```vagrant suspend``` seems to mess up the network. It's not supported at this time.
@@ -4,13 +4,17 @@ Running kubernetes with Vagrant (and VirtualBox) is an easy way to run/test/deve
...
@@ -4,13 +4,17 @@ Running kubernetes with Vagrant (and VirtualBox) is an easy way to run/test/deve
### Prerequisites
### Prerequisites
1. Install latest version >= 1.6.2 of vagrant from http://www.vagrantup.com/downloads.html
1. Install latest version >= 1.6.2 of vagrant from http://www.vagrantup.com/downloads.html
2. Install latest version of Virtual Box from https://www.virtualbox.org/wiki/Downloads
2. Install one of:
1. The latest version of Virtual Box from https://www.virtualbox.org/wiki/Downloads
2.[VMWare Fusion](https://www.vmware.com/products/fusion/) version 5 or greater as well as the appropriate [Vagrant VMWare Fusion provider](https://www.vagrantup.com/vmware)
3.[VMWare Workstation](https://www.vmware.com/products/workstation/) version 9 or greater as well as the [Vagrant VMWare Workstation provider](https://www.vagrantup.com/vmware)
4.[Parallels Desktop](https://www.parallels.com/products/desktop/) version 9 or greater as well as the [Vagrant Parallels provider](https://parallels.github.io/vagrant-parallels/)
### Setup
### Setup
Setting up a cluster is as simple as running:
Setting up a cluster is as simple as running:
```
```sh
export KUBERNETES_PROVIDER=vagrant
export KUBERNETES_PROVIDER=vagrant
curl -sS https://get.k8s.io | bash
curl -sS https://get.k8s.io | bash
```
```
...
@@ -19,33 +23,41 @@ The `KUBERNETES_PROVIDER` environment variable tells all of the various cluster
...
@@ -19,33 +23,41 @@ The `KUBERNETES_PROVIDER` environment variable tells all of the various cluster
By default, the Vagrant setup will create a single kubernetes-master and 1 kubernetes-minion. Each VM will take 1 GB, so make sure you have at least 2GB to 4GB of free memory (plus appropriate free disk space). To start your local cluster, open a shell and run:
By default, the Vagrant setup will create a single kubernetes-master and 1 kubernetes-minion. Each VM will take 1 GB, so make sure you have at least 2GB to 4GB of free memory (plus appropriate free disk space). To start your local cluster, open a shell and run:
```
```sh
cd kubernetes
cd kubernetes
export KUBERNETES_PROVIDER=vagrant
export KUBERNETES_PROVIDER=vagrant
cluster/kube-up.sh
./cluster/kube-up.sh
```
```
Vagrant will provision each machine in the cluster with all the necessary components to run Kubernetes. The initial setup can take a few minutes to complete on each machine.
Vagrant will provision each machine in the cluster with all the necessary components to run Kubernetes. The initial setup can take a few minutes to complete on each machine.
If you installed more than one Vagrant provider, Kubernetes will usually pick the appropriate one. However, you can override which one Kubernetes will use by setting the [`VAGRANT_DEFAULT_PROVIDER`](https://docs.vagrantup.com/v2/providers/default.html) environment variable:
```sh
export VAGRANT_DEFAULT_PROVIDER=parallels
export KUBERNETES_PROVIDER=vagrant
./cluster/kube-up.sh
```
By default, each VM in the cluster is running Fedora, and all of the Kubernetes services are installed into systemd.
By default, each VM in the cluster is running Fedora, and all of the Kubernetes services are installed into systemd.
To access the master or any minion:
To access the master or any minion:
```
```sh
vagrant ssh master
vagrant ssh master
vagrant ssh minion-1
vagrant ssh minion-1
```
```
If you are running more than one minion, you can access the others by:
If you are running more than one minion, you can access the others by:
```
```sh
vagrant ssh minion-2
vagrant ssh minion-2
vagrant ssh minion-3
vagrant ssh minion-3
```
```
To view the service status and/or logs on the kubernetes-master:
To view the service status and/or logs on the kubernetes-master:
```
```sh
vagrant ssh master
vagrant ssh master
[vagrant@kubernetes-master ~] $ sudo systemctl status kube-apiserver
[vagrant@kubernetes-master ~] $ sudo systemctl status kube-apiserver
With your Kubernetes cluster up, you can manage the nodes in your cluster with the regular Vagrant commands.
With your Kubernetes cluster up, you can manage the nodes in your cluster with the regular Vagrant commands.
To push updates to new Kubernetes code after making source changes:
To push updates to new Kubernetes code after making source changes:
```
```sh
cluster/kube-push.sh
./cluster/kube-push.sh
```
```
To stop and then restart the cluster:
To stop and then restart the cluster:
```
```sh
vagrant halt
vagrant halt
cluster/kube-up.sh
./cluster/kube-up.sh
```
```
To destroy the cluster:
To destroy the cluster:
```
```sh
vagrant destroy
vagrant destroy
```
```
...
@@ -90,14 +102,13 @@ Once your Vagrant machines are up and provisioned, the first thing to do is to c
...
@@ -90,14 +102,13 @@ Once your Vagrant machines are up and provisioned, the first thing to do is to c
You may need to build the binaries first, you can do this with ```make```
You may need to build the binaries first, you can do this with ```make```
```
```sh
$ ./cluster/kubectl.sh get minions
$ ./cluster/kubectl.sh get minions
NAME LABELS
NAME LABELS
10.245.1.4 <none>
10.245.1.4 <none>
10.245.1.5 <none>
10.245.1.5 <none>
10.245.1.3 <none>
10.245.1.3 <none>
```
```
### Interacting with your Kubernetes cluster with the `kube-*` scripts.
### Interacting with your Kubernetes cluster with the `kube-*` scripts.
...
@@ -106,39 +117,39 @@ Alternatively to using the vagrant commands, you can also use the `cluster/kube-
...
@@ -106,39 +117,39 @@ Alternatively to using the vagrant commands, you can also use the `cluster/kube-
All of these commands assume you have set `KUBERNETES_PROVIDER` appropriately:
All of these commands assume you have set `KUBERNETES_PROVIDER` appropriately:
```
```sh
export KUBERNETES_PROVIDER=vagrant
export KUBERNETES_PROVIDER=vagrant
```
```
Bring up a vagrant cluster
Bring up a vagrant cluster
```
```sh
cluster/kube-up.sh
./cluster/kube-up.sh
```
```
Destroy the vagrant cluster
Destroy the vagrant cluster
```
```sh
cluster/kube-down.sh
./cluster/kube-down.sh
```
```
Update the vagrant cluster after you make changes (only works when building your own releases locally):
Update the vagrant cluster after you make changes (only works when building your own releases locally):
```
```sh
cluster/kube-push.sh
./cluster/kube-push.sh
```
```
Interact with the cluster
Interact with the cluster
```
```sh
cluster/kubectl.sh
./cluster/kubectl.sh
```
```
### Authenticating with your master
### Authenticating with your master
When using the vagrant provider in Kubernetes, the `cluster/kubectl.sh` script will cache your credentials in a `~/.kubernetes_vagrant_auth` file so you will not be prompted for them in the future.
When using the vagrant provider in Kubernetes, the `cluster/kubectl.sh` script will cache your credentials in a `~/.kubernetes_vagrant_auth` file so you will not be prompted for them in the future.
#### I keep downloading the same (large) box all the time!
#### I keep downloading the same (large) box all the time!
By default the Vagrantfile will download the box from S3. You can change this (and cache the box locally) by providing an alternate URL when calling `kube-up.sh`
By default the Vagrantfile will download the box from S3. You can change this (and cache the box locally) by providing a name and an alternate URL when calling `kube-up.sh`
#### I just created the cluster, but I do not see my container running!
#### I just created the cluster, but I do not see my container running!
If this is your first time creating the cluster, the kubelet on each minion schedules a number of docker pull requests to fetch prerequisite images. This can take some time and as a result may delay your initial pod getting provisioned.
If this is your first time creating the cluster, the kubelet on each minion schedules a number of docker pull requests to fetch prerequisite images. This can take some time and as a result may delay your initial pod getting provisioned.
#### I want to make changes to Kubernetes code!
#### I want to make changes to Kubernetes code!
To set up a vagrant cluster for hacking, follow the [vagrant developer guide](../devel/developer-guides/vagrant.md).
To set up a vagrant cluster for hacking, follow the [vagrant developer guide](../devel/developer-guides/vagrant.md).
#### I have brought Vagrant up but the minions won't validate!
#### I have brought Vagrant up but the minions won't validate!
Log on to one of the minions (`vagrant ssh minion-1`) and inspect the salt minion log (`sudo cat /var/log/salt/minion`).
Log on to one of the minions (`vagrant ssh minion-1`) and inspect the salt minion log (`sudo cat /var/log/salt/minion`).
#### I want to change the number of minions!
#### I want to change the number of minions!
You can control the number of minions that are instantiated via the environment variable `NUM_MINIONS` on your host machine. If you plan to work with replicas, we strongly encourage you to work with enough minions to satisfy your largest intended replica size. If you do not plan to work with replicas, you can save some system resources by running with a single minion. You do this, by setting `NUM_MINIONS` to 1 like so:
You can control the number of minions that are instantiated via the environment variable `NUM_MINIONS` on your host machine. If you plan to work with replicas, we strongly encourage you to work with enough minions to satisfy your largest intended replica size. If you do not plan to work with replicas, you can save some system resources by running with a single minion. You do this, by setting `NUM_MINIONS` to 1 like so:
```
```sh
export NUM_MINIONS=1
export NUM_MINIONS=1
```
```
#### I want my VMs to have more memory!
#### I want my VMs to have more memory!
You can control the memory allotted to virtual machines with the `KUBERNETES_MEMORY` environment variable.
You can control the memory allotted to virtual machines with the `KUBERNETES_MEMORY` environment variable.
Just set it to the number of megabytes you would like the machines to have. For example:
Just set it to the number of megabytes you would like the machines to have. For example:
```
```sh
export KUBERNETES_MEMORY=2048
export KUBERNETES_MEMORY=2048
```
```
If you need more granular control, you can set the amount of memory for the master and minions independently. For example:
```sh
export KUBERNETES_MASTER_MEMORY=1536
export KUBERNETES_MASTER_MINION=2048
```
#### I ran vagrant suspend and nothing works!
#### I ran vagrant suspend and nothing works!
```vagrant suspend``` seems to mess up the network. It's not supported at this time.
```vagrant suspend``` seems to mess up the network. It's not supported at this time.