mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2024-10-29 07:49:37 +01:00
POC: Supporting k3s-ansible with external database (#339)
* POC: Supporting k3s-ansible with external database Signed-off-by: Peter Klijn <pjmklijn@gmail.com>
This commit is contained in:
parent
91ee70ee17
commit
31b8b1edcf
24
README.md
24
README.md
@ -63,6 +63,30 @@ Start provisioning of the cluster using the following command:
|
||||
ansible-playbook playbooks/site.yml -i inventory.yml
|
||||
```
|
||||
|
||||
### Using an external database
|
||||
|
||||
If an external database is preferred, this can be achieved by passing the `--datastore-endpoint` as an extra server argument as well as setting the `use_external_database` flag to true.
|
||||
|
||||
```bash
|
||||
k3s_cluster:
|
||||
children:
|
||||
server:
|
||||
hosts:
|
||||
192.16.35.11:
|
||||
192.16.35.12:
|
||||
agent:
|
||||
hosts:
|
||||
192.16.35.13:
|
||||
|
||||
vars:
|
||||
use_external_database: true
|
||||
extra_server_args: "--datastore-endpoint=postgres://username:password@hostname:port/database-name"
|
||||
```
|
||||
|
||||
The `use_external_database` flag is required when more than one server is defined, as otherwise an embedded etcd cluster will be created instead.
|
||||
|
||||
The format of the datastore-endpoint parameter is dependent upon the datastore backend, please visit the [K3s datastore endpoint format](https://docs.k3s.io/datastore#datastore-endpoint-format-and-functionality) for details on the format and supported datastores.
|
||||
|
||||
## Upgrading
|
||||
|
||||
A playbook is provided to upgrade K3s on all nodes in the cluster. To use it, update `k3s_version` with the desired version in `inventory.yml` and run:
|
||||
|
@ -7,3 +7,4 @@ user_kubectl: true # noqa var-naming[no-role-prefix]
|
||||
cluster_context: k3s-ansible # noqa var-naming[no-role-prefix]
|
||||
server_group: server # noqa var-naming[no-role-prefix]
|
||||
agent_group: agent # noqa var-naming[no-role-prefix]
|
||||
use_external_database: false # noqa var-naming[no-role-prefix]
|
||||
|
@ -58,7 +58,7 @@
|
||||
when: inventory_hostname == groups[server_group][0]
|
||||
block:
|
||||
- name: Copy K3s service file [Single]
|
||||
when: groups[server_group] | length == 1
|
||||
when: groups[server_group] | length == 1 or use_external_database
|
||||
ansible.builtin.template:
|
||||
src: "k3s-single.service.j2"
|
||||
dest: "{{ systemd_dir }}/k3s.service"
|
||||
@ -67,7 +67,9 @@
|
||||
mode: "0644"
|
||||
|
||||
- name: Copy K3s service file [HA]
|
||||
when: groups[server_group] | length > 1
|
||||
when:
|
||||
- groups[server_group] | length > 1
|
||||
- not use_external_database
|
||||
ansible.builtin.template:
|
||||
src: "k3s-cluster-init.service.j2"
|
||||
dest: "{{ systemd_dir }}/k3s.service"
|
||||
@ -148,7 +150,9 @@
|
||||
- inventory_hostname != groups[server_group][0]
|
||||
block:
|
||||
- name: Copy K3s service file [HA]
|
||||
when: groups[server_group] | length > 1
|
||||
when:
|
||||
- groups[server_group] | length > 1
|
||||
- not use_external_database
|
||||
ansible.builtin.template:
|
||||
src: "k3s-ha.service.j2"
|
||||
dest: "{{ systemd_dir }}/k3s.service"
|
||||
@ -156,6 +160,17 @@
|
||||
group: root
|
||||
mode: "0644"
|
||||
|
||||
- name: Copy K3s service file [External DB]
|
||||
when:
|
||||
- groups[server_group] | length > 1
|
||||
- use_external_database
|
||||
ansible.builtin.template:
|
||||
src: "k3s-single.service.j2"
|
||||
dest: "{{ systemd_dir }}/k3s.service"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
|
||||
- name: Enable and check K3s service
|
||||
ansible.builtin.systemd:
|
||||
name: k3s
|
||||
|
Loading…
Reference in New Issue
Block a user