mirror of https://github.com/k3s-io/k3s
Set up flannel in your cluster!
parent
bc6c425ab4
commit
a95243450e
|
@ -47,4 +47,8 @@ Only the kubernetes nodes:
|
|||
|
||||
`INVENTORY=myinventory ./setup.sh`
|
||||
|
||||
Only flannel:
|
||||
|
||||
$ ./setup.sh --tags=flannel
|
||||
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/ansible/README.md?pixel)]()
|
||||
|
|
|
@ -8,6 +8,17 @@
|
|||
tags:
|
||||
- etcd
|
||||
|
||||
# install flannel
|
||||
- hosts:
|
||||
- etcd
|
||||
- masters
|
||||
- nodes
|
||||
sudo: yes
|
||||
roles:
|
||||
- flannel
|
||||
tags:
|
||||
- flannel
|
||||
|
||||
# install kube master services
|
||||
- hosts: masters
|
||||
sudo: yes
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# Only used for the location to store flannel info in etcd, but may be used
|
||||
# for dns purposes and cluster id purposes in the future.
|
||||
cluster_name: kube.local
|
||||
|
||||
# Account name of remote user. Ansible will use this user account to ssh into
|
||||
# the managed machines. The user must be able to use sudo without asking
|
||||
# for password unless ansible_sudo_pass is set
|
||||
|
@ -15,3 +19,18 @@ ansible_ssh_user: root
|
|||
# This range must not conflict with anything in your infrastructure. These
|
||||
# addresses do not need to be routable and must just be an unused block of space.
|
||||
kube_service_addresses: 10.254.0.0/16
|
||||
|
||||
# Flannel internal network (optional). When flannel is used, it will assign IP
|
||||
# addresses from this range to individual pods.
|
||||
# This network must be unused in your network infrastructure!
|
||||
flannel_subnet: 172.16.0.0
|
||||
|
||||
# Flannel internal network total size (optional). This is the prefix of the
|
||||
# entire flannel overlay network. So the entirety of 172.16.0.0/12 must be
|
||||
# unused in your environment.
|
||||
flannel_prefix: 12
|
||||
|
||||
# Flannel internal network (optional). This is the size allocation that flannel
|
||||
# will give to each node on your network. With these defaults you should have
|
||||
# room for 4096 nodes with 254 pods per node.
|
||||
flannel_host_prefix: 24
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- name: restart flannel
|
||||
service: name=flanneld state=restarted
|
||||
notify:
|
||||
- stop docker
|
||||
- delete docker0
|
||||
- start docker
|
||||
when: inventory_hostname in groups['nodes']
|
||||
|
||||
- name: stop docker
|
||||
service: name=docker state=stopped
|
||||
|
||||
- name: delete docker0
|
||||
command: ip link delete docker0
|
||||
ignore_errors: yes
|
||||
|
||||
- name: start docker
|
||||
service: name=docker state=started
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- { role: common }
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: Install flannel
|
||||
action: "{{ ansible_pkg_mgr }}"
|
||||
args:
|
||||
name: flannel
|
||||
state: latest
|
||||
when: not is_atomic
|
||||
|
||||
- name: Install Flannel config file
|
||||
template: src=flanneld.j2 dest=/etc/sysconfig/flanneld
|
||||
notify:
|
||||
- restart flannel
|
||||
|
||||
- name: Launch Flannel
|
||||
service: name=flanneld state=started enabled=yes
|
||||
notify:
|
||||
- restart flannel
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: Set facts about etcdctl command
|
||||
set_fact:
|
||||
peers: "{% for hostname in groups['etcd'] %}http://{{ hostname }}:2379{% if not loop.last %},{% endif %}{% endfor %}"
|
||||
conf_file: "/tmp/flannel-conf.json"
|
||||
conf_loc: "/{{ cluster_name }}/network/config"
|
||||
run_once: true
|
||||
delegate_to: "{{ groups['etcd'][0] }}"
|
||||
|
||||
- name: Create flannel config file to go in etcd
|
||||
template: src=flannel-conf.json.j2 dest={{ conf_file }}
|
||||
run_once: true
|
||||
delegate_to: "{{ groups['etcd'][0] }}"
|
||||
|
||||
- name: Load the flannel config file into etcd
|
||||
shell: "/usr/bin/etcdctl --no-sync --peers={{ peers }} set {{ conf_loc }} < {{ conf_file }}"
|
||||
run_once: true
|
||||
delegate_to: "{{ groups['etcd'][0] }}"
|
||||
|
||||
- name: Clean up the flannel config file
|
||||
file: path=/tmp/flannel-config.json state=absent
|
||||
run_once: true
|
||||
delegate_to: "{{ groups['etcd'][0] }}"
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- include: config.yml
|
||||
|
||||
- include: client.yml
|
||||
when: inventory_hostname in groups['masters'] + groups['nodes']
|
|
@ -0,0 +1 @@
|
|||
{ "Network": "{{ flannel_subnet }}/{{ flannel_prefix }}", "SubnetLen": {{ flannel_host_prefix }}, "Backend": { "Type": "vxlan" } }
|
|
@ -0,0 +1,11 @@
|
|||
# Flanneld configuration options
|
||||
|
||||
# etcd url location. Point this to the server where etcd runs
|
||||
FLANNEL_ETCD="http://{{ groups['etcd'][0] }}:2379"
|
||||
|
||||
# etcd config key. This is the configuration key that flannel queries
|
||||
# For address range assignment
|
||||
FLANNEL_ETCD_KEY="/{{ cluster_name }}/network"
|
||||
|
||||
# Any additional options that you want to pass
|
||||
#FLANNEL_OPTIONS=""
|
Loading…
Reference in New Issue