Обновить ansible/k8s_post_install.yml

This commit is contained in:
2025-12-28 18:25:23 +00:00
parent c6d8951d2c
commit 8038ca3e12

View File

@@ -1,54 +1,38 @@
--- ---
- name: 1. Исправление сетевых путей (CNI Fix) - name: CNI Fix
hosts: masters,workers hosts: k8s_nodes
become: true become: true
tasks: tasks:
- name: Создание симлинка для Cilium CNI (Debian 13 Fix) - name: Create CNI symlink
shell: | shell: |
mkdir -p /usr/lib/cni mkdir -p /usr/lib/cni
ln -sf /opt/cni/bin/cilium-cni /usr/lib/cni/cilium-cni ln -sf /opt/cni/bin/cilium-cni /usr/lib/cni/cilium-cni
changed_when: true changed_when: true
- name: Перезапуск Kubelet - name: Restart Kubelet
# ИСПОРАВЛЕНО: используем правильный модуль service вместо systemctl shell: systemctl restart kubelet
service:
name: kubelet
state: restarted
- name: 2. Настройка ресурсов кластера (Storage & Network) - name: Cluster Resources
hosts: masters hosts: masters_group
become: false become: false
vars:
ip_range: "{{ metallb_ip_range | default('10.33.33.210-10.33.33.250') }}"
tasks: tasks:
- name: Установка Local Path Provisioner (Storage) - name: Install Storage
shell: | shell: kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
- name: Установка StorageClass по умолчанию - name: Install MetalLB
shell: | shell: kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
- name: Wait for MetalLB
shell: kubectl wait --namespace metallb-system --for=condition=ready pod -l app=metallb,component=controller --timeout=120s
ignore_errors: true ignore_errors: true
- name: Установка MetalLB (Manifest) - name: Fix Webhook
shell: | shell: kubectl delete validatingwebhookconfiguration metallb-webhook-configuration
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml
- name: Ожидание запуска MetalLB Controller
shell: |
kubectl wait --namespace metallb-system --for=condition=ready pod -l app=metallb,component=controller --timeout=120s
changed_when: false
ignore_errors: true ignore_errors: true
- name: Удаление блокирующего Webhook - name: Config IP Pool
shell: | shell: |
kubectl delete validatingwebhookconfiguration metallb-webhook-configuration cat <<EOF | kubectl apply -f -
ignore_errors: true
- name: Создание временного файла конфигурации IP Pool
copy:
dest: /tmp/ippool_config.yaml
content: |
apiVersion: metallb.io/v1beta1 apiVersion: metallb.io/v1beta1
kind: IPAddressPool kind: IPAddressPool
metadata: metadata:
@@ -56,40 +40,11 @@
namespace: metallb-system namespace: metallb-system
spec: spec:
addresses: addresses:
- {{ ip_range }} - 10.33.33.210-10.33.33.250
--- ---
apiVersion: metallb.io/v1beta1 apiVersion: metallb.io/v1beta1
kind: L2Advertisement kind: L2Advertisement
metadata: metadata:
name: l2-adv name: l2-adv
namespace: metallb-system namespace: metallb-system
EOF
- name: Применение конфигурации IP Pool
shell: |
kubectl apply -f /tmp/ippool_config.yaml
- name: Удаление временного файла
file:
path: /tmp/ippool_config.yaml
state: absent
- name: 3. Финальная проверка
hosts: masters
tasks:
- name: Проверка статуса узлов
shell: |
kubectl get nodes
register: nodes_out
- name: Список запущенных подов
shell: |
kubectl get pods -A
register: pods_out
- name: Вывод статуса кластера
debug:
msg:
- "УЗЛЫ:"
- "{{ nodes_out.stdout_lines }}"
- "ПОДЫ:"
- "{{ pods_out.stdout_lines }}"