Добавить ansible/k8s_post_install.yml

This commit is contained in:
2025-12-28 17:38:56 +00:00
parent 0aa00c770d
commit b2ce85c63d

View File

@@ -0,0 +1,58 @@
---
- name: Финальная настройка узлов (CNI Fix)
hosts: masters,workers
become: true
tasks:
- name: Исправление путей CNI для Debian 13
shell: |
mkdir -p /usr/lib/cni
ln -sf /opt/cni/bin/cilium-cni /usr/lib/cni/cilium-cni
changed_when: true
- name: Перезапуск Kubelet для применения CNI
systemctl:
name: kubelet
state: restarted
- name: Настройка ресурсов кластера (Storage & Network)
hosts: masters
become: false # Выполняем от ubuntu через kubectl
tasks:
- name: 1. Установка Local Path Provisioner (Storage)
kubernetes.core.k8s:
src: https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
state: present
- name: 2. Установка StorageClass по умолчанию
shell: |
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
ignore_errors: true
- name: 3. Установка MetalLB (Manifest)
kubernetes.core.k8s:
src: https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml
state: present
- name: 4. Ожидание запуска MetalLB Controller
shell: kubectl wait --namespace metallb-system --for=condition=ready pod -l app=metallb,component=controller --timeout=300s
changed_when: false
- name: 5. Удаление блокирующего Webhook (Fix "operation not permitted")
shell: kubectl delete validatingwebhookconfiguration metallb-webhook-configuration
ignore_errors: true
- name: 6. Применение конфигурации IP Pool
kubernetes.core.k8s:
definition: "{{ lookup('template', 'templates/ippool.j2') }}"
state: present
- name: Проверка готовности кластера
hosts: masters
tasks:
- name: Get Nodes Status
shell: kubectl get nodes
register: nodes_status
- name: Show Nodes
debug:
var: nodes_status.stdout_lines