mirror of https://github.com/k3s-io/k3s
Merge pull request #12036 from timothysc/ansible-ha-etcd
Add ha-etcd deployment for ansible.pull/6/head
commit
198119c206
|
@ -1,2 +1,3 @@
|
|||
myinventory
|
||||
inventory
|
||||
*.swp
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
---
|
||||
# This playbook deploys a kubernetes cluster
|
||||
# with the default addons.
|
||||
|
||||
- hosts: all
|
||||
gather_facts: false
|
||||
sudo: yes
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
[masters]
|
||||
kube-master-test-[1:3].example.com
|
||||
|
||||
[etcd:children]
|
||||
masters
|
||||
|
||||
[nodes]
|
||||
kube-minion-test-[1:2].example.com
|
|
@ -0,0 +1,36 @@
|
|||
Role Name
|
||||
=========
|
||||
|
||||
Configures an etcd cluster for an arbitrary number of hosts
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
TODO
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
None
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
- hosts: etcd
|
||||
roles:
|
||||
- { etcd }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
Scott Dodson <sdodson@redhat.com>, Tim St. Clair <tstclair@redhat.com>
|
||||
Adapted from https://github.com/retr0h/ansible-etcd. We
|
||||
should at some point submit a PR to merge this with that module.
|
||||
|
||||
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/ansible/roles/etcd/README.md?pixel)]()
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
etcd_client_port: 2379
|
||||
etcd_peer_port: 2380
|
||||
etcd_peers_group: etcd
|
||||
etcd_url_scheme: http
|
||||
etcd_peer_url_scheme: http
|
||||
etcd_conf_dir: /etc/etcd
|
||||
etcd_script_dir: /usr/libexec/etcd
|
||||
etcd_ca_file: "{{ etcd_conf_dir }}/ca.crt"
|
||||
etcd_cert_file: "{{ etcd_conf_dir }}/server.crt"
|
||||
etcd_key_file: "{{ etcd_conf_dir }}/server.key"
|
||||
etcd_peer_ca_file: "{{ etcd_conf_dir }}/ca.crt"
|
||||
etcd_peer_cert_file: "{{ etcd_conf_dir }}/peer.crt"
|
||||
etcd_peer_key_file: "{{ etcd_conf_dir }}/peer.key"
|
||||
|
||||
etcd_initial_cluster_state: new
|
||||
etcd_initial_cluster_token: etcd-k8-cluster
|
||||
|
||||
etcd_initial_advertise_peer_urls: "{{ etcd_peer_url_scheme }}://{{ ansible_fqdn }}:{{ etcd_peer_port }}"
|
||||
etcd_listen_peer_urls: "{{ etcd_peer_url_scheme }}://{{ ansible_fqdn }}:{{ etcd_peer_port }}"
|
||||
etcd_advertise_client_urls: "{{ etcd_url_scheme }}://{{ ansible_fqdn }}:{{ etcd_client_port }}"
|
||||
etcd_listen_client_urls: "{{ etcd_url_scheme }}://{{ ansible_fqdn }}:{{ etcd_client_port }}"
|
||||
|
||||
etcd_data_dir: /var/lib/etcd
|
||||
|
|
@ -1,5 +1,52 @@
|
|||
# etcd2.0
|
||||
{% macro initial_cluster() -%}
|
||||
{% for host in groups[etcd_peers_group] -%}
|
||||
{% if loop.last -%}
|
||||
{{ hostvars[host]['ansible_hostname'] }}={{ etcd_peer_url_scheme }}://{{ hostvars[host]['ansible_fqdn'] }}:{{ etcd_peer_port }}
|
||||
{%- else -%}
|
||||
{{ hostvars[host]['ansible_hostname'] }}={{ etcd_peer_url_scheme }}://{{ hostvars[host]['ansible_fqdn'] }}:{{ etcd_peer_port }},
|
||||
{%- endif -%}
|
||||
{% endfor -%}
|
||||
{% endmacro -%}
|
||||
|
||||
{% if groups[etcd_peers_group] and groups[etcd_peers_group] | length > 1 %}
|
||||
ETCD_NAME={{ ansible_hostname }}
|
||||
ETCD_LISTEN_PEER_URLS={{ etcd_listen_peer_urls }}
|
||||
{% else %}
|
||||
ETCD_NAME=default
|
||||
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
|
||||
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
|
||||
ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"
|
||||
{% endif %}
|
||||
ETCD_DATA_DIR={{ etcd_data_dir }}
|
||||
#ETCD_SNAPSHOT_COUNTER="10000"
|
||||
#ETCD_HEARTBEAT_INTERVAL="100"
|
||||
#ETCD_ELECTION_TIMEOUT="1000"
|
||||
ETCD_LISTEN_CLIENT_URLS={{ etcd_listen_client_urls }}
|
||||
#ETCD_MAX_SNAPSHOTS="5"
|
||||
#ETCD_MAX_WALS="5"
|
||||
#ETCD_CORS=""
|
||||
|
||||
{% if groups[etcd_peers_group] and groups[etcd_peers_group] | length > 1 %}
|
||||
#[cluster]
|
||||
ETCD_INITIAL_ADVERTISE_PEER_URLS={{ etcd_initial_advertise_peer_urls }}
|
||||
ETCD_INITIAL_CLUSTER={{ initial_cluster() }}
|
||||
ETCD_INITIAL_CLUSTER_STATE={{ etcd_initial_cluster_state }}
|
||||
ETCD_INITIAL_CLUSTER_TOKEN={{ etcd_initial_cluster_token }}
|
||||
#ETCD_DISCOVERY=""
|
||||
#ETCD_DISCOVERY_SRV=""
|
||||
#ETCD_DISCOVERY_FALLBACK="proxy"
|
||||
#ETCD_DISCOVERY_PROXY=""
|
||||
{% endif %}
|
||||
ETCD_ADVERTISE_CLIENT_URLS={{ etcd_advertise_client_urls }}
|
||||
|
||||
#[proxy]
|
||||
#ETCD_PROXY="off"
|
||||
|
||||
#[security]
|
||||
{% if etcd_url_scheme == 'https' -%}
|
||||
ETCD_CA_FILE={{ etcd_ca_file }}
|
||||
ETCD_CERT_FILE={{ etcd_cert_file }}
|
||||
ETCD_KEY_FILE={{ etcd_key_file }}
|
||||
{% endif -%}
|
||||
{% if etcd_peer_url_scheme == 'https' -%}
|
||||
ETCD_PEER_CA_FILE={{ etcd_peer_ca_file }}
|
||||
ETCD_PEER_CERT_FILE={{ etcd_peer_cert_file }}
|
||||
ETCD_PEER_KEY_FILE={{ etcd_peer_key_file }}
|
||||
{% endif -%}
|
||||
|
|
Loading…
Reference in New Issue