Skip to content
Snippets Groups Projects
Select Git revision
  • be611059d4283d93749a7dc27fda5d5b417b6e6f
  • master default
2 results

kubernetes-vagrant

Name Last commit Last update
ansible
scripts
.gitignore
README.md
Vagrantfile

Kubernetes vagrant

This vagranfile was defined to support the local development of kubernetes multinode with ansible.

It create a management machine and a four node cluster of kubernetes (k8s), with two masters and two workers.

Prerequisites

In order to use this vagrantfile you need virtualbox and vagrant.

Notes

Here we define some particularities of this vagrantifle

  • the number of machines is specify inside the vagrantfile. If we adjust the number of machines, we should also adjust the ansible hosts.yaml acordingly.

How to create

To create the machine clone this repo, go into the folder and execute vagrant up.

git clone https://git.code.tecnalia.com/gorka.benguria/kubernetes-vagrant
cd kubernetes-vagrant
vagrant up

This will automatically start 5 virtual machines and install ansible in the management machine.

How to setup kubernetes

This vagrant does not setup kubernetes automatically as it is a testing playground for the kubernetes deployment. It contains a sequence of steps to be performed in order to deploy and test the kubernetes deployment.

Therefore in order to setup kubernetes we have to login into management machine and invoke some scripts that simulate the steps that we will require to do in a on premise environment.

vagrant ssh

once inside, we can start invoking the scripts.

cd /kubernetes-vagrant/ansible/
export ANSIBLE_CONFIG=/kubernetes-vagrant/ansible/ansible.cfg
echo this is not required with ansible 2.12 ./01_add_required_ansible_modules.sh
./02_hosts_from_inventory.sh
./03_upgrade.sh
./04_epel.sh
./05_development.sh
./06_check_macs_vagrant_eth1.sh
./07_install_kubernetes_kubeadm_docker.sh
echo inside the following script we can adjust the cidrs
./08_bootstrap_kubernetes_kubeadm.sh
./09_enable_kubectl_at_management.sh
./10_calico_network_kubernetes.sh
echo we can check that nodes become ready
kubectl get nodes
./11_kubernetes_dashboard.sh
./12_enable_helm_at_management.sh
echo inside the following script we can adjust the lb ip range
./13_install_metallb.sh
echo we should wait until the metallb controller gets ready, this may take even 5 minutes
kubectl get pod -A
echo once the metallb is ready we can use it for loadbalancer based services
kubectl create deployment nginx --image=nginx --port=80
kubectl expose deployment nginx --type=LoadBalancer --name=nginx-service
kubectl describe service nginx-service
curl http://192.168.56.200
./14_install_nginx_ingress.sh
echo we check the ingress status
kubectl get services -A
echo we test ingress
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web --type=NodePort --port=8080
curl -L https://k8s.io/examples/service/networking/example-ingress.yaml
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml
echo 192.168.56.201 hello-world.info | sudo tee -a /etc/hosts
curl http://hello-world.info