Added support for Etcd, removed DQLite support. See #41

This commit is contained in:
Xan Manning 2020-09-17 21:01:20 +01:00
parent c743df868b
commit 175b90ecb0
10 changed files with 59 additions and 13 deletions

View file

@ -39,10 +39,10 @@ env:
MOLECULE_SCENARIO: highavailability MOLECULE_SCENARIO: highavailability
MOLECULE_PLAYBOOK: playbook-auto-deploying-manifests.yml MOLECULE_PLAYBOOK: playbook-auto-deploying-manifests.yml
# Test multiple masters in control plane with DQLite # Test multiple masters in control plane with Etcd
- MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest - MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest
MOLECULE_SCENARIO: highavailability MOLECULE_SCENARIO: highavailability
MOLECULE_PLAYBOOK: playbook-dqlite.yml MOLECULE_PLAYBOOK: playbook-etcd.yml
install: install:
# Install test dependencies. # Install test dependencies.

View file

@ -95,7 +95,7 @@ consistency.
| `k3s_become_for_package_install` | Enable become for installing prerequisite packages. | _NULL_ | | `k3s_become_for_package_install` | Enable become for installing prerequisite packages. | _NULL_ |
| `k3s_become_for_kubectl` | Enable become for kubectl commands. | _NULL_ | | `k3s_become_for_kubectl` | Enable become for kubectl commands. | _NULL_ |
| `k3s_become_for_uninstall` | Enable become for running uninstall scripts. | _NULL_ | | `k3s_become_for_uninstall` | Enable become for running uninstall scripts. | _NULL_ |
| `k3s_dqlite_datastore` | Use DQLite as the database backend for HA. (EXPERIMENTAL) | `false` | | `k3s_etcd_datastore` | Use Embedded Etcd as the database backend for HA. (EXPERIMENTAL) | `false` |
| `k3s_secrets_encryption` | Use secrets encryption at rest. (EXPERIMENTAL) | `false` | | `k3s_secrets_encryption` | Use secrets encryption at rest. (EXPERIMENTAL) | `false` |
#### Important note about `k3s_release_version` #### Important note about `k3s_release_version`
@ -238,8 +238,8 @@ It is also possible, though not supported, to run a single K3s master with a
`k3s_datastore_endpoint` defined. As this is not a typically supported `k3s_datastore_endpoint` defined. As this is not a typically supported
configuration you will need to set `k3s_use_unsupported_config` to `true`. configuration you will need to set `k3s_use_unsupported_config` to `true`.
Since K3s v1.0.0 it is possible to use DQLite as the backend database, and this Since K3s v1.19.1 it is possible to use Etcd as the backend database, and this
is done by setting `k3s_dqlite_datastore` to true. As this is an experimental is done by setting `k3s_etcd_datastore` to true. As this is an experimental
feature you will also need to set `k3s_use_experimental` to true. feature you will also need to set `k3s_use_experimental` to true.
#### Important note about `k3s_flannel_interface` #### Important note about `k3s_flannel_interface`

View file

@ -53,8 +53,8 @@ k3s_datastore_endpoint: false
# k3s_datastore_certfile: /path/to/cert.crt # k3s_datastore_certfile: /path/to/cert.crt
# k3s_datastore_keyfile: /path/to/key.pem # k3s_datastore_keyfile: /path/to/key.pem
# Use DQLite for HA Datastore? (EXPERIMENTAL) # Use Etcd for HA Datastore? (EXPERIMENTAL)
k3s_dqlite_datastore: false k3s_etcd_datastore: false
# HTTPS Listening port # HTTPS Listening port
k3s_https_port: 6443 k3s_https_port: 6443

View file

@ -4,10 +4,11 @@
become: true become: true
vars: vars:
molecule_is_test: true molecule_is_test: true
k3s_release_version: v1.18.2+k3s1 k3s_release_version: v1.18
k3s_dqlite_datastore: true k3s_dqlite_datastore: true
k3s_secrets_encryption: true k3s_secrets_encryption: true
k3s_use_experimental: true k3s_use_experimental: true
k3s_use_unsupported_config: true
pre_tasks: pre_tasks:
- name: Set each node to be a control node - name: Set each node to be a control node
set_fact: set_fact:

View file

@ -0,0 +1,17 @@
---
- name: Converge
hosts: node*
become: true
vars:
molecule_is_test: true
k3s_release_version: v1.19
k3s_etcd_datastore: true
k3s_secrets_encryption: true
k3s_use_experimental: true
pre_tasks:
- name: Set each node to be a control node
set_fact:
k3s_control_node: true
when: inventory_hostname in ['node2', 'node3']
roles:
- role: xanmanning.k3s

View file

@ -3,10 +3,15 @@
- name: Ensure k3s is linked into the installation destination on the contol plane - name: Ensure k3s is linked into the installation destination on the contol plane
file: file:
src: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}" src: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
dest: "{{ k3s_install_dir }}/k3s" dest: "{{ k3s_install_dir }}/{{ item }}"
state: "{{ 'hard' if k3s_install_hard_links else 'link' }}" state: "{{ 'hard' if k3s_install_hard_links else 'link' }}"
force: "{{ k3s_install_hard_links }}" force: "{{ k3s_install_hard_links }}"
mode: 0755 mode: 0755
loop:
- k3s
- kubectl
- crictl
- ctr
when: ((k3s_control_node and k3s_controller_count | length == 1) when: ((k3s_control_node and k3s_controller_count | length == 1)
or (k3s_primary_control_node and k3s_controller_count | length > 1)) and not ansible_check_mode or (k3s_primary_control_node and k3s_controller_count | length > 1)) and not ansible_check_mode
notify: notify:

View file

@ -8,4 +8,16 @@
fail_msg: "Experimental variables have been configured. If you want to use them ensure you set k3s_use_experimental" fail_msg: "Experimental variables have been configured. If you want to use them ensure you set k3s_use_experimental"
when: (k3s_non_root is defined and k3s_non_root) when: (k3s_non_root is defined and k3s_non_root)
or (k3s_dqlite_datastore is defined and k3s_dqlite_datastore) or (k3s_dqlite_datastore is defined and k3s_dqlite_datastore)
or (k3s_etcd_datastore is defined and k3s_etcd_datastore)
or (k3s_secrets_encryption is defined and k3s_secrets_encryption) or (k3s_secrets_encryption is defined and k3s_secrets_encryption)
- name: Check if experimental dqlite is being used and k3s_use_unsupported_config is configured
assert:
that:
- k3s_use_unsupported_config is defined and k3s_use_unsupported_config
success_msg: "Unsupported use of dqlite backend is enabled."
fail_msg: |
Embedded DQLite is no longer supported and there is no upgrade path to use Etcd!
If you're sure you want to use it set k3s_use_unsupported_config. This will break in v1.19!
when: k3s_use_experimental
and (k3s_dqlite_datastore is defined and k3s_dqlite_datastore)

View file

@ -6,6 +6,7 @@
- (k3s_controller_count | length == 1) - (k3s_controller_count | length == 1)
and (k3s_datastore_endpoint is not defined or not k3s_datastore_endpoint) and (k3s_datastore_endpoint is not defined or not k3s_datastore_endpoint)
and (k3s_dqlite_datastore is not defined or not k3s_dqlite_datastore) and (k3s_dqlite_datastore is not defined or not k3s_dqlite_datastore)
and (k3s_etcd_datastore is not defined or not k3s_etcd_datastore)
success_msg: "Control plane configuration is valid." success_msg: "Control plane configuration is valid."
fail_msg: "Control plane configuration is invalid. Please see notes about k3s_control_node and HA in README.md." fail_msg: "Control plane configuration is invalid. Please see notes about k3s_control_node and HA in README.md."
when: k3s_controller_count | length == 1 when: k3s_controller_count | length == 1
@ -16,7 +17,8 @@
that: that:
- (k3s_controller_count | length >= 2) - (k3s_controller_count | length >= 2)
and ((k3s_datastore_endpoint is defined and k3s_datastore_endpoint) and ((k3s_datastore_endpoint is defined and k3s_datastore_endpoint)
or k3s_dqlite_datastore is defined and k3s_dqlite_datastore) or (k3s_dqlite_datastore is defined and k3s_dqlite_datastore)
or (k3s_etcd_datastore is defined and k3s_etcd_datastore))
success_msg: "Control plane configuration is valid." success_msg: "Control plane configuration is valid."
fail_msg: "Control plane configuration is invalid. Please see notes about k3s_control_node and HA in README.md." fail_msg: "Control plane configuration is invalid. Please see notes about k3s_control_node and HA in README.md."
when: k3s_controller_count | length >= 2 when: k3s_controller_count | length >= 2

View file

@ -226,10 +226,19 @@
assert: assert:
that: that:
- (k3s_release_version | replace('v', '')) is version_compare('1.0.0', '>=') - (k3s_release_version | replace('v', '')) is version_compare('1.0.0', '>=')
success_msg: "--cluster-init supported in {{ k3s_release_version }}" - (k3s_release_version | replace('v', '')) is version_compare('1.19.0', '<')
fail_msg: "--cluster-init not supported in {{ k3s_release_version }}" success_msg: "--cluster-init (dqlite) supported in {{ k3s_release_version }}"
fail_msg: "--cluster-init (dqlite) not supported in {{ k3s_release_version }}"
when: k3s_dqlite_datastore is defined and k3s_dqlite_datastore when: k3s_dqlite_datastore is defined and k3s_dqlite_datastore
- name: Check k3s_etcd_datastore against k3s version
assert:
that:
- (k3s_release_version | replace('v', '')) is version_compare('1.19.1', '>=')
success_msg: "--cluster-init (etcd) supported in {{ k3s_release_version }}"
fail_msg: "--cluster-init (etcd) not supported in {{ k3s_release_version }}"
when: k3s_etcd_datastore is defined and k3s_etcd_datastore
- name: Check k3s_datastore_cafile against k3s version - name: Check k3s_datastore_cafile against k3s version
assert: assert:
that: that:

View file

@ -75,7 +75,7 @@ ExecStart={{ k3s_install_dir }}/k3s
--datastore-keyfile {{ k3s_datastore_keyfile }} --datastore-keyfile {{ k3s_datastore_keyfile }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if k3s_dqlite_datastore is defined and k3s_dqlite_datastore %} {% if (k3s_dqlite_datastore is defined and k3s_dqlite_datastore) or (k3s_etcd_datastore is defined and k3s_etcd_datastore) %}
{% if k3s_primary_control_node is defined and k3s_primary_control_node %} {% if k3s_primary_control_node is defined and k3s_primary_control_node %}
--cluster-init --cluster-init
{% else %} {% else %}