Compare commits

...

68 Commits

Author SHA1 Message Date
Jon
0b84d1bc0e Merge branch 'automated-tasks' into 'development'
chore(gitlab-ci): Automated update of git sub-module

See merge request nofusscomputing/projects/ansible/collections/kubernetes!83
2025-02-26 13:20:51 +00:00
c8a1f60a9e chore(git): updated submodule gitlab-ci
Automation Data:
{
    "branch": "development",
    "current_commit": "6f8dfcba0b25313b59bc17b4c99d674fcedd207a)",
    "name": "gitlab-ci",
    "path": "/builds/nofusscomputing/projects/ansible/collections/kubernetes/_automation_/gitlab-ci",
    "remote_head": "224ef831571458ad433a0143eec00df0f7e8b409)",
    "remote_name": "origin",
    "url": "https://gitlab.com/nofusscomputing/projects/gitlab-ci.git"
}

Changes: Submodule path gitlab-ci: checked out 224ef831571458ad433a0143eec00df0f7e8b409

MR !83
2025-02-26 13:08:54 +00:00
Jon
a790f5c60c Merge branch 'automated-tasks' into 'development'
chore(gitlab-ci): Automated update of git sub-module

See merge request nofusscomputing/projects/ansible/collections/kubernetes!81
2024-11-03 19:37:38 +00:00
0ebb28c978 chore(git): updated submodule gitlab-ci
Automation Data:
{
    "branch": "development",
    "current_commit": "58ffcabbfb503af3e57d9cb3ab43931b23dc4cd8)",
    "name": "gitlab-ci",
    "path": "/builds/nofusscomputing/projects/ansible/collections/kubernetes/_automation_/gitlab-ci",
    "remote_head": "6f8dfcba0b25313b59bc17b4c99d674fcedd207a)",
    "remote_name": "origin",
    "url": "https://gitlab.com/nofusscomputing/projects/gitlab-ci.git"
}

Changes: Submodule path gitlab-ci: checked out 6f8dfcba0b25313b59bc17b4c99d674fcedd207a

MR !81
2024-08-19 07:24:43 +00:00
e0ee4ba249 chore(git): updated submodule gitlab-ci
Automation Data:
{
    "branch": "development",
    "current_commit": "673441f83a7d943434252ee23899e3572cdfb141)",
    "name": "gitlab-ci",
    "path": "/builds/nofusscomputing/projects/ansible/collections/kubernetes/_automation_/gitlab-ci",
    "remote_head": "58ffcabbfb503af3e57d9cb3ab43931b23dc4cd8)",
    "remote_name": "origin",
    "url": "https://gitlab.com/nofusscomputing/projects/gitlab-ci.git"
}

Changes: Submodule path gitlab-ci: checked out 58ffcabbfb503af3e57d9cb3ab43931b23dc4cd8

MR !81
2024-08-01 06:08:19 +00:00
a6aeac42c8 build: bump version 1.13.1 -> 1.13.2
!77
2024-07-30 05:30:59 +00:00
Jon
ce8143f52d fix(nfc_kubernetes): correct logic for prime node to always be labeled prime
useful for setting up single node where if all nodes off except prime, targeting can be done

!77 !78 !79 !80 nofusscomputing/infrastructure/configuration-management/project-production!58 nofusscomputing/infrastructure/configuration-management/inventory-infrastructure!4 nofusscomputing/infrastructure/configuration-management/templates-production!28
2024-07-30 14:47:26 +09:30
6581056bc9 build: bump version 1.13.0 -> 1.13.1
!77
2024-07-28 08:11:42 +00:00
Jon
c204539b67 fix(nfc_kubernetes): prime node to always be labeled prime
useful for setting up single node where if all nodes off except prime, targeting can be done

!77 !78 !79 nofusscomputing/infrastructure/configuration-management/project-production!58 nofusscomputing/infrastructure/configuration-management/inventory-infrastructure!4 nofusscomputing/infrastructure/configuration-management/templates-production!28
2024-07-28 17:27:52 +09:30
06f44f5c3b build: bump version 1.12.0 -> 1.13.0
!77
2024-07-28 06:36:20 +00:00
Jon
9f3fcdc5e3 Merge branch 'node-labels-taints' into 'development'
feat(nfc_kubernetes): ability to add node labels and taints

See merge request nofusscomputing/projects/ansible/collections/kubernetes!77
2024-07-28 06:23:02 +00:00
Jon
3c06647637 feat(nfc_kubernetes): prime node to always be labeled prime
useful for setting up single node where if all nodes off except prime, targeting can be done

!77 nofusscomputing/infrastructure/configuration-management/project-production!58 nofusscomputing/infrastructure/configuration-management/inventory-infrastructure!4 nofusscomputing/infrastructure/configuration-management/templates-production!28
2024-07-28 15:40:24 +09:30
Jon
6d26e2e0cf feat(nfc_kubernetes): ability to add node labels and taints
!77 nofusscomputing/infrastructure/configuration-management/project-production!58 nofusscomputing/infrastructure/configuration-management/inventory-infrastructure!4 nofusscomputing/infrastructure/configuration-management/templates-production!28
2024-07-28 15:29:46 +09:30
b47b868f43 build: bump version 1.11.0 -> 1.12.0
!75
2024-07-08 07:48:01 +00:00
Jon
f3f2769f0a Merge branch 'fixes' into 'development'
fix(kebernetes): Apply fixes listed in issues

Closes #33 and #32

See merge request nofusscomputing/projects/ansible/collections/kubernetes!75
2024-07-08 02:02:29 +00:00
cba13dd8a3 fix(kubernetes_roles): conditional checks for prime
required so that config not applied to workers

!75
2024-07-08 00:46:06 +00:00
425e05de37 fix(kubernetes_roles): conditional checks for prime
required so that config not applied to workers

!75
2024-07-08 00:45:55 +00:00
cf63ec5543 fix(kubernetes_roles): conditional checks for prime
required so that config not applied to workers

!75
2024-07-08 00:45:42 +00:00
115755ad54 fix(kubernetes_roles): clean up white space
!75
2024-07-08 00:44:15 +00:00
6893164f90 fix(kubernetes_roles): clean up white space
!75
2024-07-08 00:44:05 +00:00
6275dde9e3 fix(kubernetes_roles): clean up white space
!75
2024-07-08 00:43:51 +00:00
98b6442bf8 fix(kubernetes_roles): clean up white space
!75
2024-07-08 00:43:33 +00:00
202e92a90b fix(kubernetes_role): delete leftover ]
this was a leftover from a copy and paste

!75
2024-07-07 14:33:45 +09:30
860addad4d fix(kubernetes_role): Change "https://" + hostvars[ns.prime_name].ansible_host + ":6443" -> "https://" + ns.prime_name.ansible_host + ":6443"
!75
2024-07-07 14:23:44 +09:30
8c1223769d fix(kubernetes_role): get prime hostname
required to set https address

!75
2024-07-07 14:11:30 +09:30
6bd8d27cfd fix(kubernetes_role): set server var -> "https://" + hostvars[nfc_role_kubernetes_node_prime].ansible_host + ":6443"
!75
2024-07-07 10:35:03 +09:30
a8ddcad1a0 fix(kubernetes_role): remove not nfc_role_kubernetes_cluster_upgraded | default(true) | bool section
Does not appear to acomplish what I was after

!75
2024-07-06 14:29:41 +09:30
536bab4ce2 fix(kubernetes_role): undo previous change
tasks did not run

!75
2024-07-06 14:08:51 +09:30
8217889910 test(kubernetes_role): set not nfc_role_kubernetes_cluster_upgraded | default(false | bool -> not nfc_role_kubernetes_cluster_upgraded | default(true) | bool
Testing to set node as a prime

!75
2024-07-06 13:49:52 +09:30
d59f20077e test(kubernetes_role): set prime default value to true
!74
2024-07-06 12:33:13 +09:30
23808704ae fix(kubernetes_role): remove commented out section
Not required

!74
2024-07-06 11:53:31 +09:30
55cc007575 fix(kubernetes_roles): use inventory_hostname
!74
2024-07-05 12:33:42 +09:30
044c914617 feat(kubernetes_role): nfc_role_kubernetes_prime cast type to bool
needs to check if type is a boolean

!74
2024-07-05 12:16:47 +09:30
2d5eb7c375 fix(kubernetes_roles): update cmd for setting ip6tables
!74
2024-07-04 18:10:18 +09:30
4d51d3ca00 fix(kubernetes_roles): update variable nfc_role_kubernetes_prime | default(false) | boolean -> nfc_role_kubernetes_prime !=false
test failed with result could not load boolean

!74
2024-07-04 17:21:05 +09:30
14a2cbed98 fix(kubernetes_role): set variable prime_hostname
!74
2024-07-04 17:10:40 +09:30
a2580f9328 fix(kubernetes_roles): update variable nfc_role_kubernetes_prime type to boolean
!74
2024-07-04 16:42:00 +09:30
28c4e3bbca feat(kubernetes_role): set var nfc_role_kubernetes_prime type boolean
!74 fixes #33
2024-07-04 15:24:45 +09:30
576ab623d8 fix(kubernetes_role): update var kubernetes_config.cluster.prime.name -> nfc_role_kubernetes_prime
variable is depreciated

!74
2024-07-04 15:03:16 +09:30
f5bba112cf feat(kubernetes_role): set ip6tables to legacy mode
!74 fixes #32
2024-07-04 14:41:06 +09:30
5a188407fe Merge branch 'automated-tasks' into 'development'
chore(website-template): Automated update of git sub-module

See merge request nofusscomputing/projects/ansible/collections/kubernetes!73
2024-06-30 18:14:29 +00:00
cb6211862c chore(git): updated submodule website-template
Automation Data:
{
    "branch": "development",
    "current_commit": "92c4b16a14524e7b5b18171d4e21b72676c36fbf)",
    "name": "website-template",
    "path": "/builds/nofusscomputing/projects/ansible/collections/kubernetes/_automation_/website-template",
    "remote_head": "8735f623dc5e1d9c9e46e50db03b4c41cb3d1efd)",
    "remote_name": "origin",
    "url": "https://gitlab.com/nofusscomputing/infrastructure/website-template.git"
}

Changes: Submodule path website-template: checked out 8735f623dc5e1d9c9e46e50db03b4c41cb3d1efd

MR !73
2024-06-30 18:03:32 +00:00
88e5f73b33 Merge branch 'automated-tasks' into 'development'
chore(gitlab-ci): Automated update of git sub-module

See merge request nofusscomputing/projects/ansible/collections/kubernetes!72
2024-06-30 18:00:03 +00:00
870dfcbb81 chore(git): updated submodule website-template
Automation Data:
{
    "branch": "development",
    "current_commit": "f5a82d3604faca56756eec91acee28ff89defd1d)",
    "name": "website-template",
    "path": "/builds/nofusscomputing/projects/ansible/collections/kubernetes/_automation_/website-template",
    "remote_head": "92c4b16a14524e7b5b18171d4e21b72676c36fbf)",
    "remote_name": "origin",
    "url": "https://gitlab.com/nofusscomputing/infrastructure/website-template.git"
}

Changes: Submodule path website-template: checked out 92c4b16a14524e7b5b18171d4e21b72676c36fbf

MR !72
2024-06-30 17:48:08 +00:00
edb2ef2409 chore(git): updated submodule gitlab-ci
Automation Data:
{
    "branch": "development",
    "current_commit": "a24f352ca3d82b8d0f02f5db20173fe2c3f71a4a)",
    "name": "gitlab-ci",
    "path": "/builds/nofusscomputing/projects/ansible/collections/kubernetes/_automation_/gitlab-ci",
    "remote_head": "673441f83a7d943434252ee23899e3572cdfb141)",
    "remote_name": "origin",
    "url": "https://gitlab.com/nofusscomputing/projects/gitlab-ci.git"
}

Changes: Submodule path gitlab-ci: checked out 673441f83a7d943434252ee23899e3572cdfb141

MR !72
2024-06-30 17:46:00 +00:00
49077e1088 build: bump version 1.10.3 -> 1.11.0
!71 nofusscomputing/projects/ansible/collections/firewall
2024-06-27 15:25:12 +00:00
Jon
ea3547a48f feat(firewall): update collection nfc_firewall 1.1.0 -> 1.1.1
!71 nofusscomputing/projects/ansible/collections/firewall!27
2024-06-28 00:40:27 +09:30
c87ed1646a build: bump version 1.10.2 -> 1.10.3
!69
2024-06-27 07:39:53 +00:00
Jon
25496d1f55 Merge branch '31-fix-ipv6-check' into 'development'
fix: kubernetes install failes when host with ipv6 disabled

Closes #31

See merge request nofusscomputing/projects/ansible/collections/kubernetes!69
2024-06-27 07:26:27 +00:00
Jon
b0d9279535 fix(install): ensure ipv6 is installed before attempting to disable
!69 fixes #31
2024-06-27 16:43:33 +09:30
7905f881fe build: bump version 1.10.1 -> 1.10.2
!68 nofusscomputing/projects/ansible/execution_environment
2024-05-03 20:38:59 +00:00
Jon
5ee0782993 fix(nfc_kubernetes): set default for var so task 'Copy Template' when clause doesn't fail task with undefined var
!68 nofusscomputing/projects/ansible/execution_environment!256
2024-05-04 05:56:00 +09:30
aeb1bcc048 build: bump version 1.10.0 -> 1.10.1
!67
2024-05-03 19:27:15 +00:00
Jon
bcc870a87c fix(nfc_kubernetes): set default for var so when clause doesn't fail task with undefined var
!67
2024-05-04 04:43:24 +09:30
c2c0a9fe7d build: bump version 1.9.0 -> 1.10.0
!65
2024-05-03 18:33:42 +00:00
Jon
1f90af4eac Merge branch '28-29-logic-fixes' into 'development'
fix: logic

Closes #28 and #29

See merge request nofusscomputing/projects/ansible/collections/kubernetes!65
2024-05-03 18:20:28 +00:00
Jon
a01af004a7 ci(test): add two apt updates in an attempt to correct apt-key random errors
error is "Unknown error executing apt-key" and "GPG error: < repo> InRelease: Unknown error executing apt-key"

!65
2024-05-04 03:36:02 +09:30
Jon
e002ff3749 fix(nfc_kubernetes): correct 'Create Required directories' when logic
!65
2024-05-04 03:23:29 +09:30
Jon
ece10c7ee0 feat(nfc_kubernetes): new variable 'nfc_role_kubernetes_node_prime' to denote the hostname of the prime node
!65 fixes #28
2024-05-04 01:47:49 +09:30
Jon
cbd2ec7ef8 refactor(nfc_kubernetes): remove usage of prime node name over is_prime var
!65 #28
2024-05-04 01:47:49 +09:30
Jon
43ddb13bdd fix(nfc_kubernetes): only run tasks on master nodes
!65 #28
2024-05-04 01:47:49 +09:30
Jon
310d7a1c48 fix(nfc_kubernetes): only run tasks on prime node
!65 #28
2024-05-04 01:47:49 +09:30
Jon
2ebeb805e8 fix(nfc_kubernetes): ensure correct node type selection for installation
!65 fixes #29
2024-05-04 01:47:49 +09:30
0d0d1862cc build: bump version 1.8.1-a2 -> 1.9.0
!63
2024-05-03 13:10:33 +00:00
Jon
b4c06b9f91 feat(nfc_kubernetes): add debug out to k3s download on failure
!63
2024-05-03 22:27:39 +09:30
Jon
3d0dda7277 revert: "feat(nfc_kubernetes) build url and on use cast as string"
This reverts commit 9fa3b233a9.

The bug was within awx-core 2.16.1 as upgrading to 2.16.6 fixed the problem

!63 !61 nofusscomputing/projects/ansible/execution_environment!255 closes https://github.com/ansible/awx/issues/15161
2024-05-02 15:00:51 +09:30
1a11014420 build: bump version 1.8.1-a1 -> 1.8.1-a2
!64 https://github.com/ansible/awx/issues/15161
2024-05-02 01:44:21 +00:00
Jon
ad55d3e874 fix(nfc_kubernetes): cast url var as list
!64 https://github.com/ansible/awx/issues/15161
2024-05-02 11:01:02 +09:30
11 changed files with 233 additions and 154 deletions

View File

@ -4,5 +4,5 @@ commitizen:
prerelease_offset: 1
tag_format: $version
update_changelog_on_bump: false
version: 1.8.1-a1
version: 1.13.2
version_scheme: semver

View File

@ -37,6 +37,8 @@
- | # enter test container
docker exec -i test_image_${CI_JOB_ID} ps aux
- docker ps
- docker exec -i test_image_${CI_JOB_ID} bash -c 'apt update || true'
- docker exec -i test_image_${CI_JOB_ID} bash -c 'apt update || true'
- docker exec -i test_image_${CI_JOB_ID} apt update
- docker exec -i test_image_${CI_JOB_ID} apt install -y --no-install-recommends python3-pip net-tools dnsutils iptables
- |

View File

@ -1,85 +1,71 @@
## 1.8.1-a1 (2024-05-02)
## 1.13.2 (2024-07-30)
### Fix
- **nfc_kubernetes**: correct url build to loop through all cpu arch
- **nfc_kubernetes**: correct logic for prime node to always be labeled prime
## 1.8.0 (2024-05-02)
## 1.13.1 (2024-07-28)
### Fix
- **nfc_kubernetes**: prime node to always be labeled prime
## 1.13.0 (2024-07-28)
### Feat
- **nfc_kubernetes**: build url and on use cast as string
- **nfc_kubernetes**: prime node to always be labeled prime
- **nfc_kubernetes**: ability to add node labels and taints
## 1.7.2 (2024-04-25)
## 1.12.0 (2024-07-08)
### Fix
- **nfc_kubernetes**: adjust some tasks to run during checkmode
- **kubernetes_roles**: conditional checks for prime
- **kubernetes_roles**: conditional checks for prime
- **kubernetes_roles**: conditional checks for prime
- **kubernetes_roles**: clean up white space
- **kubernetes_roles**: clean up white space
- **kubernetes_roles**: clean up white space
- **kubernetes_roles**: clean up white space
- **kubernetes_role**: delete leftover ]
- **kubernetes_role**: Change "https://" + hostvars[ns.prime_name].ansible_host + ":6443" -> "https://" + ns.prime_name.ansible_host + ":6443"
- **kubernetes_role**: get prime hostname
- **kubernetes_role**: set server var -> "https://" + hostvars[nfc_role_kubernetes_node_prime].ansible_host + ":6443"
- **kubernetes_role**: remove not nfc_role_kubernetes_cluster_upgraded | default(true) | bool section
## 1.7.1 (2024-04-24)
### Fix
- add role readme
## 1.7.0 (2024-04-24)
## 1.11.0 (2024-06-27)
### Feat
- **kubernetes_netbox**: custom field bug work around
- **services**: add netbox service fields
- **role**: New role kubernetes_netbox
- **firewall**: update collection nfc_firewall 1.1.0 -> 1.1.1
## 1.10.3 (2024-06-27)
### Fix
- **nfc_kubernetes**: ensure install tasks run when job_tags specified
- **facts**: gather required facts if not already available
- **install**: correct template installed var
- **install**: as part of install check, confirm service
- **install**: ensure ipv6 is installed before attempting to disable
## 1.6.0 (2024-03-29)
### Feat
- **test**: add integration test. playbook install
- add retry=3 delay=10 secs to all ansible url modules
- **upgrade**: If upgrade occurs, dont run remaining tasks
- support upgrading cluster
## 1.10.2 (2024-05-03)
### Fix
- **docs**: use correct badge query url
- **nfc_kubernetes**: set default for var so task 'Copy Template' when clause doesn't fail task with undefined var
### Refactor
- **galaxy**: for dependent collections prefix with `>=` so as to not cause version lock
## 1.5.0 (2024-03-21)
### Feat
- **collection**: nofusscomputing.firewall update 1.0.1 -> 1.1.0
## 1.4.0 (2024-03-20)
### Feat
- **install**: "ansible_check_mode=true" no hostname check
## 1.3.0 (2024-03-18)
## 1.10.1 (2024-05-03)
### Fix
- **handler**: add missing 'reboot_host' handler
- **firewall**: ensure slave nodes can access ALL masters API point
- **firewall**: dont add rules for disabled features
- **nfc_kubernetes**: set default for var so when clause doesn't fail task with undefined var
## 1.2.0 (2024-03-16)
### Feat
- **firewall**: use collection nofusscomputing.firewall to configure kubernetes firewall
## 1.10.0 (2024-05-03)
### Fix
- **config**: use correct var name when setting node name
- **nfc_kubernetes**: correct 'Create Required directories' when logic
## 1.9.0 (2024-05-03)
### Feat
- **nfc_kubernetes**: add debug out to k3s download on failure

View File

@ -8,7 +8,7 @@ namespace: nofusscomputing
name: kubernetes
# The version of the collection. Must be compatible with semantic versioning
version: 1.8.1-a1
version: 1.13.2
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
@ -46,7 +46,7 @@ tags:
dependencies:
ansible.posix: '>=1.5.4'
kubernetes.core: '>=3.0.0'
nofusscomputing.firewall: '>=1.1.0'
nofusscomputing.firewall: '>=1.1.1'
netbox.netbox: '>=3.16.0'

View File

@ -46,6 +46,10 @@ nfc_role_kubernetes_install_kubevirt: false
nfc_role_kubernetes_kubevirt_operator_replicas: 1
nfc_role_kubernetes_node_labels: {} # Optional, Dict. Node labels.
nfc_role_kubernetes_node_taints: {} # Optional, Dict. Node taints.
# nfc_role_kubernetes_node_prime: '' # Mandatory*, string. the inventory_hostname of the prime node. ONLY required for multi-node deployments
nfc_role_kubernetes_oidc_enabled: false
nfc_role_kubernetes_resolv_conf_file: /etc/resolv.conf
@ -53,8 +57,8 @@ nfc_role_kubernetes_resolv_conf_file: /etc/resolv.conf
nfc_role_kubernetes_pod_subnet: 172.16.248.0/21
nfc_role_kubernetes_service_subnet: 172.16.244.0/22
nfc_role_kubernetes_prime: true # Mandatory for a node designated as the prime master node
nfc_role_kubernetes_master: true # Mandatory for a node designated as a master node and the prime master node
nfc_role_kubernetes_prime: false # Mandatory for a node designated as the prime master node
nfc_role_kubernetes_master: false # Mandatory for a node designated as a master node and the prime master node
nfc_role_kubernetes_worker: false # Mandatory for a node designated as a worker node
############################################################################################################
@ -136,7 +140,7 @@ k3s:
# usernames: []
# runtimeClasses: []
# namespaces: [kube-system]
when: "{{ kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname }}"
when: "{{ nfc_role_kubernetes_prime | bool }}"
#############################################################################################

View File

@ -34,13 +34,13 @@
- src: kubernetes-manifest-rbac.yaml.j2
dest: /var/lib/rancher/k3s/server/manifests/rbac-authorization-common.yaml
when: "{{ kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname }}"
when: "{{ nfc_role_kubernetes_prime | bool }}"
- src: iptables-kubernetes.rules.j2
dest: "/etc/iptables-reloader/rules.d/iptables-kubernetes.rules"
notify: firewall_reloader
when: |-
{%- if firewall_installed -%}
{%- if firewall_installed | default(false) -%}
{{ firewall_rules_dir_metadata.stat.exists }}
@ -58,21 +58,41 @@
kind: Node
metadata:
name: "{{ inventory_hostname }}"
{% if kubernetes_config.hosts[inventory_hostname].labels | default([]) | list | length > 0 -%}
{% if
nfc_role_kubernetes_node_labels
and
not nfc_role_kubernetes_prime | bool
-%}
labels:
{{ kubernetes_config.hosts[inventory_hostname].labels | to_nice_yaml | indent(4) }}
{{ nfc_role_kubernetes_node_labels | to_nice_yaml(indent=0) | indent(4) }}
{% elif
nfc_role_kubernetes_prime | bool
%}
labels:
node-role.kubernetes.io/prime: "true"
{% if nfc_role_kubernetes_node_labels %}
{{ nfc_role_kubernetes_node_labels | to_nice_yaml(indent=0) | indent(4) }}
{% endif %}
{%- endif +%}
{% if kubernetes_config.hosts[inventory_hostname].taints | default([]) | list | length > 0 -%}
{% if nfc_role_kubernetes_node_taints -%}
spec:
taints:
{{ kubernetes_config.hosts[inventory_hostname].taints | to_nice_yaml(indent=0) | indent(4) }}
{{ nfc_role_kubernetes_node_taints | to_nice_yaml(indent=0) | indent(4) }}
{% endif %}
dest: /var/lib/rancher/k3s/server/manifests/node-manifest-{{ inventory_hostname }}.yaml
owner: root
group: root
mode: '700'
delegate_to: "{{ kubernetes_config.cluster.prime.name }}"
delegate_to: "{{ nfc_role_kubernetes_node_prime }}"
when:
kubernetes_config.hosts[inventory_hostname].labels | default([]) | list | length > 0
nfc_role_kubernetes_node_labels
or
kubernetes_config.hosts[inventory_hostname].taints | default([]) | list | length > 0
nfc_role_kubernetes_node_taints
or
nfc_role_kubernetes_prime | bool

View File

@ -15,12 +15,16 @@
ansible.builtin.stat:
name: /var/lib/rancher/k3s/server/manifests/calico.yaml
register: file_calico_yaml_metadata
when: >
nfc_role_kubernetes_prime | bool
- name: Check for calico Operator deployment manifest
ansible.builtin.stat:
name: /var/lib/rancher/k3s/ansible/deployment-manifest-calico_operator.yaml
register: file_calico_operator_yaml_metadata
when: >
nfc_role_kubernetes_prime | bool
- name: Install dependent packages
@ -108,15 +112,30 @@
- name: /var/lib/rancher/k3s/server/logs
state: directory
mode: 700
when: >
{{ nfc_role_kubernetes_master | bool }}
- name: /var/lib/rancher/k3s/server/manifests
state: directory
mode: 700
when: >
{{ nfc_role_kubernetes_master | bool }}
- name: /var/lib/rancher/k3s/ansible
state: directory
mode: 700
when: >
{{ nfc_role_kubernetes_master | bool }}
when: >
item.when | default(true)
- name: Add sysctl net.ipv4.ip_forward
- name: Check if IPv6 Enabled
ansible.builtin.stat:
path: /proc/sys/net/ipv6/conf/all/disable_ipv6
register: ipv6_file
failed_when: false
- name: Add sysctl settings
ansible.posix.sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
@ -135,8 +154,11 @@
value: '512'
- name: net.ipv6.conf.all.disable_ipv6
value: '1'
when:
- ansible_os_family == 'Debian'
when: "{{ ipv6_file.stat.exists }}"
when: >
ansible_os_family == 'Debian'
and
item.when | default(true) | bool
- name: Check for Network Manager Directory
@ -304,62 +326,62 @@
when: >
file_cached_k3s_binary.stat.checksum | default('0') != node_k3s.desired_hash
# Workaround. See: https://github.com/ansible/awx/issues/15161
- name: Build K3s Download URL
ansible.builtin.set_fact:
cacheable: false
url_download_k3s: |-
[
{%- for key, value in nfc_kubernetes_install_architectures | dict2items -%}
"https://github.com/k3s-io/k3s/releases/download/
{{- node_k3s.desired_version | urlencode -}}
/k3s
{%- if key == 'aarch64' -%}
-arm64
{%- endif %}",
{%- endfor -%}
]
changed_when: false
check_mode: false
delegate_to: localhost
loop: "{{ nfc_kubernetes_install_architectures | dict2items }}"
loop_control:
loop_var: cpu_arch
vars:
ansible_connection: local
- name: Try / Catch
block:
- name: Download K3s Binary
ansible.builtin.uri:
url: "{{ url | string }}"
method: GET
return_content: false
status_code:
- 200
- 304
dest: "/tmp/k3s.{{ ansible_architecture }}"
mode: "744"
changed_when: not ansible_check_mode
check_mode: false
delay: 10
retries: 3
register: k3s_download_files
delegate_to: localhost
failed_when: >
(lookup('ansible.builtin.file', '/tmp/k3s.' + ansible_architecture) | hash('sha256') | string) != node_k3s.desired_hash
and
(
k3s_download_files.status | int != 200
or
k3s_download_files.status | int != 304
)
run_once: true
when: ansible_os_family == 'Debian'
loop: "{{ url_download_k3s }}"
loop_control:
loop_var: url
vars:
ansible_connection: local
- name: Download K3s Binary
ansible.builtin.uri:
url: |-
https://github.com/k3s-io/k3s/releases/download/
{{- node_k3s.desired_version | urlencode -}}
/k3s
{%- if cpu_arch.key == 'aarch64' -%}
-arm64
{%- endif %}
method: GET
return_content: false
status_code:
- 200
- 304
dest: "/tmp/k3s.{{ ansible_architecture }}"
mode: "744"
changed_when: not ansible_check_mode
check_mode: false
delay: 10
retries: 3
register: k3s_download_files
delegate_to: localhost
failed_when: >
(lookup('ansible.builtin.file', '/tmp/k3s.' + ansible_architecture) | hash('sha256') | string) != node_k3s.desired_hash
and
(
k3s_download_files.status | int != 200
or
k3s_download_files.status | int != 304
)
run_once: true
when: ansible_os_family == 'Debian'
loop: "{{ nfc_kubernetes_install_architectures | dict2items }}"
loop_control:
loop_var: cpu_arch
vars:
ansible_connection: local
rescue:
- name: TRACE - Debug out
ansible.builtin.debug:
msg:
- "Download file hash: {{ (lookup('ansible.builtin.file', '/tmp/k3s.' + ansible_architecture) | hash('sha256') | string) }}"
- name: Fail task
ansible.builtin.assert:
that:
- false
msg: "Task failed, review previous task for error"
- name: Copy K3s binary to Host
@ -499,7 +521,7 @@
dest: /var/lib/rancher/k3s/server/manifests/calico.yaml
when: >
{{
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | bool
and
(
(
@ -530,6 +552,14 @@
# ipv6: true
- name: Set IP6Tables to legacy mode
ansible.builtin.command:
cmd: update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
changed_when: false
when: >
not nfc_role_kubernetes_cluster_upgraded | default(false) | bool
- name: Set IPTables to legacy mode
ansible.builtin.command:
cmd: update-alternatives --set iptables /usr/sbin/iptables-legacy
@ -546,7 +576,7 @@
/tmp/install.sh {% if nfc_role_kubernetes_etcd_enabled %}--cluster-init{% endif %}
changed_when: false
when: >
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | bool
and
not node_k3s.installed | bool
and
@ -567,12 +597,12 @@
'operator_calico' in ansible_run_tags
)
or
not file_calico_yaml_metadata.stat.exists
not file_calico_yaml_metadata.stat.exists | default(false)
)
and
'calico_manifest' not in ansible_run_tags
and
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | bool
and
not nfc_role_kubernetes_cluster_upgraded | default(false) | bool
@ -593,7 +623,7 @@
when: >-
nfc_kubernetes_enable_metallb | default(false) | bool
and
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | bool
and
not nfc_role_kubernetes_cluster_upgraded | default(false) | bool
@ -609,7 +639,7 @@
exit 127;
fi
executable: /bin/bash
delegate_to: "{{ kubernetes_config.cluster.prime.name | default(inventory_hostname) }}"
delegate_to: "{{ nfc_role_kubernetes_node_prime }}"
run_once: true
register: kubernetes_ready_check
retries: 30
@ -649,7 +679,7 @@
install_olm.rc == 1
register: install_olm
when: >
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | bool
and
nfc_role_kubernetes_install_olm | default(false) | bool
and
@ -679,7 +709,7 @@
failed_when: false
register: install_olm
when: >
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | bool
and
'olm_uninstall' in ansible_run_tags
and
@ -692,7 +722,7 @@
changed_when: false
failed_when: false # New cluster will fail
when: >
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | bool
and
kubernetes_config.cluster.networking.encrypt | default(false) | bool
and
@ -712,7 +742,7 @@
- name: Fetch Join Token
ansible.builtin.slurp:
src: /var/lib/rancher/k3s/server/token
delegate_to: "{{ kubernetes_config.cluster.prime.name | default(inventory_hostname) }}"
delegate_to: "{{ nfc_role_kubernetes_node_prime }}"
run_once: true
register: k3s_join_token
no_log: true # Value is sensitive
@ -723,7 +753,7 @@
- name: Create Token fact
ansible.builtin.set_fact:
k3s_join_token: "{{ k3s_join_token.content | b64decode | replace('\n', '') }}"
delegate_to: "{{ kubernetes_config.cluster.prime.name | default(inventory_hostname) }}"
delegate_to: "{{ nfc_role_kubernetes_node_prime }}"
run_once: true
no_log: true # Value is sensitive
when: >
@ -743,7 +773,7 @@
when: >
nfc_role_kubernetes_master | default(false) | bool
and
not kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
not nfc_role_kubernetes_prime | bool
and
not node_k3s.installed | bool
and
@ -758,14 +788,14 @@
INSTALL_K3S_SKIP_DOWNLOAD=true \
INSTALL_K3S_VERSION="v{{ node_k3s.desired_version }}" \
K3S_TOKEN="{{ k3s_join_token }}" \
K3S_URL="https://{{ hostvars[kubernetes_config.cluster.prime.name | default(inventory_hostname)].ansible_host }}:6443" \
K3S_URL="https://{{ hostvars[nfc_role_kubernetes_node_prime].ansible_host }}:6443" \
/tmp/install.sh -
executable: /bin/bash
changed_when: false
when: >
not nfc_role_kubernetes_master | default(false) | bool
and
not kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
not nfc_role_kubernetes_prime | bool
and
not node_k3s.installed | bool
and

View File

@ -1,15 +1,29 @@
---
- name: Default Variable adjustment [Probable Single Node Install]
ansible.builtin.set_fact:
cacheable: false
nfc_role_kubernetes_prime: true
nfc_role_kubernetes_master: true
nfc_role_kubernetes_node_prime: "{{ inventory_hostname }}"
when: >
not nfc_role_kubernetes_worker | bool
and
not nfc_role_kubernetes_prime | bool
and
not nfc_role_kubernetes_master | bool
- name: Install/Configure Kubernetes Prime Master Node
ansible.builtin.include_tasks:
file: install.yaml
tags:
- always
when:
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
and
nfc_role_kubernetes_prime | bool
and
not nfc_role_kubernetes_worker | bool
and
not kubernetes_installed | default(false)
@ -19,10 +33,12 @@
tags:
- always
when:
kubernetes_config.cluster.prime.name | default(inventory_hostname) != inventory_hostname
and
nfc_role_kubernetes_master | bool
and
not nfc_role_kubernetes_prime | bool
and
not nfc_role_kubernetes_worker | bool
and
not kubernetes_installed | default(false)

View File

@ -9,9 +9,10 @@
{%- if
nfc_role_kubernetes_master
or
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
nfc_role_kubernetes_prime | default(true) | bool
and
not nfc_role_kubernetes_worker
-%}
{%
set kube_apiserver_arg = [
@ -197,13 +198,28 @@
}) -%}
{%- elif
kubernetes_config.cluster.prime.name != inventory_hostname
nfc_role_kubernetes_prime | default(true) | bool
and
not node_k3s.installed
and
not nfc_role_kubernetes_worker
-%}
{%- set ns = namespace(prime_name) -%}
{%- for hostname, values in hostvars.iteritems() -%}
{%- if values.nfc_role_kubernetes_node_prime ==true -%}
{%- set ns.prime_name = hostname -%}
{%- endif -%}
{%- endfor -%}
{%- set server = (server | default([])) + [
"https://" + hostvars[kubernetes_config.cluster.prime.name].ansible_host + ":6443"
"https://" + ns.prime_name.ansible_host + ":6443"
] -%}
{%- set all_nodes_config = all_nodes_config | combine({
@ -235,13 +251,18 @@
{%- endif -%}
{# EoF All Nodes #}
{%- if
nfc_role_kubernetes_master
or
kubernetes_config.cluster.prime.name | default(inventory_hostname) == inventory_hostname
(
nfc_role_kubernetes_master
or
nfc_role_kubernetes_prime | default(true) | bool
)
and
not nfc_role_kubernetes_worker
-%}
{%- set servers_config = servers_config | combine( all_nodes_config ) -%}