Compare commits
10 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
4676c7f207 | |
|
|
d308cbde66 | |
|
|
745f941573 | |
|
|
160e3d2a79 | |
|
|
5df504b09c | |
|
|
78cc2e5dab | |
|
|
1f2e965b8d | |
|
|
f4f9594c8b | |
|
|
34107156c6 | |
|
|
b2b87fd120 |
|
|
@ -1,2 +1,2 @@
|
|||
**/inventory.ini
|
||||
.vscode/settings.json
|
||||
.idea
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
[developers]
|
||||
192.168.2.39 ansible_user=developers ansible_password=developers ansible_become_pass=developers
|
||||
|
|
@ -1,29 +1,28 @@
|
|||
# Роль Ansible: Инициализация кластера K8s
|
||||
# Роль Ansible: node-exporters-common
|
||||
|
||||
## Описание
|
||||
|
||||
Данная роль предназначена для базовой настройки и инициализации кластера Kubernetes. В рамках выполнения роли:
|
||||
Данная роль предназначена для установки и настройки **Node Exporter** для сбора метрик с хостов и их отправки в Prometheus. В рамках выполнения роли:
|
||||
|
||||
1. Обновляются и очищаются пакеты системы.
|
||||
2. Удаляются старые репозитории и GPG-ключи Kubernetes и CRI-O.
|
||||
3. Отключается swap.
|
||||
4. Загружаются необходимые модули ядра и включается пересылка IPv4-трафика.
|
||||
5. Устанавливаются базовые пакеты и инструменты для работы с Kubernetes.
|
||||
6. Добавляются репозитории и GPG-ключи Kubernetes и CRI-O.
|
||||
7. Устанавливаются `kubelet`, `kubeadm`, `kubectl`, а также `cri-o`.
|
||||
8. Включается и запускается служба `cri-o`.
|
||||
1. Устанавливается и запускается контейнер **Node Exporter**.
|
||||
2. Настроены необходимые параметры для работы контейнера, включая монтирование файловой системы хоста и правильную настройку прав.
|
||||
3. Контейнер настраивается с использованием параметров, таких как `--path.rootfs=/host` для корректной работы с файловой системой хоста.
|
||||
|
||||
## Требования
|
||||
|
||||
- Поддерживаемая версия ОС: Debian/Ubuntu
|
||||
- Поддерживаемая версия ОС: Debian/Ubuntu, CentOS, RHEL
|
||||
- Установлен Docker на целевых хостах.
|
||||
- Ansible с правами `root` (например, через `become: yes`)
|
||||
|
||||
## Переменные роли
|
||||
## TODO: Переменные роли
|
||||
|
||||
| Переменная | Значение по умолчанию |
|
||||
|---------------|--------------------|
|
||||
| `k8s_version` | `v1.31` |
|
||||
| `crio_version` | `v1.30` |
|
||||
| Переменная | Значение по умолчанию | Описание |
|
||||
|--------------------------|----------------------------------------|----------|
|
||||
| `node_exporter_image` | `quay.io/prometheus/node-exporter:latest` | Образ контейнера для Node Exporter |
|
||||
| `node_exporter_container_name` | `node_exporter` | Имя контейнера Node Exporter |
|
||||
| `node_exporter_restart_policy` | `always` | Политика перезапуска контейнера |
|
||||
| `node_exporter_volumes` | `['/host:/host:ro,rslave']` | Монтирование томов для доступа к файловой системе хоста |
|
||||
| `node_exporter_command` | `'--path.rootfs=/host'` | Команда для запуска контейнера |
|
||||
|
||||
## Зависимости
|
||||
|
||||
|
|
@ -37,9 +36,4 @@
|
|||
- hosts: all
|
||||
become: yes
|
||||
roles:
|
||||
- common-kubernetes
|
||||
```
|
||||
|
||||
## Автор
|
||||
|
||||
Автор: [Юрий Обрезков]
|
||||
- node-exporters-common
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
[prometheus]
|
||||
192.168.2.34 ansible_user=user ansible_password=k8sstand1 ansible_become_pass=k8sstand1
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# defaults file for cadvisor-common
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# handlers file for cadvisor-common
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
- name: install cadvisor
|
||||
community.docker.docker_container:
|
||||
name: cadvisor
|
||||
image: gcr.io/cadvisor/cadvisor:latest
|
||||
restart_policy: always
|
||||
detach: true
|
||||
ports:
|
||||
- 9101:8080
|
||||
volumes:
|
||||
- '/:/rootfs:ro'
|
||||
- '/var/run:/var/run:ro'
|
||||
- '/sys:/sys:ro'
|
||||
- '/var/lib/docker/:/var/lib/docker:ro'
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
localhost
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- cadvisor-common
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# vars file for cadvisor-common
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# defaults file for node-exporters-common
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
- name: install node exporter
|
||||
community.docker.docker_container:
|
||||
name: node_exporter
|
||||
image: quay.io/prometheus/node-exporter:latest
|
||||
restart_policy: always
|
||||
command: '--path.rootfs=/host'
|
||||
network_mode: host
|
||||
pid_mode: host
|
||||
volumes:
|
||||
- '/:/host:ro,rslave'
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
localhost
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- node-exporters-common
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# vars file for node-exporters-common
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[defaults]
|
||||
roles_path = ./roles:../docker/roles:../k8s/roles:../monitoring/roles:../ssh/roles:../node-exporters/roles
|
||||
|
||||
inventory = ./inventory.ini
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
$ANSIBLE_VAULT;1.1;AES256
|
||||
37363438356361313835356463333732653863666533313565623366356137343764343864393636
|
||||
6466363730386333316133633131333233316464356331650a643965363565323664383864366538
|
||||
31353863393762653931376461663738313731326635363630666534653839386539366535383334
|
||||
6161666538366133650a383338343935323133323862353663383761303238623336626336663365
|
||||
65656634636461636232383832616462666362616531333662643361373933626264653632643838
|
||||
62623865626638303864353062343539643330383331383563636634656165383764393161613866
|
||||
36366635626130366130643135363864326337666132643333616230303633373931303432643365
|
||||
33356265316239646436303561333661666466666332353934363261343733646133316339626166
|
||||
34643436323731333732356431393731306434643131393732346664643634626161383761656566
|
||||
31393431376463373437303430316233353337636536623631666239316461393363386161343565
|
||||
32313461656361353037333264613933646264383636626234303336316532636238386462306465
|
||||
62346139626164663766313930303864396361333832343566333564646335326133316630643733
|
||||
63333562366330663366363837653436333830656235623530363538396237613762316131396465
|
||||
35303565656666633635356164363339656161303839366637613963633934333635373831376339
|
||||
30393163366339316333346331656439353736636137636165306631393566646364616332346131
|
||||
35323030326439313938316431393332383464383362313631306265646537653761316538363065
|
||||
31376239366363353533386465616366356133303334663565646532333438376330643564636435
|
||||
33636639376465356637343635373133346266326265393930626536363939316539643666636133
|
||||
64636366333534393862303832613935653864663639653638323336323166646237663432663265
|
||||
37346162346163646163313732306232623362643563343232643138656266373430306238376135
|
||||
38313336323236366262373535316634656163313433383439383238323239373765353532313830
|
||||
35613735633430646536653466383936396436643739363831336565313332393464643635616365
|
||||
39336330363865663831306333623536663462613263623534653632316336623230626434316632
|
||||
35323561376333373634313964663238383365656535373634386235313932393165336537626662
|
||||
36386534333735303535333431653163343531353439633764323837303732363565613035656262
|
||||
65373437613962343134633534373465363362646464313631373765613465303563616532623330
|
||||
66343962303334313962373538613666313732656363633864333166343036396236316533303061
|
||||
38616564336238396263653035323136343861363864336261396265636161636566633531643562
|
||||
37663233386131383563336331353433346431653261363735396562353063646437383762633137
|
||||
36646332666439346265373061366165666239343533326337366335663039353433316337353461
|
||||
33326138636535386238386563653430623661323335396434376532313739643265633331646130
|
||||
33633230653463326639376634303336653433656131303437336634663334646631336435343234
|
||||
38386239396662306137383137656230366332353535393163636233643039643137626639323632
|
||||
34653636323137623932313634336461336363333033333636613332663232373236646639396232
|
||||
61666131623431376233616261373361383432323336323931653934363031366637363036643163
|
||||
62646239633562396137613063356233643734356362393365643237383365363037383436303337
|
||||
62396534633334383761616436363531366336313831613539313039323039623135656432636461
|
||||
64656639643239663938656161646632383634653137626638653337333235653534393439356662
|
||||
396663306633323131663233306262363962
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
- name: Install node exporter
|
||||
become: true
|
||||
hosts: monitoring
|
||||
tasks:
|
||||
- name: Verify if Docker is installed
|
||||
command: "docker version"
|
||||
register: docker_rc
|
||||
ignore_errors: true
|
||||
|
||||
- name: Install Docker if not installed
|
||||
include_role:
|
||||
name: docker-common
|
||||
when: docker_rc.rc != 0
|
||||
|
||||
- name: Install node exporter container
|
||||
include_role:
|
||||
name: node-exporters-common
|
||||
- name: Install cadvisor container
|
||||
include_role:
|
||||
name: cadvisor-common
|
||||
Loading…
Reference in New Issue