Merge branch '11-arm-cpu-arhitecture' into 'development'

feat: arm cpu support

Closes #12 and #11

See merge request nofusscomputing/projects/ansible/kubernetes!7
This commit is contained in:
2023-11-13 08:41:09 +00:00
3 changed files with 75 additions and 9 deletions

View File

@ -22,9 +22,15 @@ This role deploys a K3s cluster. In addition it has the following features:
- etcd snapshot cron schedule
- etcd snapshot retention
- Cluster Domain
- Configure System reserved CPU, Storage and Memory.
- Node Labels
- Service Load Balancer Namespace
- _[ToDo-#3](https://gitlab.com/nofusscomputing/projects/ansible/kubernetes/-/issues/3)_ Encryption between nodes (Wireguard)
- [Firewall configured for kubernetes host](firewall.md)
@ -64,6 +70,6 @@ If the playbook is setup as per [our recommendation](ansible.md) step 2 onwards
``` yaml title="defaults/main.yaml" linenums="1"
--8<-- "defaults/main.yaml"
--8<-- "defaults/main.yml"
```

View File

@ -95,7 +95,12 @@
register: k3s_installed
- name: Download K3s Binary
- name: Check Machine Architecture
ansible.builtin.set_fact:
nfc_kubernetes_install_architectures: "{{ nfc_kubernetes_install_architectures | default({}) | combine({ansible_architecture: ''}) }}"
- name: Download Install Script
ansible.builtin.uri:
url: "{{ item.url }}"
method: GET
@ -105,7 +110,7 @@
- 304
dest: "{{ item.dest }}"
mode: "744"
register: k3s_download_files
register: k3s_download_script
delegate_to: localhost
run_once: true
# no_log: true
@ -116,14 +121,43 @@
download_files:
- dest: /tmp/install.sh
url: https://get.k3s.io
- dest: "/tmp/k3s"
url: "https://github.com/k3s-io/k3s/releases/download/v{{ KubernetesVersion + KubernetesVersion_k3s_prefix | urlencode }}/k3s"
- name: Download K3s Binary
ansible.builtin.uri:
url: |-
https://github.com/k3s-io/k3s/releases/download/v
{{- KubernetesVersion + KubernetesVersion_k3s_prefix | urlencode -}}
/k3s
{%- if cpu_arch.key == 'aarch64' -%}
-arm64
{%- endif %}
method: GET
return_content: true
status_code:
- 200
- 304
dest: "/tmp/k3s.{{ cpu_arch.key }}"
mode: "744"
register: k3s_download_files
delegate_to: localhost
run_once: true
# no_log: true
when: ansible_os_family == 'Debian'
loop: "{{ nfc_kubernetes_install_architectures | dict2items }}"
loop_control:
loop_var: cpu_arch
vars:
ansible_connection: local
- name: "[TRACE] Downloaded File SHA256"
ansible.builtin.set_fact:
hash_sha256_k3s_downloaded_binary: "{{ lookup('ansible.builtin.file', '/tmp/k3s') | hash('sha256') | string }}"
hash_sha256_k3s_downloaded_binary: "{{ lookup('ansible.builtin.file', '/tmp/k3s.' + cpu_arch.key) | hash('sha256') | string }}"
delegate_to: localhost
loop: "{{ nfc_kubernetes_install_architectures | dict2items }}"
loop_control:
loop_var: cpu_arch
- name: Existing k3s File hash
@ -135,7 +169,7 @@
- name: Copy K3s binary to Host
ansible.builtin.copy:
src: "/tmp/k3s"
src: "/tmp/k3s.{{ ansible_architecture }}"
dest: "/usr/local/bin/k3s"
mode: '740'
owner: root
@ -305,3 +339,4 @@
kubernetes_installed: true
# Clear Token as no llonger required and due to being a sensitive value
k3s_join_token: null
nfc_kubernetes_install_architectures: {}

View File

@ -6,7 +6,18 @@
# Dont edit this file directly as it will be overwritten.
#
{% if Kubernetes_Prime | default(false) | bool -%}cluster-cidr: "{{ KubernetesPodSubnet }}"{% endif %}
{% if Kubernetes_Prime | default(false) | bool -%}
cluster-cidr: "{{ KubernetesPodSubnet }}"
{% if
kubernetes_config.cluster.domain_name is defined
and
kubernetes_config.cluster.domain_name | default('') != ''
-%}
cluster-domain: {{ kubernetes_config.cluster.domain_name }}
{%- endif %}
{%- endif %}
{% if Kubernetes_Master | default(false) -%}cluster-init: true
disable-network-policy: true
@ -32,7 +43,21 @@ kubelet-arg:
- system-reserved=cpu={{ kubelet_arg_system_reserved_cpu }},memory={{ kubelet_arg_system_reserved_memory }},ephemeral-storage={{ kubelet_arg_system_reserved_storage }}
{% if host_external_ip | default('') %}node-external-ip: "{{ host_external_ip }}"{% endif %}
{% if not Kubernetes_Prime | default(false) | bool -%}server: https://{{ hostvars[kubernetes_config.cluster.prime.name].ansible_host }}:6443{%- endif -%}
{% if
kubernetes_config.hosts[inventory_hostname].labels is defined
and
kubernetes_config.hosts[inventory_hostname].labels | default([]) | list | length > 0
-%}
node-label:
{% for node_label in kubernetes_config.hosts[inventory_hostname].labels | dict2items %}
- {{ node_label.key }}={{ node_label.value }}
{%- endfor %}
{%- endif %}
{% if not Kubernetes_Prime | default(false) | bool -%}
server: https://{{ hostvars[kubernetes_config.cluster.prime.name].ansible_host }}:6443
servicelb-namespace: {{ kubernetes_config.cluster.networking.service_load_balancer_namespace | default('kube-system') }}
{%- endif %}
{% if Kubernetes_Master | default(false) | bool -%}
service-cidr: "{{ KubernetesServiceSubnet }}"