Browse Source

Merge pull request #107 from ansibl8s/race_condition_api_master

Slowdown apimaster restart
pull/110/head 1.4.0
Antoine Legrand 8 years ago
parent
commit
cf472a6b4c
6 changed files with 29 additions and 27 deletions
  1. 1
      .travis.yml
  2. 2
      README.md
  3. 16
      roles/kubernetes/master/handlers/main.yml
  4. 8
      roles/kubernetes/master/tasks/main.yml
  5. 21
      roles/kubernetes/master/tasks/start.yml
  6. 8
      roles/network_plugin/tasks/calico.yml

1
.travis.yml

@ -9,7 +9,6 @@ addons:
env: env:
- SITE=cluster.yml ANSIBLE_VERSION=2.0.0 - SITE=cluster.yml ANSIBLE_VERSION=2.0.0
- SITE=cluster.yml ANSIBLE_VERSION=1.9.4
install: install:
# Install Ansible. # Install Ansible.

2
README.md

@ -19,7 +19,7 @@ Linux distributions tested:
* The firewalls are not managed, you'll need to implement your own rules the way you used to. * The firewalls are not managed, you'll need to implement your own rules the way you used to.
in order to avoid any issue during deployment you should **disable your firewall** in order to avoid any issue during deployment you should **disable your firewall**
* **Copy your ssh keys** to all the servers part of your inventory. * **Copy your ssh keys** to all the servers part of your inventory.
* **Ansible v1.9.x/v2.x and python-netaddr**
* **Ansible v2.x and python-netaddr**
* Base knowledge on Ansible. Please refer to [Ansible documentation](http://www.ansible.com/how-ansible-works) * Base knowledge on Ansible. Please refer to [Ansible documentation](http://www.ansible.com/how-ansible-works)
### Components ### Components

16
roles/kubernetes/master/handlers/main.yml

@ -1,16 +1,4 @@
--- ---
- name: restart kube-apiserver - name: restart kube-apiserver
command: /bin/true
notify:
- reload systemd
- reload kube-apiserver
- name: reload systemd
command: systemctl daemon-reload
when: init_system == "systemd"
- name: reload kube-apiserver
service:
name: kube-apiserver
state: restarted
set_fact:
restart_apimaster: True

8
roles/kubernetes/master/tasks/main.yml

@ -76,11 +76,9 @@
- meta: flush_handlers - meta: flush_handlers
- name: Enable apiserver
service:
name: kube-apiserver
enabled: yes
state: started
- include: start.yml
with_items: groups['kube-master']
when: "{{ hostvars[item].inventory_hostname == inventory_hostname }}"
# Create kube-system namespace # Create kube-system namespace
- name: copy 'kube-system' namespace manifest - name: copy 'kube-system' namespace manifest

21
roles/kubernetes/master/tasks/start.yml

@ -0,0 +1,21 @@
---
- name: Pause
pause: seconds=10
- name: reload systemd
command: systemctl daemon-reload
when: init_system == "systemd" and restart_apimaster is defined and restart_apimaster == True
- name: reload kube-apiserver
service:
name: kube-apiserver
state: restarted
enabled: yes
when: restart_apimaster is defined and restart_apimaster == True
- name: Enable apiserver
service:
name: kube-apiserver
enabled: yes
state: started
when: restart_apimaster is not defined or restart_apimaster == False

8
roles/network_plugin/tasks/calico.yml

@ -25,13 +25,11 @@
status_code: 200,404 status_code: 200,404
register: calico_conf register: calico_conf
run_once: true run_once: true
delegate_to: "{{ groups['etcd'][0] }}"
- name: Calico | Configure calico network pool - name: Calico | Configure calico network pool
shell: calicoctl pool add {{ kube_pods_subnet }} shell: calicoctl pool add {{ kube_pods_subnet }}
run_once: true run_once: true
when: calico_conf.status == 404 when: calico_conf.status == 404
delegate_to: "{{ groups['etcd'][0] }}"
- name: Calico | Get calico configuration from etcd - name: Calico | Get calico configuration from etcd
uri: uri:
@ -39,7 +37,6 @@
return_content: yes return_content: yes
register: calico_pools register: calico_pools
run_once: true run_once: true
delegate_to: "{{ groups['etcd'][0] }}"
- name: Calico | Check if calico pool is properly configured - name: Calico | Check if calico pool is properly configured
fail: fail:
@ -48,7 +45,6 @@
when: ( calico_pools.json['node']['nodes'] | length > 1 ) or when: ( calico_pools.json['node']['nodes'] | length > 1 ) or
( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") ) ( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") )
run_once: true run_once: true
delegate_to: "{{ groups['etcd'][0] }}"
- name: Calico | Write calico-node configuration - name: Calico | Write calico-node configuration
template: src=calico/calico.conf.j2 dest=/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico_kubernetes.ini template: src=calico/calico.conf.j2 dest=/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico_kubernetes.ini
@ -83,12 +79,12 @@
- name: Calico | Disable node mesh - name: Calico | Disable node mesh
shell: calicoctl bgp node-mesh off shell: calicoctl bgp node-mesh off
environment: environment:
ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
ETCD_AUTHORITY: "127.0.0.1:2379"
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node'] when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
- name: Calico | Configure peering with router(s) - name: Calico | Configure peering with router(s)
shell: calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }} shell: calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }}
environment: environment:
ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
ETCD_AUTHORITY: "127.0.0.1:2379"
with_items: peers with_items: peers
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node'] when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
Loading…
Cancel
Save