-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* prometheus: use v2 * pass config vol to setup container
- Loading branch information
Showing
70 changed files
with
5,976 additions
and
1,435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ icon: https://media.sys.truenas.net/apps/prometheus/icons/icon.png | |
keywords: | ||
- metrics | ||
- prometheus | ||
lib_version: 1.1.7 | ||
lib_version_hash: d05e43e25b7dc1736be6cc1efa4b9255368aa346e3e7a4350a38440f29b73186 | ||
lib_version: 2.0.32 | ||
lib_version_hash: 4a0bf69cccda322e191eab36ab81ca6d0c8e5d64a0b2fa117c609804b55b86c6 | ||
maintainers: | ||
- email: [email protected] | ||
name: truenas | ||
|
@@ -30,4 +30,4 @@ sources: | |
- https://prometheus.io | ||
title: Prometheus | ||
train: stable | ||
version: 1.1.18 | ||
version: 1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 55 additions & 102 deletions
157
ix-dev/stable/prometheus/templates/docker-compose.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,63 @@ | ||
{# Stores storage items that contains info for volumes, vol mounts, perms dirs and perms mounts #} | ||
{% set storage_items = namespace(items=[]) %} | ||
{# Stores the top level volumes #} | ||
{% set volumes = namespace(items={}) %} | ||
{# Stores the container volume mounts #} | ||
{% set volume_mounts = namespace(items=[]) %} | ||
{# Stores the perms container volume mounts #} | ||
{% set perms_mounts = namespace(items=[]) %} | ||
{# Stores the perms container dirs #} | ||
{% set perms_dirs = namespace(items=[]) %} | ||
{% from "macros/init.sh" import init %} | ||
|
||
{% do storage_items.items.append(ix_lib.base.storage.storage_item(data=dict(values.storage.config, **{"mount_path": values.consts.config_path}), | ||
values=values, perm_opts={"mount_path": "/mnt/prometheus/config", "mode": "check", "uid": values.run_as.user, "gid": values.run_as.group} | ||
)) %} | ||
{% do storage_items.items.append(ix_lib.base.storage.storage_item(data=dict(values.storage.data, **{"mount_path": values.consts.data_path}), | ||
values=values, perm_opts={"mount_path": "/mnt/prometheus/data", "mode": "check", "uid": values.run_as.user, "gid": values.run_as.group} | ||
)) %} | ||
{% do storage_items.items.append(ix_lib.base.storage.storage_item(data={"type":"anonymous", "mount_path": "/tmp"})) %} | ||
{% set tpl = ix_lib.base.render.Render(values) %} | ||
|
||
{% for store in values.storage.additional_storage %} | ||
{% do storage_items.items.append(ix_lib.base.storage.storage_item(data=store, values=values, | ||
perm_opts={"mount_path": "/mnt/prometheus/dir_%s"|format(loop.index0), "mode": "check", "uid": values.run_as.user, "gid": values.run_as.group} | ||
)) %} | ||
{% endfor %} | ||
{% set setup = tpl.add_container(values.consts.init_container_name, "image") %} | ||
|
||
{% do setup.set_user(values.run_as.user, values.run_as.group) %} | ||
{% do setup.healthcheck.disable() %} | ||
{% do setup.remove_devices() %} | ||
{% do setup.restart.set_policy("on-failure", 1) %} | ||
{% do setup.deploy.resources.set_profile("low") %} | ||
{% do setup.configs.add("init.sh", init(values), "/init.sh", "0755") %} | ||
{% do setup.set_entrypoint(["/bin/sh", "-c", "/init.sh"]) %} | ||
|
||
{% set c1 = tpl.add_container(values.consts.prometheus_container_name, "image") %} | ||
{% set perm_container = tpl.deps.perms(values.consts.perms_container_name) %} | ||
{% set perms_config = {"uid": values.run_as.user, "gid": values.run_as.group, "mode": "check"} %} | ||
|
||
{# Add each item to the above lists #} | ||
{% for item in storage_items.items %} | ||
{% if item.vol and volumes.items.update(item.vol) %}{% endif %} | ||
{% if item.vol_mount and volume_mounts.items.append(item.vol_mount) %}{% endif %} | ||
{% if item.perms_item and (perms_dirs.items.append(item.perms_item.perm_dir), perms_mounts.items.append(item.perms_item.vol_mount)) %}{% endif %} | ||
{% do c1.set_user(values.run_as.user, values.run_as.group) %} | ||
|
||
{% do c1.healthcheck.set_test("wget", {"port": values.network.web_port, "path": "/-/healthy"}) %} | ||
{% do c1.depends.add_dependency(values.consts.init_container_name, "service_completed_successfully") %} | ||
|
||
{% set cmd = namespace(x=[ | ||
"--web.listen-address=0.0.0.0:%d"|format(values.network.web_port), | ||
"--storage.tsdb.path=%s"|format(values.consts.data_path), | ||
"--config.file=%s/prometheus.yml"|format(values.consts.config_path), | ||
"--storage.tsdb.retention.time=%s"|format(values.prometheus.retention_time), | ||
]) %} | ||
{% if values.prometheus.retention_size %} | ||
{% do cmd.x.append("--storage.tsdb.retention.size=%s"|format(values.prometheus.retention_size)) %} | ||
{% endif %} | ||
{% if values.prometheus.wal_compression %} | ||
{% do cmd.x.append("--storage.tsdb.wal-compression") %} | ||
{% endif %} | ||
{% for arg in values.prometheus.additional_args %} | ||
{% do cmd.x.append(arg) %} | ||
{% endfor %} | ||
|
||
{# Containers #} | ||
services: | ||
{{ values.consts.init_container_name }}: | ||
image: {{ ix_lib.base.utils.get_image(images=values.images, name="image") }} | ||
user: {{ "%d:%d" | format(values.run_as.user, values.run_as.group) }} | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "1.0" | ||
memory: 512m | ||
{% if perms_dirs.items %} | ||
depends_on: | ||
{{ values.consts.perms_container_name }}: | ||
condition: service_completed_successfully | ||
{% endif %} | ||
entrypoint: | ||
- sh | ||
- -c | ||
command: | ||
- | | ||
if [ ! -f {{ values.consts.config_path }}/prometheus.yml ]; then | ||
touch {{ values.consts.config_path }}/prometheus.yml | ||
fi | ||
volumes: {{ volume_mounts.items | tojson }} | ||
{{ values.consts.prometheus_container_name }}: | ||
user: {{ "%d:%d" | format(values.run_as.user, values.run_as.group) }} | ||
image: {{ ix_lib.base.utils.get_image(images=values.images, name="image") }} | ||
restart: unless-stopped | ||
command: | ||
- --web.listen-address=0.0.0.0:{{ values.network.web_port }} | ||
- --storage.tsdb.path={{ values.consts.data_path }} | ||
- --config.file={{ values.consts.config_path }}/prometheus.yml | ||
- --storage.tsdb.retention.time={{ values.prometheus.retention_time }} | ||
{% if values.prometheus.retention_size %} | ||
- --storage.tsdb.retention.size={{ values.prometheus.retention_size }} | ||
{% endif %} | ||
{% if values.prometheus.wal_compression %} | ||
- --storage.tsdb.wal-compression | ||
{% endif %} | ||
{% for arg in values.prometheus.additional_args %} | ||
- {{ arg | tojson }} | ||
{% endfor %} | ||
deploy: | ||
resources: {{ ix_lib.base.resources.resources(values.resources) | tojson }} | ||
devices: {{ ix_lib.base.resources.get_devices(values.resources) | tojson }} | ||
depends_on: | ||
{{ values.consts.init_container_name }}: | ||
condition: service_completed_successfully | ||
{% if perms_dirs.items %} | ||
{{ values.consts.perms_container_name }}: | ||
condition: service_completed_successfully | ||
{% endif %} | ||
{% if values.network.host_network %} | ||
network_mode: host | ||
{% endif %} | ||
cap_drop: {{ ix_lib.base.security.get_caps().drop | tojson }} | ||
security_opt: {{ ix_lib.base.security.get_sec_opts() | tojson }} | ||
{% if values.network.dns_opts %} | ||
dns_opt: {{ ix_lib.base.network.dns_opts(values.network.dns_opts) | tojson }} | ||
{% endif %} | ||
{% set test = ix_lib.base.healthchecks.wget_test(port=values.network.web_port, path="/-/healthy") %} | ||
healthcheck: {{ ix_lib.base.healthchecks.check_health(test) | tojson }} | ||
environment: {{ ix_lib.base.environment.envs(app={}, user=values.prometheus.additional_envs, values=values) | tojson }} | ||
{% if not values.network.host_network %} | ||
ports: | ||
- {{ ix_lib.base.ports.get_port(port={"target": values.network.web_port, "published": values.network.web_port}) | tojson }} | ||
{% endif %} | ||
volumes: {{ volume_mounts.items | tojson }} | ||
{% if perms_dirs.items %} | ||
{{ values.consts.perms_container_name }}: {{ ix_lib.base.permissions.perms_container(items=perms_dirs.items, volumes=perms_mounts.items) | tojson }} | ||
{% endif %} | ||
{% do c1.set_command(cmd.x) %} | ||
|
||
{% do c1.environment.add_user_envs(values.prometheus.additional_envs) %} | ||
{% do c1.ports.add_port(values.network.web_port, values.network.web_port) %} | ||
|
||
{% if volumes.items %} | ||
volumes: {{ volumes.items | tojson }} | ||
{% do c1.add_storage(values.consts.config_path, values.storage.config) %} | ||
{% do setup.add_storage(values.consts.config_path, values.storage.config) %} | ||
{% do perm_container.add_or_skip_action("config", values.storage.config, perms_config) %} | ||
{% do c1.add_storage(values.consts.data_path, values.storage.data) %} | ||
{% do perm_container.add_or_skip_action("data", values.storage.data, perms_config) %} | ||
|
||
{% for store in values.storage.additional_storage %} | ||
{% do c1.add_storage(store.mount_path, store) %} | ||
{% do perm_container.add_or_skip_action(store.mount_path, store, perms_config) %} | ||
{% endfor %} | ||
|
||
{% if perm_container.has_actions() %} | ||
{% do perm_container.activate() %} | ||
{% do c1.depends.add_dependency(values.consts.perms_container_name, "service_completed_successfully") %} | ||
{% endif %} | ||
|
||
x-portals: {{ ix_lib.base.metadata.get_portals([{"port": values.network.web_port}]) | tojson }} | ||
x-notes: {{ ix_lib.base.metadata.get_notes("Prometheus") | tojson }} | ||
{% do tpl.portals.add_portal({"port": values.network.web_port}) %} | ||
|
||
{{ tpl.render() | tojson }} |
98 changes: 0 additions & 98 deletions
98
ix-dev/stable/prometheus/templates/library/base_v1_1_7/environment.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.