Fixed Mayastor DiskPool, K8S upgrade.

This commit is contained in:
Jeroen Vermeulen 2023-09-25 18:36:38 +02:00
parent c7469d55e5
commit 41f67af217
No known key found for this signature in database
17 changed files with 131 additions and 40 deletions

8
dci_finish.yml Normal file
View File

@ -0,0 +1,8 @@
---
- name: Mark installation finished using DCI Manager
gather_facts: false
hosts:
- talos_hardware_nodes
roles:
- role: dci_finish

View File

@ -1,5 +1,6 @@
---
kubernetes_version: v1.26.7
kubernetes_version: v1.26.9 # Rancher can't run on v1.27, see https://www.suse.com/suse-rancher/support-matrix/all-supported-versions/rancher-v2-7-6/
talos_image_version: v1.5.2
talos_version: v1.5.3
ansible_root_dir: "{{ inventory_dir | ansible.builtin.dirname }}"
ansible_vault_password_file: "{{ ansible_root_dir }}/.ansible/vault_pass"
@ -13,7 +14,6 @@ talos_node_config_file: "{{ talos_cluster_config_dir }}/talos-{{ inventory_hostn
talos_disk: /dev/sda
talosconfig: "{{ talos_cluster_config_dir }}/talosconfig.yaml"
kubeconfig: "{{ talos_cluster_config_dir }}/kubeconfig.yaml"
talos_image_version: v1.4.7
kubectl_host: localhost
talosctl_host: localhost
ingress_lb_hostname: "workers.{{ cluster_name }}"
@ -21,4 +21,4 @@ ingress_ips: [] # One or more IPs must be defined for first cluster node using I
rancher_hostname: "rancher.{{ cluster_name }}"
letsencrypt_email: "jeroen@deovero.com"
network_interface: "eth0"
network_cidr_prefix: "24"
network_cidr_prefix: "24"

View File

@ -24,10 +24,21 @@
register: _dci_reinstall
until: _dci_reinstall.status != 503 and _dci_reinstall.status != -1
- name: Wait for Talos port 50000
- name: Wait for Talos port 50000 to go down
delegate_to: "{{ talosctl_host }}"
become: false
ansible.builtin.wait_for:
delay: 10
state: stopped
host: "{{ ansible_remote }}"
port: 50000
timeout: 300
- name: Wait for Talos port 50000 to be open
delegate_to: "{{ talosctl_host }}"
become: false
ansible.builtin.wait_for:
delay: 10
host: "{{ ansible_remote }}"
port: 50000
timeout: 1200

View File

@ -0,0 +1,3 @@
---
dependencies:
- role: common

View File

@ -0,0 +1,17 @@
---
- name: DiskPool for Mayastor
delegate_to: "{{ kubectl_host }}"
when: "mayastor_disk is defined"
kubernetes.core.k8s:
kubeconfig: "{{ kubeconfig }}"
resource_definition:
apiVersion: "openebs.io/v1beta1"
kind: DiskPool
metadata:
name: "{{ inventory_hostname | ansible.builtin.regex_replace('[^a-z0-9]+', '-') }}-{{ mayastor_disk | ansible.builtin.regex_replace('[^a-z0-9]+', '-') }}"
namespace: mayastor
spec:
node: "{{ inventory_hostname }}"
disks:
- "{{ mayastor_disk }}"

View File

@ -14,6 +14,7 @@
- name: Apply Talos node config
delegate_to: "{{ talosctl_host }}"
become: false
throttle: 1
ansible.builtin.command:
cmd: >-
talosctl apply-config

View File

@ -1,20 +0,0 @@
---
- name: Create Talos control node config
delegate_to: "{{ talosctl_host }}"
become: false
ansible.builtin.command:
cmd: >-
talosctl gen config '{{ cluster_name }}' 'https://{{ talos_control_lb_hostname }}:6443'
--output-types controlplane
--output '{{ talos_node_config_file }}'
--with-secrets '{{ talos_cluster_secrets_file }}'
--config-patch @'{{ talos_generic_config_dir }}/talos-patch.yaml'
--config-patch-control-plane @'{{ talos_generic_config_dir }}/talos-patch-control.yaml'
--config-patch='[{"op": "replace", "path": "/machine/network/hostname", "value": "{{ inventory_hostname }}"}]'
--config-patch='[{"op": "replace", "path": "/machine/install/disk", "value": "{{ talos_disk }}"}]'
--talos-version '{{ talos_image_version }}'
--kubernetes-version '{{ kubernetes_version }}'
--additional-sans '{{ talos_control_lb_hostname }}'
--force
changed_when: true

View File

@ -15,17 +15,20 @@
gateway: "{{ (ansible_remote ~ '/' ~ network_cidr_prefix) | ansible.utils.ipaddr('1') | ansible.utils.ipaddr('address') }}"
install:
disk: "{{ talos_disk }}"
kubelet:
extraArgs:
max-pods: "{% if 'talos_hardware_nodes' in group_names %}250{% else %}110{% endif %}"
- name: Create Talos interfaces bond append
when: "network_interfaces_bond is defined"
when: "network_interface_bond is defined"
ansible.utils.update_fact:
updates:
- path: "_talos_override_config.machine.network.interfaces.0.bond"
value: "{{ network_interfaces_bond }}"
value: "{{ network_interface_bond }}"
register: _talos_override_update
- name: Apply Talos interfaces bond append
when: "network_interfaces_bond is defined"
when: "network_interface_bond is defined"
ansible.builtin.set_fact:
_talos_override_config: "{{ _talos_override_update._talos_override_config }}"
@ -52,10 +55,11 @@
ansible.builtin.command:
cmd: >-
talosctl gen config '{{ cluster_name }}' 'https://{{ talos_control_lb_hostname }}:6443'
--output-types='worker'
--output-types='{% if "talos_control_nodes" in group_names %}controlplane{% else %}worker{% endif %}'
--output='{{ talos_node_config_file }}'
--with-secrets='{{ talos_cluster_secrets_file }}'
--config-patch=@'{{ talos_generic_config_dir }}/talos-patch.yaml'
--config-patch-control-plane @'{{ talos_generic_config_dir }}/talos-patch-control.yaml'
--config-patch-worker=@'{{ talos_generic_config_dir }}/talos-patch-worker.yaml'
--config-patch=@'{{ _talos_override_tempfile }}'
--talos-version='{{ talos_image_version }}'

View File

@ -14,10 +14,5 @@
- name: Import create_talosconfig tasks
ansible.builtin.import_tasks: create_talosconfig.yml
- name: Import create_control_configs tasks
when: "'talos_control_nodes' in group_names"
ansible.builtin.import_tasks: create_control_configs.yml
- name: Import create_worker_configs tasks
when: "'talos_worker_nodes' in group_names"
ansible.builtin.import_tasks: create_worker_configs.yml
- name: Import create_node_config tasks
ansible.builtin.import_tasks: create_node_config.yml

View File

@ -1,22 +1,22 @@
---
- name: Upgrade Talos
delegate_to: "{{ talosctl_host }}"
become: false
throttle: 1
ansible.builtin.command:
cmd: >-
talosctl upgrade
--image="ghcr.io/siderolabs/installer:{{ talos_version }}"
--endpoints '{{ talos_control_lb_hostname }}'
--nodes '{{ ansible_remote }}'
--endpoints='{{ talos_control_lb_hostname }}'
--nodes='{{ ansible_remote }}'
--timeout='30m'
--wait=true
changed_when: false
changed_when: true
environment:
TALOSCONFIG: "{{ talosconfig }}"
- name: Wait for Talos port 50000
delegate_to: "{{ talosctl_host }}"
throttle: 1
become: false
ansible.builtin.wait_for:
host: "{{ ansible_remote }}"

View File

@ -0,0 +1,3 @@
---
dependencies:
- role: common

View File

@ -0,0 +1,21 @@
---
- name: Upgrade Kubernetes to {{ kubernetes_version }}
delegate_to: "{{ talosctl_host }}"
run_once: true
ansible.builtin.command:
cmd: >-
talosctl upgrade-k8s
--to={{ kubernetes_version }}
changed_when: true
environment:
TALOSCONFIG: "{{ talosconfig }}"
- name: Wait for Talos port 50000
delegate_to: "{{ talosctl_host }}"
throttle: 1
become: false
ansible.builtin.wait_for:
host: "{{ ansible_remote }}"
port: 50000
delay: 5
timeout: 300

View File

@ -0,0 +1,3 @@
---
dependencies:
- role: common

View File

@ -0,0 +1,12 @@
---
- name: Wait for Talos health
delegate_to: "{{ talosctl_host }}"
run_once: true
ansible.builtin.command:
cmd: >-
talosctl health
--wait-timeout='30m'
changed_when: false
environment:
TALOSCONFIG: "{{ talosconfig }}"

View File

@ -28,3 +28,14 @@
- role: velero
tags:
- velero
- name: Install per-node services on K8S
become: false
gather_facts: false
hosts:
- talos
roles:
- role: mayastor_diskpool
tags:
- mayastor
- mayastor_diskpool

View File

@ -1,7 +1,17 @@
---
- name: Wait for Talos health
gather_facts: false
serial: 1
hosts:
- talos_first_nodes
roles:
- role: talos_wait_port
- role: talos_wait_health
- name: Upgrade Talos
gather_facts: false
serial: 1
hosts:
- talos
roles:

12
talos_upgrade_k8s.yml Normal file
View File

@ -0,0 +1,12 @@
---
- name: Upgrade Talos
gather_facts: false
throttle: 1
serial: 1
hosts:
- talos_first_nodes
roles:
- role: talos_wait_port
- role: talos_wait_health
- role: talos_upgrade_k8s