Browse Source
Etcd cluster setup makeover
Etcd cluster setup makeover
The current way to setup the etc cluster is messy and buggy. - It checks for cluster is healthy before the cluster is even created. - The unit files are started on handlers, not in the task, so you mess with "flush handlers". - The join_member.yml is not used. - etcd events cluster is not configured for kubeadm - remove duplicate runs between running the role on etcd nodes and k8s nodespull/2577/head
woopstar
6 years ago
committed by
Andreas Kruger
15 changed files with 129 additions and 166 deletions
Split View
Diff Options
-
4cluster.yml
-
1roles/etcd/defaults/main.yml
-
5roles/etcd/handlers/main.yml
-
115roles/etcd/tasks/configure.yml
-
17roles/etcd/tasks/gen_certs_script.yml
-
8roles/etcd/tasks/install_docker.yml
-
1roles/etcd/tasks/install_host.yml
-
2roles/etcd/tasks/install_rkt.yml
-
13roles/etcd/tasks/join_etcd-events_member.yml
-
15roles/etcd/tasks/join_etcd_member.yml
-
47roles/etcd/tasks/join_member.yml
-
36roles/etcd/tasks/main.yml
-
2roles/etcd/tasks/refresh_config.yml
-
26roles/etcd/tasks/set_cluster_health.yml
-
3roles/kubernetes/master/templates/kubeadm-config.yaml.j2
@ -1,47 +0,0 @@ |
|||
--- |
|||
- name: Join Member | Add member to cluster |
|||
shell: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_access_addresses }} member add {{ etcd_member_name }} {{ etcd_peer_url }}" |
|||
register: member_add_result |
|||
until: member_add_result.rc == 0 |
|||
retries: 4 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
when: target_node == inventory_hostname |
|||
environment: |
|||
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem" |
|||
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem" |
|||
|
|||
- include_tasks: refresh_config.yml |
|||
vars: |
|||
etcd_peer_addresses: >- |
|||
{% for host in groups['etcd'] -%} |
|||
{%- if hostvars[host]['etcd_member_in_cluster'].rc == 0 -%} |
|||
{{ "etcd"+loop.index|string }}=https://{{ hostvars[host].access_ip | default(hostvars[host].ip | default(hostvars[host].ansible_default_ipv4['address'])) }}:2380, |
|||
{%- endif -%} |
|||
{%- if loop.last -%} |
|||
{{ etcd_member_name }}={{ etcd_peer_url }} |
|||
{%- endif -%} |
|||
{%- endfor -%} |
|||
when: target_node == inventory_hostname |
|||
|
|||
- name: Join Member | reload systemd |
|||
command: systemctl daemon-reload |
|||
when: target_node == inventory_hostname |
|||
|
|||
- name: Join Member | Ensure etcd is running |
|||
service: |
|||
name: etcd |
|||
state: started |
|||
enabled: yes |
|||
when: target_node == inventory_hostname |
|||
|
|||
- name: Join Member | Ensure member is in cluster |
|||
shell: "{{ bin_dir }}/etcdctl --no-sync --endpoints={{ etcd_access_addresses }} member list | grep -q {{ etcd_access_address }}" |
|||
register: etcd_member_in_cluster |
|||
changed_when: false |
|||
check_mode: no |
|||
tags: |
|||
- facts |
|||
when: target_node == inventory_hostname |
|||
environment: |
|||
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem" |
|||
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem" |
@ -1,26 +0,0 @@ |
|||
--- |
|||
- name: Configure | Check if etcd cluster is healthy |
|||
shell: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_access_addresses }} cluster-health | grep -q 'cluster is healthy'" |
|||
register: etcd_cluster_is_healthy |
|||
ignore_errors: true |
|||
changed_when: false |
|||
check_mode: no |
|||
when: is_etcd_master |
|||
tags: |
|||
- facts |
|||
environment: |
|||
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem" |
|||
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem" |
|||
|
|||
- name: Configure | Check if etcd-events cluster is healthy |
|||
shell: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_events_access_addresses }} cluster-health | grep -q 'cluster is healthy'" |
|||
register: etcd_events_cluster_is_healthy |
|||
ignore_errors: true |
|||
changed_when: false |
|||
check_mode: no |
|||
when: is_etcd_master and etcd_events_cluster_setup |
|||
tags: |
|||
- facts |
|||
environment: |
|||
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem" |
|||
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem" |
Write
Preview
Loading…
Cancel
Save