|
| 1 | +[[cluster-setup-vagrant]] |
| 2 | += Cluster Setup With Vagrant |
| 3 | +{product-author} |
| 4 | +{product-version} |
| 5 | +:data-uri: |
| 6 | +:icons: |
| 7 | + |
| 8 | +Vagrant is a tool for working with virtual environments, which usually means |
| 9 | +working with virtual machines. |
| 10 | + |
| 11 | +Vagrant can be used to quickly set up and run a single-node or multi-node |
| 12 | +cluster with the help of kubernetes. |
| 13 | + |
| 14 | + |
| 15 | +== Prerequisites |
| 16 | + |
| 17 | +* Ansible - to provision the cluster |
| 18 | +* Git - to clone the kubernetes contrib repository, containing the |
| 19 | +Vagrantfile we need |
| 20 | +* One of the following vagrant providers |
| 21 | +** https://libvirt.org[Libvirt] |
| 22 | +** https://www.virtualbox.org[VirtualBox] |
| 23 | +** https://github.com/ggiamarchi/vagrant-openstack-provider[OpenStack] |
| 24 | +** https://github.com/mitchellh/vagrant-aws[AWS] |
| 25 | +* Vagrant - to run vagrant commands |
| 26 | + |
| 27 | + |
| 28 | +== Single-Node Vagrant Example (QS) |
| 29 | + |
| 30 | +To get up and running with an atomic host cluster, run the following |
| 31 | +commands in your terminal: |
| 32 | + |
| 33 | +.... |
| 34 | +git clone https://github.com/kubernetes/contrib.git |
| 35 | +cd contrib/ansible/vagrant |
| 36 | +export OS_IMAGE=fedoraatomic # (alternativly this can be centosatomic) |
| 37 | +export NUM_NODES=1 |
| 38 | +vagrant up --no-provision --provider=libvirt # (virtualbox, openstack and aws are other provider options) |
| 39 | +vagrant provision kube-master-1 |
| 40 | +.... |
| 41 | + |
| 42 | + |
| 43 | +=== Optional providers |
| 44 | + |
| 45 | +If you are not using one or both of the openstack or aws providers and do |
| 46 | +not wish to install them, please comment out the |
| 47 | +`require 'vagrant-openstack-provider'` and/or |
| 48 | +`require 'vagrant-aws'` lines from `contrib/ansible/vagrant/Vagrantfile`. |
| 49 | + |
| 50 | + |
| 51 | +=== Testing it out |
| 52 | + |
| 53 | +Run `vagrant up`. |
| 54 | + |
| 55 | +Once the ansible playbook has finished running, you should have a single |
| 56 | +node cluster. |
| 57 | + |
| 58 | +Login using: |
| 59 | + |
| 60 | + vagrant ssh kube-master-1 |
| 61 | + |
| 62 | +And verify the cluster is up: |
| 63 | + |
| 64 | +.... |
| 65 | +[vagrant@kube-master-1 ~]$ kubectl cluster-info |
| 66 | +Kubernetes master is running at http://localhost:8080 |
| 67 | +Elasticsearch is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/elasticsearch-logging |
| 68 | +Heapster is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/heapster |
| 69 | +Kibana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kibana-logging |
| 70 | +KubeDNS is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kube-dns |
| 71 | +Grafana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana |
| 72 | +InfluxDB is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb |
| 73 | +
|
| 74 | +[vagrant@kube-master-1 ~]$ kubectl get nodes |
| 75 | +NAME LABELS STATUS AGE |
| 76 | +kube-node-1 kubernetes.io/hostname=kube-node-1 Ready 34m |
| 77 | +.... |
| 78 | + |
| 79 | + |
| 80 | +== Multi-Node Vagrant Example |
| 81 | + |
| 82 | +To run an N node multi-node cluster, where N is an integer value, |
| 83 | +`export NUM_NODES=N` before running the vagrant commands. For |
| 84 | +example to create a 4 node cluster: |
| 85 | + |
| 86 | +.... |
| 87 | +export NUM_NODES=4 |
| 88 | +vagrant up --no-provision --provider=libvirt # (virtualbox, openstack and aws are other provider options) |
| 89 | +vagrant provision kube-master-1 |
| 90 | +.... |
| 91 | + |
| 92 | + |
| 93 | +=== Testing it out |
| 94 | + |
| 95 | +Run `vagrant up`. |
| 96 | + |
| 97 | +Once the ansible playbook has finished running, you should have |
| 98 | +an N kube-node cluster. |
| 99 | + |
| 100 | +Login using: |
| 101 | + |
| 102 | + vagrant ssh kube-master-1 |
| 103 | + |
| 104 | +And verify the cluster is up: |
| 105 | + |
| 106 | +.... |
| 107 | +[vagrant@kube-master-1 ~]$ kubectl cluster-info |
| 108 | +Kubernetes master is running at http://localhost:8080 |
| 109 | +Elasticsearch is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/elasticsearch-logging |
| 110 | +Heapster is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/heapster |
| 111 | +Kibana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kibana-logging |
| 112 | +KubeDNS is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kube-dns |
| 113 | +Grafana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana |
| 114 | +InfluxDB is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb |
| 115 | +
|
| 116 | +[vagrant@kube-master-1 ~]$ kubectl get nodes |
| 117 | +NAME LABELS STATUS AGE |
| 118 | +kube-node-1 kubernetes.io/hostname=kube-node-1 Ready 34m |
| 119 | +kube-node-2 kubernetes.io/hostname=kube-node-2 Ready 34m |
| 120 | +kube-node-3 kubernetes.io/hostname=kube-node-3 Ready 34m |
| 121 | +kube-node-4 kubernetes.io/hostname=kube-node-4 Ready 34m |
| 122 | +.... |
0 commit comments