race condition in download role under vagrant

using a shared folder can cause race conditions for the download
role as it tries to download files on all the nodes to the same
shared path.  This adds a flag to run the tasks in the download
role on just one node.
This commit is contained in:
Paul Czarkowski 2016-05-17 23:30:01 -05:00
parent 5240465f39
commit ba615ff94e
4 changed files with 14 additions and 54 deletions

View file

@ -2,7 +2,7 @@
![Kubespray Logo](http://s9.postimg.org/md5dyjl67/kubespray_logoandkubespray_small.png) ![Kubespray Logo](http://s9.postimg.org/md5dyjl67/kubespray_logoandkubespray_small.png)
# Deploy a production ready kubernetes cluster ##Deploy a production ready kubernetes cluster
- Can be deployed on **AWS, GCE, OpenStack or Baremetal** - Can be deployed on **AWS, GCE, OpenStack or Baremetal**
- **High available** cluster - **High available** cluster
@ -10,61 +10,12 @@
- Support most popular **Linux distributions** - Support most popular **Linux distributions**
- **Continuous integration tests** - **Continuous integration tests**
# Getting Started
To deploy the cluster you can use : To deploy the cluster you can use :
## kargo-cli * [**kargo-cli**](https://github.com/kubespray/kargo-cli)
* **vagrant** by simply running `vagrant up`
[**kargo-cli**](https://github.com/kubespray/kargo-cli) * **Ansible** usual commands
## Vagrant
Assuming you have Vagrant (1.8+) installed with virtualbox (it may work
with vmware, but is untested) you should be able to launch a 3 node
Kubernetes cluster by simply running `$ vagrant up`.
This will spin up 3 VMs and install kubernetes on them. Once they are
completed you can connect to any of them by running
`$ vagrant ssh k8s-0[1..3]`.
```
$ vagrant up
Bringing machine 'k8s-01' up with 'virtualbox' provider...
Bringing machine 'k8s-02' up with 'virtualbox' provider...
Bringing machine 'k8s-03' up with 'virtualbox' provider...
==> k8s-01: Box 'bento/ubuntu-14.04' could not be found. Attempting to find and install...
...
...
k8s-03: Running ansible-playbook...
PLAY [k8s-cluster] *************************************************************
TASK [setup] *******************************************************************
ok: [k8s-03]
ok: [k8s-01]
ok: [k8s-02]
...
...
PLAY RECAP *********************************************************************
k8s-01 : ok=157 changed=66 unreachable=0 failed=0
k8s-02 : ok=137 changed=59 unreachable=0 failed=0
k8s-03 : ok=86 changed=51 unreachable=0 failed=0
$ vagrant ssh k8s-01
vagrant@k8s-01:~$ kubectl get nodes
NAME STATUS AGE
k8s-01 Ready 45s
k8s-02 Ready 45s
k8s-03 Ready 45s
```
## Ansible
**Ansible** usual commands
# Further Reading
A complete **documentation** can be found [**here**](https://docs.kubespray.io) A complete **documentation** can be found [**here**](https://docs.kubespray.io)

4
Vagrantfile vendored
View file

@ -79,7 +79,8 @@ Vagrant.configure("2") do |config|
"access_ip" => ip, "access_ip" => ip,
"flannel_interface" => ip, "flannel_interface" => ip,
"flannel_backend_type" => "host-gw", "flannel_backend_type" => "host-gw",
"local_release_dir" => "/vagrant/temp" "local_release_dir" => "/vagrant/temp",
"download_run_once" => "True"
} }
config.vm.network :private_network, ip: ip config.vm.network :private_network, ip: ip
@ -96,6 +97,7 @@ Vagrant.configure("2") do |config|
ansible.host_key_checking = false ansible.host_key_checking = false
ansible.raw_arguments = ["--forks=#{$num_instances}"] ansible.raw_arguments = ["--forks=#{$num_instances}"]
ansible.host_vars = host_vars ansible.host_vars = host_vars
#ansible.tags = ['download']
ansible.groups = { ansible.groups = {
# The first three nodes should be etcd servers # The first three nodes should be etcd servers
"etcd" => ["k8s-0[1:3]"], "etcd" => ["k8s-0[1:3]"],

View file

@ -1,6 +1,9 @@
--- ---
local_release_dir: /tmp local_release_dir: /tmp
# if this is set to true will only download files once
download_run_once: False
# Versions # Versions
kube_version: "v1.2.4" kube_version: "v1.2.4"
etcd_version: v2.2.5 etcd_version: v2.2.5

View file

@ -2,6 +2,7 @@
- name: Create dest directories - name: Create dest directories
file: path={{local_release_dir}}/{{item.dest|dirname}} state=directory recurse=yes file: path={{local_release_dir}}/{{item.dest|dirname}} state=directory recurse=yes
with_items: "{{ downloads }}" with_items: "{{ downloads }}"
run_once: "{{ download_run_once|bool }}"
- name: Download items - name: Download items
get_url: get_url:
@ -11,6 +12,7 @@
owner: "{{ item.owner|default(omit) }}" owner: "{{ item.owner|default(omit) }}"
mode: "{{ item.mode|default(omit) }}" mode: "{{ item.mode|default(omit) }}"
with_items: "{{ downloads }}" with_items: "{{ downloads }}"
run_once: "{{ download_run_once|bool }}"
- name: Extract archives - name: Extract archives
unarchive: unarchive:
@ -21,6 +23,7 @@
copy: no copy: no
when: "{{item.unarchive is defined and item.unarchive == True}}" when: "{{item.unarchive is defined and item.unarchive == True}}"
with_items: "{{ downloads }}" with_items: "{{ downloads }}"
run_once: "{{ download_run_once|bool }}"
- name: Fix permissions - name: Fix permissions
file: file:
@ -30,3 +33,4 @@
mode: "{{ item.mode|default(omit) }}" mode: "{{ item.mode|default(omit) }}"
when: "{{item.unarchive is not defined or item.unarchive == False}}" when: "{{item.unarchive is not defined or item.unarchive == False}}"
with_items: "{{ downloads }}" with_items: "{{ downloads }}"
run_once: "{{ download_run_once|bool }}"