98 lines
2.5 KiB
YAML
98 lines
2.5 KiB
YAML
---
|
||
- name: Install NFS client on all K3S nodes
|
||
ansible.builtin.apt:
|
||
name: nfs-common
|
||
state: present
|
||
update_cache: true
|
||
become: true
|
||
when: csi_nfs_install_client
|
||
# Выполняется на ВСЕХ нодах кластера (master + workers)
|
||
|
||
- name: Add CSI NFS Helm repo
|
||
kubernetes.core.helm_repository:
|
||
name: "{{ csi_nfs_chart_name }}"
|
||
repo_url: "{{ csi_nfs_chart_repo }}"
|
||
run_once: true
|
||
delegate_to: "{{ groups['k3s_master'][0] }}"
|
||
environment:
|
||
KUBECONFIG: "{{ k3s_kubeconfig_path }}"
|
||
become: true
|
||
|
||
- name: Deploy CSI NFS Driver via Helm
|
||
kubernetes.core.helm:
|
||
name: "{{ csi_nfs_chart_name }}"
|
||
chart_ref: "{{ csi_nfs_chart_name }}/{{ csi_nfs_chart_name }}"
|
||
chart_version: "{{ csi_nfs_version }}"
|
||
release_namespace: "{{ csi_nfs_namespace }}"
|
||
create_namespace: false
|
||
wait: true
|
||
wait_condition:
|
||
type: Ready
|
||
timeout: "5m0s"
|
||
values:
|
||
controller:
|
||
replicas: 1
|
||
resources:
|
||
limits:
|
||
cpu: 200m
|
||
memory: 200Mi
|
||
requests:
|
||
cpu: 10m
|
||
memory: 20Mi
|
||
node:
|
||
resources:
|
||
limits:
|
||
cpu: 100m
|
||
memory: 100Mi
|
||
requests:
|
||
cpu: 10m
|
||
memory: 20Mi
|
||
run_once: true
|
||
delegate_to: "{{ groups['k3s_master'][0] }}"
|
||
environment:
|
||
KUBECONFIG: "{{ k3s_kubeconfig_path }}"
|
||
become: true
|
||
|
||
- name: Deploy NFS StorageClass
|
||
ansible.builtin.template:
|
||
src: storageclass.yaml.j2
|
||
dest: /tmp/nfs-storageclass.yaml
|
||
mode: '0644'
|
||
delegate_to: "{{ groups['k3s_master'][0] }}"
|
||
run_once: true
|
||
|
||
- name: Apply NFS StorageClass
|
||
ansible.builtin.command: >
|
||
k3s kubectl apply -f /tmp/nfs-storageclass.yaml
|
||
become: true
|
||
delegate_to: "{{ groups['k3s_master'][0] }}"
|
||
run_once: true
|
||
changed_when: true
|
||
|
||
- name: Verify CSI NFS pods are running
|
||
ansible.builtin.command: >
|
||
k3s kubectl -n {{ csi_nfs_namespace }} get pods
|
||
-l app=csi-nfs-controller
|
||
-o jsonpath='{.items[*].status.phase}'
|
||
become: true
|
||
delegate_to: "{{ groups['k3s_master'][0] }}"
|
||
run_once: true
|
||
register: csi_pods
|
||
until: "'Running' in csi_pods.stdout"
|
||
retries: 20
|
||
delay: 10
|
||
changed_when: false
|
||
|
||
- name: Show StorageClass
|
||
ansible.builtin.command: k3s kubectl get storageclass
|
||
become: true
|
||
delegate_to: "{{ groups['k3s_master'][0] }}"
|
||
run_once: true
|
||
register: sc_list
|
||
changed_when: false
|
||
|
||
- name: Display StorageClasses
|
||
ansible.builtin.debug:
|
||
msg: "{{ sc_list.stdout_lines }}"
|
||
run_once: true
|