Vagrant project to spin up a cluster of 6 virtual machines with etcd v2.0.0, kubernetes v0.9.1.
- k8snode1 : etcd + kubernetes controller node
- k8snode2 : kubernetes minions
- k8snode3 : kubernetes minions
- k8snode4 : kubernetes minions
- k8snode5 : kubernetes minions
- k8snode6 : kubernetes minions
- Download and install VirtualBox
- Download and install Vagrant.
- Run
vagrant box add centos65 https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box
- Git clone this project, and change directory (cd) into this project (directory).
- Run
vagrant up
to create the VM. - Run
vagrant ssh
to get into your VM. The VM name in vagrant is k8snode1, k8snode2 ... k8snoden. While the ip of VMs depends on the scale of your kubernetes cluster. If it is less then 10, the IP will be 10.211.57.101, .... 10.211.57.10n. Or you could runssh
directly with ip of VMs and username/password of root/vagrant. - Run
vagrant destroy
when you want to destroy and get rid of the VM. - The directory of /vagrant is mounted in each VM by vagrant if you want to access host machine from VM. You could also use win-sshfs if you want to access the local file system of VM from host machine. Please refer to http://code.google.com/p/win-sshfs/ for details.
Some gotcha's.
- Make sure you download Vagrant v1.7.1 or higher and VirtualBox 4.3.20 or higher with extension package
- Make sure when you clone this project, you preserve the Unix/OSX end-of-line (EOL) characters. The scripts will fail with Windows EOL characters. If you are using Windows, please make sure the following configuration is configured in your .gitconfig file which is located in your home directory ("C:\Users\yourname" in Win7 and after, and "C:\Documents and Settings\yourname" in WinXP). Refer to http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration for details of git configuration.
[core]
autocrlf = false
safecrlf = true
- Make sure you have 10Gb of free memory for the VMs. You may change the Vagrantfile to specify smaller memory requirements.
- This project has NOT been tested with the other providers such as VMware for Vagrant.
- You may change the script (common.sh) to point to a different location for etcd, kubernetes to be downloaded from.
If you have the resources (CPU + Disk Space + Memory), you may modify Vagrantfile to have even more kubernetes minions. Just find the line that says "numNodes = 6" in Vagrantfile and increase that number. The scripts should dynamically provision the additional slaves for you.
You can make the VM setup even faster if you pre-download the etcd and kubernetes into the /resources directory.
- /resources/etcd-v2.0.0-linux-amd64.tar.gz
- /resources/kubernetes.tar.gz
The setup script will automatically detect if these files (with precisely the same names) exist and use them instead. If you are using slightly different versions, you will have to modify the script accordingly.
After you have provisioned the cluster, SSH into kubesnode1 and run the following command.
startk8s.sh
And then, SSH into other nodes and run the following command.
startk8sslave.sh
Run the following command to make sure etcd works
etcdctl --peers 10.211.57.101:4001 set key1 value1
Refer to https://github.com/coreos/etcd/blob/master/Documentation/admin_guide.md for more info of etcd
Run the following command to make sure kubernetes works
kubectl get minions
Refer to https://github.com/GoogleCloudPlatform/kubernetes/blob/master/examples/walkthrough/README.md for more info of kubernetes
Refer to http://weaveblog.com/2014/11/11/weave-for-kubernetes/ for how to configure weave for kubernetes