Add the installation of cadvisor.
This commit is contained in:
parent
83d5c6c3d3
commit
cc991c4b83
|
@ -1,7 +1,9 @@
|
|||
Role Name
|
||||
=========
|
||||
|
||||
A role that installs and configures Docker and eventually Docker Swarm, <https://docker.com>
|
||||
A role that installs and configures Docker and eventually prepares Docker Swarm, <https://docker.com>.
|
||||
The Docker Swarm nodes configuration is managed by a separate role.
|
||||
cAdvisor is also installed, as standalone package and not as container. The standalone package does not require a local Prometheus instance
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
|
|
@ -44,6 +44,14 @@ docker_prometheus_metrics: true
|
|||
docker_prometheus_host: 127.0.0.1
|
||||
docker_prometheus_metrics_port: 9323
|
||||
|
||||
# cAdvisor
|
||||
docker_swarm_cluster_cadvisor_install: true
|
||||
docker_swarm_cluster_cadvisor_deb_pkg: true
|
||||
docker_swarm_cluster_cadvisor_docker_endpoint: "unix:///var/run/docker.sock"
|
||||
docker_swarm_cluster_cadvisor_port: 4194
|
||||
docker_swarm_cluster_cadvisor_github_url: "https://github.com/google/cadvisor/releases/download/v0.47.0/cadvisor-v0.47.0-linux-amd64"
|
||||
docker_swarm_cluster_cadvisor_binary_path: /usr/local/bin/cadvisor
|
||||
|
||||
# Usage:
|
||||
# node.labels.<key_name>==<label_value>
|
||||
# node.labels.<key_name>!=<label_value>
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
- name: Manage the installation of cAdvisor deb package
|
||||
when: docker_swarm_cluster_cadvisor_deb_pkg
|
||||
tags: ['cadvisor', 'docker_cadvisor', 'docker_swarm', 'docker']
|
||||
block:
|
||||
- name: Install the cadvisor package
|
||||
ansible.builtin.apt:
|
||||
pkg: cadvisor
|
||||
state: present
|
||||
cache_valid_time: 1800
|
||||
|
||||
- name: Manage the installation of cAdvisor Linux binary from GitHub
|
||||
when: not docker_swarm_cluster_cadvisor_deb_pkg
|
||||
tags: ['cadvisor', 'docker_cadvisor', 'docker_swarm', 'docker']
|
||||
block:
|
||||
- name: Download the cAdvisor executable from GitHub
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ docker_swarm_cluster_cadvisor_github_url }}"
|
||||
dest: "{{ docker_swarm_cluster_cadvisor_binary_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Install the cAdvisor systemd unit
|
||||
ansible.builtin.template:
|
||||
src: cadvisor.systemd.j2
|
||||
dest: /lib/systemd/system/cadvisor.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: Restart cadvisor
|
||||
register: systemd_reload
|
||||
|
||||
- name: Reload the systemd unit
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
when: systemd_reload is changed
|
||||
|
||||
- name: Manage the cAdvisor service
|
||||
tags: ['cadvisor', 'docker_cadvisor', 'docker_swarm', 'docker']
|
||||
block:
|
||||
- name: Install the cadvisor default
|
||||
ansible.builtin.template:
|
||||
src: cadvisor.default.j2
|
||||
dest: /etc/default/cadvisor
|
||||
mode: 0600
|
||||
owner: root
|
||||
group: root
|
||||
notify: Restart cadvisor
|
||||
|
||||
- name: Ensure that the cAdvisor service is up and running
|
||||
ansible.builtin.service:
|
||||
name: cadvisor
|
||||
state: started
|
||||
enabled: true
|
|
@ -9,6 +9,9 @@
|
|||
when: ansible_distribution_file_variety == "RedHat"
|
||||
|
||||
- import_tasks: docker_setup.yml
|
||||
- name: Import the cAdvisor tasks
|
||||
ansible.builtin.import_tasks: cadvisor.yml
|
||||
when: docker_swarm_cluster_cadvisor_install
|
||||
|
||||
- import_tasks: swarm_mgr.yml
|
||||
when: docker_swarm
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# config options for cadvisor(1)
|
||||
#
|
||||
|
||||
# Docker endpoint to connect to
|
||||
# Default: unix:///var/run/docker.sock
|
||||
CADVISOR_DOCKER_ENDPOINT="{{ docker_swarm_cluster_cadvisor_docker_endpoint }}"
|
||||
|
||||
# Port to listen on
|
||||
# Default: 8080
|
||||
# kubernetes expects it on port 4194
|
||||
CADVISOR_PORT="{{ docker_swarm_cluster_cadvisor_port }}"
|
||||
|
||||
# Storage driver
|
||||
# Default: none/blank
|
||||
#
|
||||
# Available Options:
|
||||
# - [none]
|
||||
# - bigquery
|
||||
# - influxdb
|
||||
CADVISOR_STORAGE_DRIVER=""
|
||||
|
||||
# Storage driver host
|
||||
# Default: localhost:8086"
|
||||
CADVISOR_STORAGE_DRIVER_HOST="localhost:8086"
|
||||
|
||||
# Storage driver password
|
||||
# Default: root
|
||||
CADVISOR_STORAGE_DRIVER_PASSWORD="root"
|
||||
|
||||
# Storage driver secure connection
|
||||
# Default: false
|
||||
CADVISOR_STORAGE_DRIVER_SECURE="false"
|
||||
|
||||
# Storage driver user
|
||||
# Default: root
|
||||
CADVISOR_STORAGE_DRIVER_USER="root"
|
||||
|
||||
# Log to stderr ("true" logs to journal on systemd
|
||||
# and to "/var/log/cadvisor.log" on SysV)
|
||||
# Default: false
|
||||
CADVISOR_LOG_TO_STDERR="true"
|
||||
|
||||
# Other options:
|
||||
#DAEMON_ARGS=""
|
|
@ -0,0 +1,20 @@
|
|||
[Unit]
|
||||
Description=cAdvisor
|
||||
Documentation=man:cadvisor
|
||||
Documentation=https://github.com/google/cadvisor
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/etc/default/cadvisor
|
||||
ExecStart={{ docker_swarm_cluster_cadvisor_binary_path }} \
|
||||
--docker=${CADVISOR_DOCKER_ENDPOINT} \
|
||||
--port=${CADVISOR_PORT} \
|
||||
--storage_driver=${CADVISOR_STORAGE_DRIVER} \
|
||||
--storage_driver_host=${CADVISOR_STORAGE_DRIVER_HOST} \
|
||||
--storage_driver_password=${CADVISOR_STORAGE_DRIVER_PASSWORD} \
|
||||
--storage_driver_secure=${CADVISOR_STORAGE_DRIVER_SECURE} \
|
||||
--storage_driver_user=${CADVISOR_STORAGE_DRIVER_USER} \
|
||||
--logtostderr=${CADVISOR_LOG_TO_STDERR} \
|
||||
${DAEMON_ARGS}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue