Обновить ansible/k8s_post_install.yml
This commit is contained in:
@@ -1,58 +1,88 @@
|
|||||||
---
|
---
|
||||||
- name: Финальная настройка узлов (CNI Fix)
|
- name: 1. Исправление сетевых путей (CNI Fix)
|
||||||
hosts: masters,workers
|
hosts: masters,workers
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: Исправление путей CNI для Debian 13
|
- name: Создание симлинка для Cilium CNI (Debian 13 Fix)
|
||||||
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 для применения CNI
|
- name: Перезапуск Kubelet
|
||||||
systemctl:
|
systemctl:
|
||||||
name: kubelet
|
name: kubelet
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: Настройка ресурсов кластера (Storage & Network)
|
- name: 2. Настройка ресурсов кластера (Storage & Network)
|
||||||
hosts: masters
|
hosts: masters
|
||||||
become: false # Выполняем от ubuntu через kubectl
|
become: false
|
||||||
|
vars:
|
||||||
|
# Эта переменная должна быть задана в Semaphore Survey
|
||||||
|
# Если не задана, используем дефолт
|
||||||
|
ip_range: "{{ metallb_ip_range | default('10.33.33.210-10.33.33.250') }}"
|
||||||
tasks:
|
tasks:
|
||||||
- name: 1. Установка Local Path Provisioner (Storage)
|
- name: Установка Local Path Provisioner (Storage)
|
||||||
kubernetes.core.k8s:
|
shell: kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
|
||||||
src: https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: 2. Установка StorageClass по умолчанию
|
- name: Установка StorageClass по умолчанию
|
||||||
shell: |
|
shell: kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
|
||||||
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
|
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: 3. Установка MetalLB (Manifest)
|
- name: Установка MetalLB (Manifest)
|
||||||
kubernetes.core.k8s:
|
shell: kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml
|
||||||
src: https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: 4. Ожидание запуска MetalLB Controller
|
- name: Ожидание запуска MetalLB Controller (может занять время)
|
||||||
shell: kubectl wait --namespace metallb-system --for=condition=ready pod -l app=metallb,component=controller --timeout=300s
|
shell: kubectl wait --namespace metallb-system --for=condition=ready pod -l app=metallb,component=controller --timeout=120s
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: 5. Удаление блокирующего Webhook (Fix "operation not permitted")
|
- name: Удаление блокирующего Webhook (Fix "operation not permitted")
|
||||||
shell: kubectl delete validatingwebhookconfiguration metallb-webhook-configuration
|
shell: kubectl delete validatingwebhookconfiguration metallb-webhook-configuration
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: 6. Применение конфигурации IP Pool
|
- name: Создание временного файла конфигурации IP Pool
|
||||||
kubernetes.core.k8s:
|
copy:
|
||||||
definition: "{{ lookup('template', 'templates/ippool.j2') }}"
|
dest: /tmp/ippool_config.yaml
|
||||||
state: present
|
content: |
|
||||||
|
apiVersion: metallb.io/v1beta1
|
||||||
|
kind: IPAddressPool
|
||||||
|
metadata:
|
||||||
|
name: main-pool
|
||||||
|
namespace: metallb-system
|
||||||
|
spec:
|
||||||
|
addresses:
|
||||||
|
- {{ ip_range }}
|
||||||
|
---
|
||||||
|
apiVersion: metallb.io/v1beta1
|
||||||
|
kind: L2Advertisement
|
||||||
|
metadata:
|
||||||
|
name: l2-adv
|
||||||
|
namespace: metallb-system
|
||||||
|
|
||||||
- name: Проверка готовности кластера
|
- name: Применение конфигурации IP Pool
|
||||||
|
shell: kubectl apply -f /tmp/ippool_config.yaml
|
||||||
|
|
||||||
|
- name: Удаление временного файла
|
||||||
|
file:
|
||||||
|
path: /tmp/ippool_config.yaml
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: 3. Финальная проверка
|
||||||
hosts: masters
|
hosts: masters
|
||||||
tasks:
|
tasks:
|
||||||
- name: Get Nodes Status
|
- name: Проверка статуса узлов
|
||||||
shell: kubectl get nodes
|
shell: kubectl get nodes
|
||||||
register: nodes_status
|
register: nodes_out
|
||||||
|
|
||||||
- name: Show Nodes
|
- name: Список запущенных подов во всех неймспейсах
|
||||||
|
shell: kubectl get pods -A
|
||||||
|
register: pods_out
|
||||||
|
|
||||||
|
- name: Вывод статуса кластера
|
||||||
debug:
|
debug:
|
||||||
var: nodes_status.stdout_lines
|
msg:
|
||||||
|
- "УЗЛЫ:"
|
||||||
|
- "{{ nodes_out.stdout_lines }}"
|
||||||
|
- "ПОДЫ:"
|
||||||
|
- "{{ pods_out.stdout_lines }}"
|
||||||
Reference in New Issue
Block a user