Added extra no-deploy options for v1.0.0

This commit is contained in:
Xan Manning 2019-12-04 18:44:37 +00:00
parent 8f3b2428c8
commit 26a3b2eef0
6 changed files with 43 additions and 19 deletions

View file

@ -22,7 +22,7 @@ env:
MOLECULE_PLAYBOOK: playbook-docker.yml
# Test using alternate port and using wireguard as the flannel backend
- MOLECULE_DISTRO: amazonlinux2
- MOLECULE_DISTRO: debian10
MOLECULE_PLAYBOOK: playbook-docker-altport-wireguard.yml
# Test disabling all deployments

View file

@ -22,11 +22,15 @@ This role has been tested on Ansible 2.6.0+ against the following Linux Distribu
## Disclaimer
:warning: Not suitable for production use.
:warning: May not be suitable for production use!
Whilst Rancher Labs are awesome, k3s is a fairly new project and not yet a v1.0
release so extreme caution and operational rigor is recommended before using
this role for any serious development.
Rancher Labs is awesome and has released k3s as v1.0.0, however at the time of
creating this role I do not have a k3s cluster in production nor am I unlikely
to ever have one. Please ensure you practice extreme caution and operational
rigor before using this role for any serious workloads.
If you have any problems please create a GitHub issue, I maintain this role in
my spare time so I cannot promise a speedy fix delivery.
## Role Variables
@ -52,6 +56,8 @@ consistency.
| `k3s_cluster_domain` | Cluster Domain. | cluster.local |
| `k3s_no_traefik` | Do not use Traefik | `false` |
| `k3s_no_servicelb` | Do not use ServiceLB, necessary for using something like MetalLB. | `false` |
| `k3s_no_local_storage` | Do not use Local Storage | `false` |
| `k3s_no_metrics_server` | Do not deploy metrics server | `false` |
| `k3s_disable_scheduler` | Disable Kubernetes default scheduler | `false` |
| `k3s_disable_cloud_controller` | Disable k3s default cloud controller manager. | `false` |
| `k3s_disable_network_policy` | Disable k3s default network policy controller. | `false` |
@ -82,15 +88,17 @@ 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` |
#### Important note about `k3s_control_node`

View file

@ -43,6 +43,12 @@ k3s_no_traefik: false
# load balancer service.
k3s_no_servicelb: false
# Do not use local storage
k3s_no_local_storage: false
# Do not deploy metrics server
k3s_no_metrics_server: false
# Disable default k3s scheduler
k3s_disable_scheduler: false

View file

@ -4,10 +4,11 @@
become: true
vars:
molecule_is_test: true
k3s_no_flannel: true
k3s_no_coredns: true
k3s_no_traefik: true
k3s_no_servicelb: true
k3s_no_local_storage: true
k3s_no_metrics_server: true
k3s_disable_scheduler: true
k3s_disable_cloud_controller: true
k3s_disable_network_policy: true

View file

@ -20,7 +20,6 @@
- name: Ensure control node is delegated to for obtaining a token
set_fact:
k3s_control_delegate: "{{ k3s_control_delegate_raw.stdout.split(' @@@ ')[0] }}"
when: k3s_control_node_address is not defined
- name: Ensure the control node address is registered in Ansible
set_fact:

View file

@ -25,14 +25,18 @@ ExecStart={{ k3s_install_dir }}/k3s
--disable-network-policy
{% endif %}
{% if k3s_no_flannel %}
{% if k3s_release_version is version_compare('1.0.0', '<') %}
--no-flannel
{% else %}
--flannel-backend none
{% endif %}
{% endif %}
{% if k3s_flannel_backend != "vxlan" and not k3s_no_flannel %}
--flannel-backend {{ k3s_flannel_backend }}
{% endif %}
{% if k3s_no_coredns is defined or k3s_no_traefik is defined or k3s_no_servicelb is defined %}
{% if k3s_no_coredns or k3s_no_traefik or k3s_no_servicelb %}
{{ ' --no-deploy coredns' if k3s_no_coredns else '' }}{{ ' --no-deploy servicelb' if k3s_no_servicelb else '' }}{{ ' --no-deploy traefik' if k3s_no_traefik else '' }}
{{ ' --no-deploy coredns' if k3s_no_coredns else '' }}{{ ' --no-deploy servicelb' if k3s_no_servicelb else '' }}{{ ' --no-deploy traefik' if k3s_no_traefik else '' }}{{ ' --no-deploy local-storage' if k3s_no_local_storage else '' }}{{ ' --no-deploy metrics-server' if k3s_no_metrics_server else '' }}
{% endif %}
{% endif %}
{% if k3s_cluster_dns is defined and k3s_cluster_dns %}
@ -46,6 +50,9 @@ ExecStart={{ k3s_install_dir }}/k3s
--server https://{{ k3s_control_node_address }}:{{ k3s_https_port }}
--token {{ k3s_control_token }}
{% endif %}
{% if k3s_node_data_dir is defined %}
--data-dir {{ k3s_node_data_dir }}
{% endif %}
{% if k3s_use_docker %}
--docker
{% endif %}
@ -58,6 +65,9 @@ ExecStart={{ k3s_install_dir }}/k3s
{% if k3s_node_name is defined %}
--node-name {{ k3s_node_name }}
{% endif %}
{% if k3s_node_id is defined %}
--with-node-id {{ k3s_node_id }}
{% endif %}
{% if k3s_node_ip_address is defined %}
--node-ip {{ k3s_node_ip_address }}
{% endif %}