Skip to content
Snippets Groups Projects
Commit a46d4efb authored by Antoine Legrand's avatar Antoine Legrand
Browse files

Merge pull request #156 from Smana/coreos_support

CoreOS support (Calico, Flannel, Weave)
parents ec64eda2 fca384e2
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
- defaults.yml - defaults.yml
paths: paths:
- ../vars - ../vars
skip: true
- name: Force binaries directory for CoreOS
set_fact:
bin_dir: "/opt/bin"
when: ansible_os_family == "CoreOS"
- name: Create kubernetes config directory - name: Create kubernetes config directory
file: file:
...@@ -85,8 +91,8 @@ ...@@ -85,8 +91,8 @@
module: "{{ ansible_pkg_mgr }}" module: "{{ ansible_pkg_mgr }}"
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
with_items: "{{required_pkgs | union(common_required_pkgs)}}" with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
when: ansible_os_family in [ "Debian", "RedHat" ] when: ansible_os_family != "CoreOS"
# Todo : selinux configuration # Todo : selinux configuration
- name: Set selinux policy to permissive - name: Set selinux policy to permissive
...@@ -95,6 +101,3 @@ ...@@ -95,6 +101,3 @@
changed_when: False changed_when: False
- include: etchosts.yml - include: etchosts.yml
- include: python-bootstrap.yml
when: ansible_os_family not in [ "Debian", "RedHat" ]
...@@ -8,13 +8,14 @@ ...@@ -8,13 +8,14 @@
mode: 0644 mode: 0644
notify: notify:
- restart docker - restart docker
when: ansible_os_family != "CoreOS"
- name: Calico | Write docker.service systemd file - name: Calico | Write docker.service systemd file
template: template:
src: systemd-docker.service src: systemd-docker.service
dest: /lib/systemd/system/docker.service dest: /lib/systemd/system/docker.service
notify: restart docker notify: restart docker
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
- meta: flush_handlers - meta: flush_handlers
...@@ -34,12 +35,6 @@ ...@@ -34,12 +35,6 @@
- name: Calico | install calicoctl - name: Calico | install calicoctl
file: path={{ bin_dir }}/calicoctl mode=0755 state=file file: path={{ bin_dir }}/calicoctl mode=0755 state=file
- name: Calico | Create calicoctl symlink (needed by kubelet)
file:
src: /usr/local/bin/calicoctl
dest: /usr/bin/calicoctl
state: link
- name: Calico | wait for etcd - name: Calico | wait for etcd
wait_for: wait_for:
port: 2379 port: 2379
...@@ -54,12 +49,12 @@ ...@@ -54,12 +49,12 @@
run_once: true run_once: true
- name: Calico | Configure calico network pool for cloud - name: Calico | Configure calico network pool for cloud
command: "calicoctl pool add {{ kube_pods_subnet }} --ipip --nat-outgoing" command: "{{ bin_dir }}/calicoctl pool add {{ kube_pods_subnet }} --ipip --nat-outgoing"
run_once: true run_once: true
when: calico_conf.status == 404 and cloud_provider is defined and cloud_provider == True when: calico_conf.status == 404 and cloud_provider is defined and cloud_provider == True
- name: Calico | Configure calico network pool - name: Calico | Configure calico network pool
command: "calicoctl pool add {{ kube_pods_subnet }}" command: "{{ bin_dir }}/calicoctl pool add {{ kube_pods_subnet }}"
run_once: true run_once: true
when: calico_conf.status == 404 and (cloud_provider is not defined or cloud_provider != True) when: calico_conf.status == 404 and (cloud_provider is not defined or cloud_provider != True)
...@@ -112,13 +107,13 @@ ...@@ -112,13 +107,13 @@
when: calico_copy.stdout_lines when: calico_copy.stdout_lines
- name: Calico | Disable node mesh - name: Calico | Disable node mesh
shell: calicoctl bgp node-mesh off shell: "{{ bin_dir }}/calicoctl bgp node-mesh off"
environment: environment:
ETCD_AUTHORITY: "127.0.0.1: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: "{{ bin_dir }}/calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }}"
environment: environment:
ETCD_AUTHORITY: "127.0.0.1:2379" ETCD_AUTHORITY: "127.0.0.1:2379"
with_items: peers with_items: peers
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
src: network.json src: network.json
dest: /etc/flannel-network.json dest: /etc/flannel-network.json
backup: yes backup: yes
- name: Flannel | Create flannel pod manifest - name: Flannel | Create flannel pod manifest
template: template:
src: flannel-pod.yml src: flannel-pod.yml
...@@ -15,6 +14,7 @@ ...@@ -15,6 +14,7 @@
wait_for: wait_for:
path: /run/flannel/subnet.env path: /run/flannel/subnet.env
delay: 5 delay: 5
timeout: 600
- name: Flannel | Get flannel_subnet from subnet.env - name: Flannel | Get flannel_subnet from subnet.env
shell: cat /run/flannel/subnet.env | awk -F'=' '$1 == "FLANNEL_SUBNET" {print $2}' shell: cat /run/flannel/subnet.env | awk -F'=' '$1 == "FLANNEL_SUBNET" {print $2}'
...@@ -42,11 +42,18 @@ ...@@ -42,11 +42,18 @@
notify: notify:
- restart docker - restart docker
- name: Flannel | Create docker config symlink for CoreOS
file:
src: "/etc/default/docker"
dest: "/run/flannel_docker_opts.env"
state: link
when: ansible_os_family == "CoreOS"
- name: Flannel | Write docker.service systemd file - name: Flannel | Write docker.service systemd file
template: template:
src: systemd-docker.service src: systemd-docker.service
dest: /lib/systemd/system/docker.service dest: /lib/systemd/system/docker.service
notify: restart docker notify: restart docker
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
- meta: flush_handlers - meta: flush_handlers
# Deployed by Ansible # Deployed by Ansible
{% if ansible_service_mgr in ["sysvinit","upstart"] and kube_network_plugin == "flannel" and ansible_os_family == "Debian" %} {% if (ansible_service_mgr in ["sysvinit","upstart"] and kube_network_plugin == "flannel" and ansible_os_family == "Debian") or
(kube_network_plugin == "flannel" and ansible_os_family == "CoreOS") %}
DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}" DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
{% elif kube_network_plugin == "flannel" %} {% elif kube_network_plugin == "flannel" %}
OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}" OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
src: systemd-docker.service src: systemd-docker.service
dest: /lib/systemd/system/docker.service dest: /lib/systemd/system/docker.service
notify: restart docker notify: restart docker
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
- meta: flush_handlers - meta: flush_handlers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment