From d6c1ce54d6d5567e3e8e2626aff3525bb6e97ff8 Mon Sep 17 00:00:00 2001 From: zynfly Date: Mon, 26 Aug 2024 15:58:30 +0800 Subject: [PATCH] [Add] confd config files --- confd/conf.d/opcua.toml | 9 +++++++++ confd/confd.toml | 6 ++++++ confd/templates/opcua.tmpl | 26 ++++++++++++++++++++++++++ docker/confd/Dockerfile | 5 +++-- 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 confd/conf.d/opcua.toml create mode 100644 confd/confd.toml create mode 100644 confd/templates/opcua.tmpl diff --git a/confd/conf.d/opcua.toml b/confd/conf.d/opcua.toml new file mode 100644 index 0000000..386c780 --- /dev/null +++ b/confd/conf.d/opcua.toml @@ -0,0 +1,9 @@ +[template] +src = "opcua.tmpl" +dest = "/data/opcua/opcua.yaml" +keys = [ + "/datasource/", + "/metrics/" +] +#reload_cmd = "pkill -f opcua-exporter && cd /home/lamonki/opcua-expoter/build && ./manage_opcua_exporter.sh | tee /dev/tty" + diff --git a/confd/confd.toml b/confd/confd.toml new file mode 100644 index 0000000..2fc4b41 --- /dev/null +++ b/confd/confd.toml @@ -0,0 +1,6 @@ +backend = "etcd" +nodes = [ + "http://etcd:2379", +] +watch = true + diff --git a/confd/templates/opcua.tmpl b/confd/templates/opcua.tmpl new file mode 100644 index 0000000..948cd7a --- /dev/null +++ b/confd/templates/opcua.tmpl @@ -0,0 +1,26 @@ +datasource: + data_source_type: {{ getv "/datasource/data_source_type" }} + name: {{ getv "/datasource/name" }} + description: {{ getv "/datasource/description" }} + opcua_service_address: {{ getv "/datasource/opcua_service_address" }} + security_policy_address: {{ getv "/datasource/security_policy_address" }} + security_mode: {{ getv "/datasource/security_mode" }} + key_authentication_file: {{ getv "/datasource/key_authentication_file" }} + certificate_authentication_file: {{ getv "/datasource/certificate_authentication_file" }} + trusted_list: {{ getv "/datasource/trusted_list" }} + measurement_point_address: {{ getv "/datasource/measurement_point_address" }} + interface_address: {{ getv "/datasource/interface_address" }} + username: {{ getv "/datasource/username" }} + password: {{ getv "/datasource/password" }} + certificate_identity_file: {{ getv "/datasource/certificate_identity_file" }} + key_identity_file: {{ getv "/datasource/key_identity_file" }} + state: {{ getv "/datasource/state" }} + +metrics: +{{ range $index, $element := ls "/metrics" }} + - name: "{{ getv (printf "/metrics/%d/name" $index) }}" + identifier_type: {{ getv (printf "/metrics/%d/identifier_type" $index) }}" + nodeid: {{ getv (printf "/metrics/%d/nodeid" $index) }} + help: "{{ getv (printf "/metrics/%d/help" $index) }}" +{{ end }} + diff --git a/docker/confd/Dockerfile b/docker/confd/Dockerfile index a7a2260..c4947e5 100644 --- a/docker/confd/Dockerfile +++ b/docker/confd/Dockerfile @@ -7,6 +7,7 @@ RUN dnf update -y && \ RUN curl -fsSL https://github.com/abtreece/confd/releases/download/v0.20.0/confd-v0.20.0-linux-amd64.tar.gz | tar -xz -C /usr/local/bin && \ chmod +x /usr/local/bin/confd -RUN mkdir /etc/confd +RUN mkdir /etc/confd && \ + mkdir /data -CMD [ "confd","-watch", "-backend", "etcd", "-node", "http://etcd:2379"] +CMD [ "confd"]