This document discusses how to deploy a Kubernetes cluster locally using Kubespray and Ansible. It begins by introducing Kubespray and Ansible and explaining how they can be used together to deploy Kubernetes. Next, it provides instructions for installing the necessary tools like Vagrant and Ansible and cloning the Kubespray repository. It then walks through running vagrant up to deploy the Kubernetes cluster locally. The document also discusses how VirtualBox and Vagrant are used to automate and manage the virtual machines, and how Ansible deploys Kubernetes components to the machines. It concludes by demonstrating how to test the local Kubernetes cluster using kubectl.
1 of 18
Downloaded 14 times
More Related Content
Deploy High Availability Kubernetes with Kubespray
5. Install Ansible
# Ubuntu
apt-add-repository ppa:ansible/ansible
&& apt-get update
&& apt-get install -y python3 ansible
&& pip install netaddr
# Mac
pip install ansible
pip install netaddr
port install py27-netaddr # if youre using MacPort
# netaddr is required by Kubespray
6. Lets Get Started
clone https://github.com/kubernetes-incubator/kubespray.git
cd kubespray
vagrant up
# All done.
Lets get to more details while waiting.
(It takes about 20 mins on my Mac lol)
7. Virtualbox
? K8s runs on servers, and Virtualbox is our server
virtualizer
? Virtualbox come with GUI, but we dont use it because
? Clicking is time-consuming and engineers are lazy
? Bad for automation. Manual operation causes mistake.
? Lack of scalability. We can click 10 VMs but how about
100+ VMs.
8. Vagrant
? Kubespray provides vagrant for deploy K8s on VMs.
? Vagrant create you VMs with Vagrtantfile, a ruby based
script.
? A script is essential for automation.
? Vagrant bring VMs up & down within 1 command.
https://www.vagrantup.com/
10. What vagrant do?
? After vagrant up, vagrant create VMs with virtual box
? Vagrant also make necessary provisions to VMs
? Vagrant deploy k8s on to VMs with Kubespray
11. Vagrant & CICD
? Commit Vagrantfile to source code
? Bring VMs up & down
? Testing app on K8s and VMs
? Clean up VMs with vagrant
12. Ansible
? Ansible is a IT automation tools.
? Ansible-playbook is a script to modify remote servers
? Check components status on each step
? Come with lots of handy tools
(better than shell script)
13. Kubespray
? Deploy k8s with ansible-playbook
? Available on AWS, GCE, or baremetal
? High Available cluster
? Install K8s components to each servers
https://github.com/kubernetes-incubator/kubespray
16. Kubectl
? Kubectl is a k8s client tool to control k8s cluster
? Kubectl convert commands to API call to k8s cluster API
server
? Kubectl use authorized context
17. Deploy to Real Servers
? ansible-playbook
http://docs.ansible.com/ansible/latest/intro_installation.htm
l
? kubectl https://kubernetes.io/docs/tasks/tools/install-
kubectl/
? Check inventory/mycluster/hosts.ini
? playbook -i inventory/myCluster/hosts.ini cluster.yml