mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2024-11-05 13:23:30 +01:00
Merge pull request #5 from nolte/feature/add_manifests
Add Support for Auto-Deploying Manifests
This commit is contained in:
commit
c8fb27ecd1
7 changed files with 57 additions and 13 deletions
|
@ -35,6 +35,10 @@ env:
|
|||
- MOLECULE_DISTRO: geerlingguy/docker-fedora31-ansible:latest
|
||||
MOLECULE_PLAYBOOK: playbook-no-deploy.yml
|
||||
|
||||
# Test auto deploying manifests
|
||||
- MOLECULE_DISTRO: geerlingguy/docker-ubuntu1804-ansible:latest
|
||||
MOLECULE_PLAYBOOK: playbook-auto-deploying-manifests.yml
|
||||
|
||||
# Test multiple masters in control plane with PostgreSQL
|
||||
- MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest
|
||||
MOLECULE_SCENARIO: highavailability
|
||||
|
|
29
README.md
29
README.md
|
@ -112,19 +112,22 @@ Please note that this may potentially break setting up agents.
|
|||
|
||||
Below are variables that are set against specific hosts in your inventory.
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
|-----------------------------|--------------------------------------------------------------------------|------------------------|
|
||||
| `k3s_control_node` | Define the host as a control plane node, (True/False). | `false` |
|
||||
| `k3s_node_name` | Define the name of this node. | `$(hostname)` |
|
||||
| `k3s_node_id` | Define the ID of this node. | _NULL_ |
|
||||
| `k3s_flannel_interface` | Define the flannel proxy interface for this node. | _NULL_ |
|
||||
| `k3s_bind_address` | Define the bind address for this node. | localhost |
|
||||
| `k3s_node_ip_address` | IP Address to advertise for this node. | _NULL_ |
|
||||
| `k3s_node_external_address` | External IP Address to advertise for this node. | _NULL_ |
|
||||
| `k3s_node_labels` | List of node labels. | _NULL_ |
|
||||
| `k3s_node_taints` | List of node taints. | _NULL_ |
|
||||
| `k3s_node_data_dir` | Folder to hold state. | `/var/lib/rancher/k3s` |
|
||||
| `k3s_tls_san` | Add additional hosname or IP as Subject Alternate Name in the TLS cert. | _NULL_ |
|
||||
| Variable | Description | Default Value |
|
||||
|----------------------------------|--------------------------------------------------------------------------|-----------------------------------------|
|
||||
| `k3s_control_node` | Define the host as a control plane node, (True/False). | `false` |
|
||||
| `k3s_node_name` | Define the name of this node. | `$(hostname)` |
|
||||
| `k3s_node_id` | Define the ID of this node. | _NULL_ |
|
||||
| `k3s_flannel_interface` | Define the flannel proxy interface for this node. | _NULL_ |
|
||||
| `k3s_bind_address` | Define the bind address for this node. | localhost |
|
||||
| `k3s_node_ip_address` | IP Address to advertise for this node. | _NULL_ |
|
||||
| `k3s_node_external_address` | External IP Address to advertise for this node. | _NULL_ |
|
||||
| `k3s_node_labels` | List of node labels. | _NULL_ |
|
||||
| `k3s_node_taints` | List of node taints. | _NULL_ |
|
||||
| `k3s_node_data_dir` | Folder to hold state. | `/var/lib/rancher/k3s` |
|
||||
| `k3s_tls_san` | Add additional hosname or IP as Subject Alternate Name in the TLS cert. | _NULL_ |
|
||||
| `k3s_server_manifests_dir` | Path for place the `k3s_server_manifests_templates`. | `/var/lib/rancher/k3s/server/manifests` |
|
||||
| `k3s_server_manifests_templates` | A list of Auto-Deploying Manifests Templates. | [] |
|
||||
|
||||
|
||||
#### Important note about `k3s_control_node` and High Availability (HA)
|
||||
|
||||
|
|
|
@ -14,6 +14,13 @@ k3s_github_url: https://github.com/rancher/k3s
|
|||
# Installation directory for k3s
|
||||
k3s_install_dir: /usr/local/bin
|
||||
|
||||
# Path for additional Kubernetes Manifests
|
||||
# https://rancher.com/docs/k3s/latest/en/advanced/#auto-deploying-manifests
|
||||
k3s_server_manifests_dir: /var/lib/rancher/k3s/server/manifests
|
||||
|
||||
# A list of templates used for preconfigure the cluster.
|
||||
k3s_server_manifests_templates: []
|
||||
|
||||
# Use experimental features in k3s?
|
||||
k3s_use_experimental: false
|
||||
|
||||
|
|
10
molecule/default/playbook-auto-deploying-manifests.yml
Normal file
10
molecule/default/playbook-auto-deploying-manifests.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
molecule_is_test: true
|
||||
k3s_server_manifests_templates:
|
||||
- "molecule/default/templates/00-ns-monitoring.yml.j2"
|
||||
roles:
|
||||
- role: xanmanning.k3s
|
4
molecule/default/templates/00-ns-monitoring.yml.j2
Normal file
4
molecule/default/templates/00-ns-monitoring.yml.j2
Normal file
|
@ -0,0 +1,4 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: monitoring
|
14
tasks/build/preconfigure-k3s-auto-deploying-manifests.yml
Normal file
14
tasks/build/preconfigure-k3s-auto-deploying-manifests.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
|
||||
- name: Ensure that the manifests directory exists, if required
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ k3s_server_manifests_dir }}"
|
||||
when: k3s_server_manifests_templates | length > 0
|
||||
|
||||
# https://rancher.com/docs/k3s/latest/en/advanced/#auto-deploying-manifests
|
||||
- name: Copy Auto-Deploying Manifests to Cluster
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ k3s_server_manifests_dir }}/{{ item | basename | replace('.j2','') }}"
|
||||
loop: "{{ k3s_server_manifests_templates }}"
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
- import_tasks: build/download-k3s.yml
|
||||
|
||||
- import_tasks: build/preconfigure-k3s-auto-deploying-manifests.yml
|
||||
|
||||
- import_tasks: build/install-k3s.yml
|
||||
|
||||
- import_tasks: build/configure-k3s-cluster.yml
|
||||
|
|
Loading…
Reference in a new issue