Merge pull request #5 from nolte/feature/add_manifests

Add Support for Auto-Deploying Manifests
This commit is contained in:
Xan Manning 2020-01-13 19:09:57 +00:00 committed by GitHub
commit c8fb27ecd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 13 deletions

View File

@ -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

View File

@ -113,7 +113,7 @@ 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_ |
@ -125,6 +125,9 @@ Below are variables that are set against specific hosts in your inventory.
| `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)

View File

@ -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

View 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

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: monitoring

View 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 }}"

View File

@ -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