Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting files for APCUPSD Addon #101

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d710d2f
Adds apcupsd_image template
danimbrogno Jun 8, 2023
1a1d2fc
Adds override tmpl
danimbrogno Jun 8, 2023
2564908
fix reference to container tag
danimbrogno Jun 8, 2023
86d4857
fix tabbing on networks key
danimbrogno Jun 8, 2023
7980c92
make volume rw
danimbrogno Jun 8, 2023
fe30c82
Adds environment variables
danimbrogno Jun 8, 2023
cb9e643
remove quotes from env variable definition
danimbrogno Jun 8, 2023
13e7df2
fix bad env variable name
danimbrogno Jun 8, 2023
994d9b0
add quotes to string variables
danimbrogno Jun 8, 2023
0948655
try multi container setup
danimbrogno Jun 9, 2023
dcda5c7
Updates networking config
danimbrogno Jun 9, 2023
8614809
Mount custom apcupsd.conf
danimbrogno Jun 9, 2023
af466ac
Mount custom apcupsd.conf
danimbrogno Jun 9, 2023
5ab242a
change location to expect apcupsd.conf
danimbrogno Jun 9, 2023
9b58079
prefix filename
danimbrogno Jun 9, 2023
c70dbc3
Add a blank file so it can be overwritten by the cli
danimbrogno Jun 9, 2023
2c9dbb9
update install script
danimbrogno Jun 9, 2023
78ebac6
Add TODO comment
danimbrogno Jun 9, 2023
c5d2cc7
Update configuration to allow external connections
danimbrogno Jun 9, 2023
6e4d84d
Update to use a collector
danimbrogno Jun 12, 2023
70c1e9c
update prometheus template and add container to network
danimbrogno Jun 13, 2023
bd2dfc4
Fix addon_apcupsd on wrong network
danimbrogno Jun 13, 2023
90b25fd
add docker host gateway to exporter
danimbrogno Jun 13, 2023
e896592
Split compose config into two variants
danimbrogno Jun 13, 2023
3c0cc28
Comment out services defined in overrides folder to avoid undefined s…
danimbrogno Jun 13, 2023
9d1d1c8
No need to publish ports on host
danimbrogno Jun 13, 2023
596d3cb
Allow for changing metrics port
danimbrogno Jun 13, 2023
8eda5c1
No need to copy the apcupsd config file
danimbrogno Jun 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install/addon_apcupsd.conf
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will be populated with an apcupsd.conf by the cli if the user enables running apcupsd in a container. This file is present in the installer so that it has the correct permissions to be overwritten by the cli.

Please let me know if there is a preffered file path to use here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this to install/addons/apcupsd/addon_apcupsd.conf - all of the addon-specific files will go into that folder and get mounted as a volume in your container.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Intentionally blank
11 changes: 11 additions & 0 deletions install/override/addons/apcupsd/addon_apcupsd.yml
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this addon may optionally run 1 or 2 containers depending on it's configuration I have commented out the services: definition.

In the scenario where a user does not want to run apcupsd in a container, the addon_apcupsd.network.tmpl template will be used which does not define the service "addon_apcupsd". If these files were uncommented, the cli would complain that "addon_apcupsd" does not have an image / build context specified.

Let me know if there is a more elegant solution here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best way to do this is one template file per container, so I'll break it out into two separate files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I want to flag that you'll want to test that the service sucessfully restarts when toggling between "Container" and "Network" mode. Keep a look out for a bug where the service tries and fails to start the apcupsd container even though we don't need this container because we are running in network mode. This happened due to the presence of an (empty) service definition inside the overrides folder.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Enter your own customizations for the APCUPSD Addon container here. These changes will persist after upgrades, so you only need to do them once.
#
# See https://docs.docker.com/compose/extends/#adding-and-overriding-configuration
# for more information on overriding specific parameters of docker-compose files.

version: "3.7"
#services:
# addon_apcupsd:
# x-rp-comment: Add your customizations below this line
# addon_apcupsd_exporter:
# x-rp-comment: Add your customizations below this line
6 changes: 5 additions & 1 deletion install/prometheus.tmpl
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: This apcupsd job is added to the prometheus config regardless of whether the user has the addon enabled. I don't think this is an issue as it fails to fetch the metrics silently, but perhaps it is additional overhead we would not want to add? Let me know if there is a method to conditionally add items to this configuration file based on an environment variable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think failing silently in this case is fine, we already do it (geth and eth1 are mutually exclusive, as the later is used for Besu and Nethermind). I'll put a comment in there for posterity.

Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ scrape_configs:
scrape_interval: 5m
scrape_timeout: 5m
static_configs:
- targets: ['watchtower:${WATCHTOWER_METRICS_PORT:-9104}']
- targets: ['watchtower:${WATCHTOWER_METRICS_PORT:-9104}']

- job_name: 'apcupsd'
static_configs:
- targets: ['addon_apcupsd_exporter:${ADDON_APCUPSD_METRICS_PORT:-9162}']
37 changes: 37 additions & 0 deletions install/templates/addons/apcupsd/addon_apcupsd.container.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Autogenerated - DO NOT MODIFY THIS FILE DIRECTLY
# If you want to overwrite some of these values with your own customizations,
# please add them to `override/addons/apcupsd/addon_apcupsd.yml`.
#
# See https://docs.docker.com/compose/extends/#adding-and-overriding-configuration
# for more information on overriding specific parameters of docker-compose files.

version: "3.7"
services:
addon_apcupsd:
image: ${ADDON_APCUPSD_CONTAINER_TAG}
container_name: ${COMPOSE_PROJECT_NAME}_addon_apcupsd
cap_drop:
- ALL
restart: unless-stopped
stop_signal: SIGKILL
stop_grace_period: 1s
devices: ["${ADDON_APCUPSD_MOUNT_POINT}"]
volumes:
- ${ROCKETPOOL_FOLDER}/addon_apcupsd.conf:/etc/apcupsd/apcupsd.conf
networks:
- net
addon_apcupsd_exporter:
image: ${ADDON_APCUPSD_EXPORTER_CONTAINER_TAG}
container_name: ${COMPOSE_PROJECT_NAME}_addon_apcupsd_exporter
cap_drop:
- ALL
restart: unless-stopped
stop_signal: SIGKILL
stop_grace_period: 1s
command: "-apcupsd.addr addon_apcupsd:3551 -apcupsd.network tcp -telemetry.addr 0.0.0.0:${ADDON_APCUPSD_METRICS_PORT:-9162} -telemetry.path /metrics"
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- net
networks:
net:
24 changes: 24 additions & 0 deletions install/templates/addons/apcupsd/addon_apcupsd.network.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Autogenerated - DO NOT MODIFY THIS FILE DIRECTLY
# If you want to overwrite some of these values with your own customizations,
# please add them to `override/addons/apcupsd/addon_apcupsd.yml`.
#
# See https://docs.docker.com/compose/extends/#adding-and-overriding-configuration
# for more information on overriding specific parameters of docker-compose files.

version: "3.7"
services:
addon_apcupsd_exporter:
image: ${ADDON_APCUPSD_EXPORTER_CONTAINER_TAG}
container_name: ${COMPOSE_PROJECT_NAME}_addon_apcupsd_exporter
cap_drop:
- ALL
restart: unless-stopped
stop_signal: SIGKILL
stop_grace_period: 1s
command: "-apcupsd.addr ${ADDON_APCUPSD_NETWORK_ADDRESS:-host.docker.internal:3551} -apcupsd.network tcp -telemetry.addr 0.0.0.0:${ADDON_APCUPSD_METRICS_PORT:-9162} -telemetry.path /metrics"
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- net
networks:
net:
Loading