Обновить ansible/k8s_setup.yml
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
hosts: k8s_nodes
|
||||
become: true
|
||||
tasks:
|
||||
- name: Ожидание разблокировки APT
|
||||
- name: 0. Ожидание разблокировки APT
|
||||
shell: "while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 5; done;"
|
||||
changed_when: false
|
||||
|
||||
- name: Установка системных зависимостей
|
||||
- name: 1. Установка системных зависимостей
|
||||
apt:
|
||||
update_cache: yes
|
||||
name: [apt-transport-https, ca-certificates, curl, gnupg, qemu-guest-agent, socat, conntrack]
|
||||
@@ -17,7 +17,7 @@
|
||||
retries: 20
|
||||
delay: 10
|
||||
|
||||
- name: Настройка модулей и sysctl
|
||||
- name: 2. Настройка модулей и sysctl
|
||||
shell: |
|
||||
modprobe overlay && modprobe br_netfilter
|
||||
echo -e "overlay\nbr_netfilter" > /etc/modules-load.d/k8s.conf
|
||||
@@ -29,12 +29,12 @@
|
||||
sysctl --system
|
||||
changed_when: false
|
||||
|
||||
- name: Установка Containerd
|
||||
- name: 3. Установка Containerd
|
||||
apt:
|
||||
name: containerd
|
||||
state: present
|
||||
|
||||
- name: Конфигурация Containerd
|
||||
- name: 4. Конфигурация Containerd
|
||||
shell: |
|
||||
mkdir -p /etc/containerd
|
||||
containerd config default > /etc/containerd/config.toml
|
||||
@@ -42,12 +42,12 @@
|
||||
systemctl restart containerd
|
||||
changed_when: true
|
||||
|
||||
- name: Добавление репозитория Kubernetes (Tsinghua)
|
||||
- name: 5. Добавление репозитория Kubernetes (Tsinghua)
|
||||
shell: |
|
||||
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg --yes
|
||||
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/kubernetes/core:/stable:/v1.32/deb/ /" > /etc/apt/sources.list.d/kubernetes.list
|
||||
|
||||
- name: Установка пакетов Kubernetes
|
||||
- name: 6. Установка пакетов Kubernetes
|
||||
apt:
|
||||
name: [kubelet, kubeadm, kubectl]
|
||||
state: present
|
||||
@@ -83,4 +83,29 @@
|
||||
- name: Join to cluster
|
||||
shell: "{{ hostvars['k8s-master']['join_cmd']['stdout'] }}"
|
||||
args:
|
||||
creates: /etc/kubernetes/kubelet.conf
|
||||
creates: /etc/kubernetes/kubelet.conf
|
||||
|
||||
- name: Установка Cilium CNI (Слой сети)
|
||||
hosts: masters_group
|
||||
become: true
|
||||
tasks:
|
||||
- name: Скачивание Cilium CLI
|
||||
get_url:
|
||||
url: https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz
|
||||
dest: /tmp/cilium.tar.gz
|
||||
register: cilium_dl
|
||||
until: cilium_dl is success
|
||||
retries: 5
|
||||
delay: 10
|
||||
|
||||
- name: Распаковка Cilium CLI
|
||||
shell: tar xzvf /tmp/cilium.tar.gz -C /usr/local/bin
|
||||
args:
|
||||
creates: /usr/local/bin/cilium
|
||||
|
||||
- name: Установка Cilium в кластер
|
||||
# Выполняем как пользователь ubuntu, чтобы иметь доступ к кубеконфигу
|
||||
become: true
|
||||
become_user: ubuntu
|
||||
shell: /usr/local/bin/cilium install --set kubeProxyReplacement=true
|
||||
ignore_errors: true
|
||||
Reference in New Issue
Block a user