Files
K3S/addons/csi-nfs/role/tasks/main.yml
2026-04-24 21:01:26 +03:00

98 lines
2.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- 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