небольше фиксы

This commit is contained in:
Sergey Antropoff
2026-04-24 21:01:26 +03:00
parent e99f1d5dfb
commit 8aa55a694c
65 changed files with 936 additions and 469 deletions

View File

@@ -1,20 +1,20 @@
---
# ─────────────────────────────────────────────────────────────────────────────
# K3S Full Stack Playbook
# Порядок установки:
# 0. Chrony (синхронизация времени — ОБЯЗАТЕЛЬНО до k3s)
# 1. K3S cluster (master → workers)
# 2. kube-vip (VIP для control plane + LoadBalancer)
# 3. NFS Server (на master или отдельном хосте)
# 4. CSI NFS Driver (StorageClass для PVC)
# 5. ingress-nginx (Ingress controller через Helm)
# K3S Core Stack — разворачивает кластер без аддонов.
#
# Запуск: ansible-playbook playbooks/site.yml --ask-vault-pass
# Только отдельный компонент: ansible-playbook playbooks/site.yml --tags kube_vip
# Порядок:
# 0. Chrony — синхронизация времени (обязательно до k3s)
# 1. K3S — кластер (master → workers)
# 2. Helm — устанавливается на мастер-ноды (нужен аддонам)
# 3. CNI — сетевой плагин (calico/cilium; flannel встроен)
# 4. kube-vip — VIP для control plane + LoadBalancer
# 5. k3s-certs — systemd таймер авторотации сертификатов
#
# Аддоны устанавливаются отдельно: make addon-<name>
# Полный стек с аддонами: make install-full
# ─────────────────────────────────────────────────────────────────────────────
# ── 0. Chrony — синхронизация времени (обязательно до k3s) ───────────────────
# Расхождение времени нарушает работу etcd, TLS и Kubernetes API
# ── 0. Chrony — синхронизация времени ────────────────────────────────────────
- name: Configure time synchronization (chrony)
hosts: k3s_cluster
gather_facts: true
@@ -24,7 +24,6 @@
- role: chrony
# ── 1. K3S Cluster ────────────────────────────────────────────────────────────
# serial: 1 — master01 запускается первым (cluster-init), остальные присоединяются
- name: Install K3S cluster (HA embedded etcd)
hosts: k3s_cluster
gather_facts: true
@@ -34,16 +33,39 @@
roles:
- role: k3s
# ── 2. CNI (calico/cilium; при flannel — пропускается) ───────────────────────
# ── 2. Helm на мастер-нодах ──────────────────────────────────────────────────
- name: Install Helm on master nodes
hosts: k3s_master
gather_facts: false
become: true
tags: [helm]
tasks:
- name: Check if Helm is installed
ansible.builtin.command: helm version --short
register: helm_check
failed_when: false
changed_when: false
- name: Download and install Helm
ansible.builtin.shell: |
set -o pipefail
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
args:
executable: /bin/bash
when: helm_check.rc != 0
retries: 3
delay: 5
# ── 3. CNI (calico/cilium; при flannel — пропускается) ──────────────────────
- name: Deploy CNI plugin
hosts: "{{ groups['k3s_master'][0] }}"
hosts: k3s_master[0]
gather_facts: false
become: true
tags: [cni]
roles:
- role: cni
# ── 3. kube-vip ───────────────────────────────────────────────────────────────
# ── 4. kube-vip ───────────────────────────────────────────────────────────────
- name: Deploy kube-vip (VIP + LoadBalancer)
hosts: k3s_master
gather_facts: true
@@ -52,63 +74,18 @@
roles:
- role: kube-vip
# ── 4. NFS Server ─────────────────────────────────────────────────────────────
- name: Configure NFS server
hosts: nfs_server
gather_facts: true
become: true
tags: [nfs, nfs_server]
roles:
- role: nfs-server
# ── 5. NFS client on all K3S nodes + CSI Driver ───────────────────────────────
- name: Deploy CSI NFS Driver
# ── 5. Certificate Auto-Rotation ─────────────────────────────────────────────
- name: Setup K3S certificate auto-rotation
hosts: k3s_cluster
gather_facts: true
become: true
tags: [nfs, csi_nfs]
tags: [certs, k3s_certs]
roles:
- role: csi-nfs
- role: k3s-certs
# ── 6. ingress-nginx ──────────────────────────────────────────────────────────
- name: Deploy ingress-nginx
hosts: k3s_cluster
gather_facts: true
become: true
tags: [ingress, ingress_nginx]
roles:
- role: ingress-nginx
# ── 7. cert-manager (опционально: cert_manager_enabled: true) ────────────────
- name: Deploy cert-manager
hosts: "{{ groups['k3s_master'][0] }}"
gather_facts: false
become: true
tags: [cert_manager, certmanager]
roles:
- role: cert-manager
# ── 8. Istio (опционально: istio_enabled: true) ───────────────────────────────
- name: Deploy Istio service mesh
hosts: "{{ groups['k3s_master'][0] }}"
gather_facts: false
become: true
tags: [istio]
roles:
- role: istio
# ── 9. kube-prometheus-stack (опционально: prometheus_stack_enabled: true) ─────
- name: Deploy kube-prometheus-stack
hosts: "{{ groups['k3s_master'][0] }}"
gather_facts: false
become: true
tags: [monitoring, prometheus]
roles:
- role: prometheus-stack
# ── Verify full stack ─────────────────────────────────────────────────────────
- name: Verify full stack
hosts: k3s_master
# ── Verify core stack ─────────────────────────────────────────────────────────
- name: Verify core stack
hosts: k3s_master[0]
gather_facts: false
become: true
tags: [verify]
@@ -126,33 +103,3 @@
changed_when: false
- ansible.builtin.debug:
msg: "{{ pods.stdout_lines }}"
- name: Services with External IPs
ansible.builtin.command: k3s kubectl get svc -A
register: svcs
changed_when: false
- ansible.builtin.debug:
msg: "{{ svcs.stdout_lines }}"
- name: StorageClasses
ansible.builtin.command: k3s kubectl get storageclass
register: sc
changed_when: false
- ansible.builtin.debug:
msg: "{{ sc.stdout_lines }}"
- name: IngressClasses
ansible.builtin.command: k3s kubectl get ingressclass
register: ic
changed_when: false
- ansible.builtin.debug:
msg: "{{ ic.stdout_lines }}"
# ── Certificate Auto-Rotation (systemd timer) ─────────────────────────────────
- name: Setup K3S certificate auto-rotation
hosts: k3s_cluster
gather_facts: true
become: true
tags: [certs, k3s_certs]
roles:
- role: k3s-certs