mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2025-01-21 11:30:21 +01:00
Added support for Etcd, removed DQLite support. See #41
This commit is contained in:
parent
c743df868b
commit
175b90ecb0
10 changed files with 59 additions and 13 deletions
|
@ -39,10 +39,10 @@ env:
|
|||
MOLECULE_SCENARIO: highavailability
|
||||
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_SCENARIO: highavailability
|
||||
MOLECULE_PLAYBOOK: playbook-dqlite.yml
|
||||
MOLECULE_PLAYBOOK: playbook-etcd.yml
|
||||
|
||||
install:
|
||||
# Install test dependencies.
|
||||
|
|
|
@ -95,7 +95,7 @@ consistency.
|
|||
| `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_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` |
|
||||
|
||||
#### 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
|
||||
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
|
||||
is done by setting `k3s_dqlite_datastore` to true. As this is an experimental
|
||||
Since K3s v1.19.1 it is possible to use Etcd as the backend database, and this
|
||||
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.
|
||||
|
||||
#### Important note about `k3s_flannel_interface`
|
||||
|
|
|
@ -53,8 +53,8 @@ k3s_datastore_endpoint: false
|
|||
# k3s_datastore_certfile: /path/to/cert.crt
|
||||
# k3s_datastore_keyfile: /path/to/key.pem
|
||||
|
||||
# Use DQLite for HA Datastore? (EXPERIMENTAL)
|
||||
k3s_dqlite_datastore: false
|
||||
# Use Etcd for HA Datastore? (EXPERIMENTAL)
|
||||
k3s_etcd_datastore: false
|
||||
|
||||
# HTTPS Listening port
|
||||
k3s_https_port: 6443
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
become: true
|
||||
vars:
|
||||
molecule_is_test: true
|
||||
k3s_release_version: v1.18.2+k3s1
|
||||
k3s_release_version: v1.18
|
||||
k3s_dqlite_datastore: true
|
||||
k3s_secrets_encryption: true
|
||||
k3s_use_experimental: true
|
||||
k3s_use_unsupported_config: true
|
||||
pre_tasks:
|
||||
- name: Set each node to be a control node
|
||||
set_fact:
|
||||
|
|
17
molecule/highavailability/playbook-etcd.yml
Normal file
17
molecule/highavailability/playbook-etcd.yml
Normal 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
|
|
@ -3,10 +3,15 @@
|
|||
- name: Ensure k3s is linked into the installation destination on the contol plane
|
||||
file:
|
||||
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' }}"
|
||||
force: "{{ k3s_install_hard_links }}"
|
||||
mode: 0755
|
||||
loop:
|
||||
- k3s
|
||||
- kubectl
|
||||
- crictl
|
||||
- ctr
|
||||
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
|
||||
notify:
|
||||
|
|
|
@ -8,4 +8,16 @@
|
|||
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)
|
||||
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)
|
||||
|
||||
- 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)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
- (k3s_controller_count | length == 1)
|
||||
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_etcd_datastore is not defined or not k3s_etcd_datastore)
|
||||
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."
|
||||
when: k3s_controller_count | length == 1
|
||||
|
@ -16,7 +17,8 @@
|
|||
that:
|
||||
- (k3s_controller_count | length >= 2)
|
||||
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."
|
||||
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
|
||||
|
|
|
@ -226,10 +226,19 @@
|
|||
assert:
|
||||
that:
|
||||
- (k3s_release_version | replace('v', '')) is version_compare('1.0.0', '>=')
|
||||
success_msg: "--cluster-init supported in {{ k3s_release_version }}"
|
||||
fail_msg: "--cluster-init not supported in {{ k3s_release_version }}"
|
||||
- (k3s_release_version | replace('v', '')) is version_compare('1.19.0', '<')
|
||||
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
|
||||
|
||||
- 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
|
||||
assert:
|
||||
that:
|
||||
|
|
|
@ -75,7 +75,7 @@ ExecStart={{ k3s_install_dir }}/k3s
|
|||
--datastore-keyfile {{ k3s_datastore_keyfile }}
|
||||
{% 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 %}
|
||||
--cluster-init
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in a new issue