Rename Ansible playbook to `provision.yml` for consistency within the repository Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org> |
||
|---|---|---|
| .. | ||
| ansible.cfg | ||
| machines.yml | ||
| provision.yml | ||
| README.md | ||
| Vagrantfile | ||
Local Kubernetes Cluster with Kubeadm
These files were created to allow users to use Vagrant (http://www.vagrantup.com) quickly and relatively easily spin up a local Kubernetes cluster that is bootstrapped using kubeadm.
Contents
-
ansible.cfg: This Ansible configuration file configures Ansible for use with this Vagrant environment. No changes to this file should be necessary.
-
machines.yml: This YAML file contains a list of VM definitions. It is referenced by
Vagrantfilewhen Vagrant instantiates the VMs. You will need to edit this file to provide the correct Vagrant box names. Other edits should not be necessary. -
provision.yml: This Ansible playbook configures the VMs with the necessary package repositories, and installs the prerequisite packages. No changes to this file should be necessary.
-
README.md: This file you're currently reading.
-
Vagrantfile: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file.
Instructions
These instructions assume you've already installed your virtualization provider (VMware Fusion/Workstation or VirtualBox), Vagrant, and any necessary plugins (such as the Vagrant VMware plugin). Please refer to the documentation for those products for more information on installation or configuration.
-
Use
vagrant box addto install an Ubuntu 16.04 base box. Reviewmachines.ymlfor some suggested boxes for Libvirt, VirtualBox, and the VMware virtualization platforms. -
If the name of your Ubuntu 16.04 base box is not one of the ones listed in
machines.yml, editmachines.ymlto supply the correct box name(s). This file has separate lines for each provider; be sure to edit the correct line for your provider ("lv" is for Libvirt, "vb" is for VirtualBox, and "vmw" is for VMware). -
Place the files from the
kubernetes/kubeadm-vagrantdirectory of this GitHub repository into a directory on your local system. You can clone the entire "learning-tools" repository (usinggit clone) or just download the specific files from the thekubernetes/kubeadm-vagrantfolder. -
Run
vagrant upto instantiate 3 VMs---one manager and two nodes. All the VMs will be running Ubuntu 16.04. -
Once Vagrant is finished, use
vagrant ssh masterto log into the manager VM. -
While logged into "master", run the following command to start bootstrapping your Kubernetes cluster:
kubeadm init --apiserver-advertise-address 192.168.100.100 \ --feature-gates CoreDNS=true DynamicKubeletConfig=true \ SelfHosting=true --pod-network-cidr 172.24.0.0/16 -
When the command completes, follow the steps listed to install a configuration file for
kubelet. -
Copy the final output of the
kubeadm initcommand, which includes a token, to the clipboard. You'll need it later. -
Install a CNI plugin, such as Calico:
kubectl apply -f https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml -
Log out and run
vagrant ssh node-01to log into "node-01". Run thekubeadm joincommand you copied from the output on "master". -
Repeat step 10, but on "node-02".
Enjoy!