This guide will introduce you to bootstrapping a Kubernetes cluster on CoreOS with VirtualBox.

Requires 4 VM Instances

  • 1x Kubernetes Master
  • 3x Kubernetes Nodes

The meat of the installation is taken care of by a CoreOS tool called cloud config.

Cloud config is a configuration tool similar to cloud-init or a very basic implementation of a config mgmt tool. It’s what does the post install configurations that are defined in a yaml file. The cloud config files used in this guide will setup networking, configure etcd, set the ssh public key for the user ‘core’, and set the default password for the user ‘core’ to ‘coreos’, and install kubernetes.

Download the CoreOS ISO https://coreos.com/os/docs/latest/booting-with-iso.html

Create 4 VMs with the following instructions

  • Name them ‘coreos-x’ where x is a number between 1-4)
  • 1GB or more of RAM (CoreOS ISO won’t boot if less than 1GB RAM assigned)
  • x1 or more vCPU’s
  • x1 HD with 8GB’s or more
  • x2 NICS, One set as host-only (For internal/private cluster communication) and the other set as NAT (For internet access)

Note: NAT can have any network address just make sure DHCP is on

Host-only network info must be as follows

  • Network Address 192.168.122.0
  • Subnet Address 255.255.255.0
  • Default Gateway 192.168.122.1

Bootstrap a Master server

Using coreos-1 VM boot off the ISO image Download the Master server cloud config yaml file off a webserver (I used github gist)

core@master ~ $ sudo wget -O cloud-config.yaml http://git.io/vswiF

Verify your cloud config yaml is valid

core@master ~ $ sudo coreos-cloudinit -validate --from-file cloud-config.yaml

Start the CoreOS install

core@master ~ $ sudo coreos-install -d /dev/sda -c cloud-config.yml

Shutdown the VM and remove/detach the CD drive

Startup the VM after about 5-10 minutes Kubernetes Master will have been bootstrapped and you should see the following files in /opt/bin

core@master ~ $ ls -ailh /opt/bin
total 109M
521218 drwxr-xr-x 2 root root 4.0K Aug 23 02:45 .
521217 drwxr-xr-x 3 root root 4.0K Aug 23 02:43 ..
521222 -rwxr-xr-x 1 root root  39M Aug 23 02:44 kube-apiserver
521223 -rwxr-xr-x 1 root root  32M Aug 23 02:45 kube-controller-manager
521224 -rwxr-xr-x 1 root root  18M Aug 23 02:45 kube-scheduler
521220 -rw-r--r-- 1 root root 1.7K Aug 23 02:43 kube-serviceaccount.key
521225 -rwxr-xr-x 1 root root  20M Aug 23 02:45 kubectl
521221 -rwxr-xr-x 1 root root 2.0M Aug 23 02:43 setup-network-environment
521219 -rwxr-xr-x 1 root root  164 Aug 23 02:43 wupiao

You can now start using the kubectl client

Bootstrap the first Node server

Using coreos-2 VM boot off the ISO image Download the Node server cloud config yaml file off a webserver (I used github gist)

core@node01 ~ $ sudo wget -O cloud-config.yaml http://git.io/vswMW

Verify your cloud config yaml is valid

core@node01 ~ $ sudo coreos-cloudinit -validate --from-file cloud-config.yaml

Start the CoreOS install

core@node01 ~ $ sudo coreos-install -d /dev/sda -c cloud-config.yml

Shutdown the VM and remove/detach the CD drive Startup the VM after about 5-10 minutes Kubernetes Master will have been bootstrapped and you should see the following files in /opt/bin

core@node01 ~ $ ls -ailh /opt/bin/
total 73M
521218 drwxr-xr-x 2 root root 4.0K Aug 23 04:14 .
521217 drwxr-xr-x 3 root root 4.0K Aug 23 04:13 ..
521221 -rwxr-xr-x 1 root root  17M Aug 23 04:14 kube-proxy
521223 -rwxr-xr-x 1 root root  20M Aug 23 04:15 kubectl
521222 -rwxr-xr-x 1 root root  35M Aug 23 04:14 kubelet
521220 -rwxr-xr-x 1 root root 2.0M Aug 23 04:13 setup-network-environment
521219 -rwxr-xr-x 1 root root  209 Aug 23 04:13 wupiao

You can now start using the kubectl client

Try the kubectl get nodes command to view joined nodes on the master

core@node01 ~ $  kubectl get nodes
NAME       LABELS                            STATUS
10.0.2.9   kubernetes.io/hostname=10.0.2.9   Ready

Bootstrap the second Node server

Using coreos-3 VM boot off the ISO image Download the Node server cloud config yaml file off a webserver (I used github gist)

core@node02 ~ $ sudo wget -O cloud-config.yaml http://git.io/vswQZ

Verify your cloud config yaml is valid

core@node02 ~ $ sudo coreos-cloudinit -validate --from-file cloud-config.yaml

Start the CoreOS install

core@node02 ~ $ sudo coreos-install -d /dev/sda -c cloud-config.yml

Shutdown the VM and remove/detach the CD drive Startup the VM after about 5-10 minutes Kubernetes Master will have been bootstrapped and you should see the following files in /opt/bin

core@node02 ~ $  ls -ailh /opt/bin/
total 73M
521218 drwxr-xr-x 2 root root 4.0K Aug 23 04:14 .
521217 drwxr-xr-x 3 root root 4.0K Aug 23 04:13 ..
521221 -rwxr-xr-x 1 root root  17M Aug 23 04:14 kube-proxy
521223 -rwxr-xr-x 1 root root  20M Aug 23 04:15 kubectl
521222 -rwxr-xr-x 1 root root  35M Aug 23 04:14 kubelet
521220 -rwxr-xr-x 1 root root 2.0M Aug 23 04:13 setup-network-environment
521219 -rwxr-xr-x 1 root root  209 Aug 23 04:13 wupiao

You can now start using the kubectl client

Try the kubectl get nodes command to view joined nodes on the master

core@node02 ~ $ kubectl get nodes
NAME       LABELS                            STATUS
10.0.2.10   kubernetes.io/hostname=10.0.2.10   Ready

Bootstrap the third Node server

Using coreos-4 VM boot off the ISO image Download the Node server cloud config yaml file off a webserver (I used github gist)

core@node03 ~ $ sudo wget -O cloud-config.yaml http://git.io/vswQ8

Verify your cloud config yaml is valid

core@node03 ~ $ sudo coreos-cloudinit -validate --from-file cloud-config.yaml

Start the CoreOS install

core@node03 ~ $ sudo coreos-install -d /dev/sda -c cloud-config.yml

Shutdown the VM and remove/detach the CD drive Startup the VM after about 5-10 minutes Kubernetes Master will have been bootstrapped and you should see the following files in /opt/bin

core@node03 ~ $ ls -ailh /opt/bin/
total 73M
521218 drwxr-xr-x 2 root root 4.0K Aug 23 04:14 .
521217 drwxr-xr-x 3 root root 4.0K Aug 23 04:13 ..
521221 -rwxr-xr-x 1 root root  17M Aug 23 04:14 kube-proxy
521223 -rwxr-xr-x 1 root root  20M Aug 23 04:15 kubectl
521222 -rwxr-xr-x 1 root root  35M Aug 23 04:14 kubelet
521220 -rwxr-xr-x 1 root root 2.0M Aug 23 04:13 setup-network-environment
521219 -rwxr-xr-x 1 root root  209 Aug 23 04:13 wupiao

You can now start using the kubectl client

Try the kubectl get nodes command to view joined nodes on the master

core@node03 ~ $ kubectl get nodes
NAME       LABELS                            STATUS
10.0.2.9   kubernetes.io/hostname=10.0.2.9   Ready
10.0.2.10   kubernetes.io/hostname=10.0.2.10   Ready
10.0.2.11   kubernetes.io/hostname=10.0.2.11   Ready

Sources


Ryan Currah

An ordinary person trying to do some extraordinary things with technology.