mirror of
https://codeberg.org/scottslowe/learning-tools.git
synced 2026-03-11 09:04:37 +00:00
Update kubeadm-Vagrant environment
Add Libvirt support to Vagrant data file. Update Vagrantfile to support Libvirt as a provider. Update and expand instructions in README.md. Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org>
This commit is contained in:
parent
99f1a3d73a
commit
224ea4e35c
3 changed files with 37 additions and 4 deletions
|
|
@ -4,8 +4,12 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co
|
|||
|
||||
## 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 `Vagrantfile` when 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.
|
||||
|
|
@ -14,16 +18,32 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co
|
|||
|
||||
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.
|
||||
|
||||
1. Use `vagrant box add` to install an Ubuntu 16.04 base box. Review `machines.yml` for some suggested boxes for both VirtualBox and VMware virtualization platforms.
|
||||
1. Use `vagrant box add` to install an Ubuntu 16.04 base box. Review `machines.yml` for some suggested boxes for Libvirt, VirtualBox, and the VMware virtualization platforms.
|
||||
|
||||
2. Place the files from the `kubernetes/kubeadm-vagrant` directory of this GitHub repository into a directory on your local system. You can clone the entire "learning-tools" repository (using `git clone`) or just download the specific files from the the `kubernetes/kubeadm-vagrant` folder.
|
||||
2. If the name of your Ubuntu 16.04 base box is _not_ one of the ones listed in `machines.yml`, edit `machines.yml` to 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).
|
||||
|
||||
3. If the name of your Ubuntu 16.04 base box is _not_ one of the ones listed in `machines.yml`, edit `machines.yml` to supply the correct box name(s). This file has separate lines for the VirtualBox and VMware providers; be sure to edit the correct line for your provider.
|
||||
3. Place the files from the `kubernetes/kubeadm-vagrant` directory of this GitHub repository into a directory on your local system. You can clone the entire "learning-tools" repository (using `git clone`) or just download the specific files from the the `kubernetes/kubeadm-vagrant` folder.
|
||||
|
||||
4. Run `vagrant up` to instantiate 3 VMs---one manager and two nodes. All the VMs will be running Ubuntu 16.04.
|
||||
|
||||
5. Once Vagrant is finished, use `vagrant ssh master` to log into the manager VM.
|
||||
|
||||
6.
|
||||
6. 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
|
||||
|
||||
7. When the command completes, follow the steps listed to install a configuration file for `kubelet`.
|
||||
|
||||
8. Copy the final output of the `kubeadm init` command, which includes a token, to the clipboard. You'll need it later.
|
||||
|
||||
9. 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
|
||||
|
||||
10. Log out and run `vagrant ssh node-01` to log into "node-01". Run the `kubeadm join` command you copied from the output on "master".
|
||||
|
||||
11. Repeat step 10, but on "node-02".
|
||||
|
||||
Enjoy!
|
||||
|
|
|
|||
10
kubernetes/kubeadm-vagrant/Vagrantfile
vendored
10
kubernetes/kubeadm-vagrant/Vagrantfile
vendored
|
|
@ -64,6 +64,16 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||
vb.cpus = machine['vcpu']
|
||||
override.vm.box = machine['box']['vb']
|
||||
end # srv.vm.provider 'virtualbox'
|
||||
|
||||
# Configure CPU & RAM per settings in machines.yml (Libvirt)
|
||||
srv.vm.provider 'libvirt' do |lv,override|
|
||||
lv.memory = machine['ram']
|
||||
lv.cpus = machine['vcpu']
|
||||
override.vm.box = machine['box']['lv']
|
||||
if machine['nested'] == true
|
||||
lv.nested = true
|
||||
end # if machine['nested']
|
||||
end # srv.vm.provider 'libvirt'
|
||||
end # config.vm.define
|
||||
end # machines.each
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
- box:
|
||||
vmw: "generic/ubuntu1604"
|
||||
vb: "ubuntu/xenial64"
|
||||
lv: "generic/ubuntu1604"
|
||||
name: "master"
|
||||
nics:
|
||||
- type: "private_network"
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
- box:
|
||||
vmw: "generic/ubuntu1604"
|
||||
vb: "ubuntu/xenial64"
|
||||
lv: "generic/ubuntu1604"
|
||||
name: "node-01"
|
||||
nics:
|
||||
- type: "private_network"
|
||||
|
|
@ -20,6 +22,7 @@
|
|||
- box:
|
||||
vmw: "generic/ubuntu1604"
|
||||
vb: "ubuntu/xenial64"
|
||||
lv: "generic/ubuntu1604"
|
||||
name: "node-02"
|
||||
nics:
|
||||
- type: "private_network"
|
||||
|
|
|
|||
Loading…
Reference in a new issue