diff --git a/apps/kea-dhcp-sidecar/ci/latest.py b/apps/kea-dhcp-sidecar/ci/latest.py index 4c747cc..e7eb3c3 100644 --- a/apps/kea-dhcp-sidecar/ci/latest.py +++ b/apps/kea-dhcp-sidecar/ci/latest.py @@ -1,7 +1,7 @@ #!/usr/bin/env python def get_latest(channel): - return "v0.0.1" + return "v0.0.2" if __name__ == "__main__": import sys diff --git a/apps/kea-dhcp-sidecar/generate_config.sh b/apps/kea-dhcp-sidecar/generate_config.sh index 7a62644..b2b6d15 100755 --- a/apps/kea-dhcp-sidecar/generate_config.sh +++ b/apps/kea-dhcp-sidecar/generate_config.sh @@ -19,12 +19,12 @@ generate_config() { PEER_ENTRIES="${PEER_ENTRIES%,}" # Generate the JSON object with the list of peers - echo "\"peers\": [$PEER_ENTRIES]" > /etc/kea/peers.json + echo "\"peers\": [$PEER_ENTRIES]" > /config/kea/peers.json # Reload kea-configuration curl -X POST -H "Content-Type: application/json" -d '{ "command": "config-reload", "service": [ "dhcp4","dhcp6" ] }' http://127.0.0.1:8000/ } echo "First initialization" -cp /etc/kea/ha-init.json /etc/kea/ha.json +cp /config/kea/ha-init.json /config/kea/ha.json generate_config curl -X POST -H "Content-Type: application/json" -d '{ "command": "libreload", "service": [ "dhcp4","dhcp6" ] }' http://127.0.0.1:8000/ curl -X POST -H "Content-Type: application/json" -d '{ "command": "config-reload", "service": [ "dhcp4","dhcp6" ] }' http://127.0.0.1:8000/ diff --git a/apps/kea-dhcp/Dockerfile b/apps/kea-dhcp/Dockerfile index d86ac4e..d479c01 100644 --- a/apps/kea-dhcp/Dockerfile +++ b/apps/kea-dhcp/Dockerfile @@ -18,7 +18,9 @@ RUN cd /tmp/build \ && autoreconf -if \ && ./configure \ --prefix=/usr/local \ - --sysconfdir=/etc \ + --sysconfdir=/config \ + --localstatedir=/data \ + --runstatedir=/run \ --disable-rpath \ --disable-static \ --with-boost-include \ @@ -35,10 +37,14 @@ RUN ldconfig / # Delete unnecessary directory RUN rm -rf /tmp/root/var/run /tmp/root/usr/local/share/man/* /tmp/root/usr/local/include /tmp/root/usr/include \ /tmp/root/usr/share/kea /tmp/root/usr/share/doc/kea /tmp/root/usr/local/lib/kea/hooks/*.la \ - /tmp/root/usr/local/lib/*.la /tmp/root/usr/local/include/* - - - + /tmp/root/usr/local/lib/*.la /tmp/root/usr/local/include/* /tmp/root/data/log/ +# Patch config files for patching sockets and logs +COPY ./patches /patches +RUN cd /tmp/root/config/kea && \ + patch < /patches/kea-ctrl-agent.patch && \ + patch < /patches/kea-dhcp-ddns.patch && \ + patch < /patches/kea-dhcp4.patch && \ + patch < /patches/kea-dhcp6.patch # Intermediate container with runtime dependencies FROM docker.io/python:alpine3.19 as exporter RUN mkdir /install @@ -69,6 +75,10 @@ LABEL org.opencontainers.image.source="https://github.com/isc-projects/kea" LABEL org.opencontainers.image.documentation="https://kea.readthedocs.io/" LABEL org.opencontainers.image.vendor="isc-projects" +#Logging +RUN mkdir /var/log/kea +ENV KEA_LOGGER_DESTINATION stdout +ENV KEA_LOCKFILE_DIR /run/kea # publish port TCP and UDP EXPOSE 67/UDP 547/TCP 547/UDP 8080 9547 @@ -76,7 +86,6 @@ EXPOSE 67/UDP 547/TCP 547/UDP 8080 9547 STOPSIGNAL SIGTERM # select entrypoint -WORKDIR /etc/kea COPY ./entrypoint.sh /usr/local/bin/ ENTRYPOINT ["/sbin/tini", "--"] CMD ["/usr/local/bin/entrypoint.sh"] diff --git a/apps/kea-dhcp/entrypoint.sh b/apps/kea-dhcp/entrypoint.sh index eb950bf..50a1933 100755 --- a/apps/kea-dhcp/entrypoint.sh +++ b/apps/kea-dhcp/entrypoint.sh @@ -2,7 +2,7 @@ set -e -u -RUNPATH="/usr/local/var/run/kea" +RUNPATH="/run/kea" if [ -e "${RUNPATH}/kea-dhcp4.kea-dhcp4.pid" ]; then rm -f "${RUNPATH}/kea-dhcp4.kea-dhcp4.pid" @@ -14,14 +14,14 @@ if [ -e "${RUNPATH}/kea-ctrl-agent.kea-ctrl-agent.pid" ]; then rm -f "${RUNPATH}/kea-ctrl-agent.kea-ctrl-agent.pid" fi -keactrl start -c /etc/kea/keactrl.conf +keactrl start -c /config/kea/keactrl.conf sleep 10 set +e +u -if [[ -e /tmp/kea4-ctrl-socket ]] && [[ -e /tmp/kea6-ctrl-socket ]];then - python3 /usr/local/bin/kea-exporter /tmp/kea4-ctrl-socket /tmp/kea6-ctrl-socket -elif [[ -e /tmp/kea4-ctrl-socket ]];then - python3 /usr/local/bin/kea-exporter /tmp/kea4-ctrl-socket -elif [[ -e /tmp/kea6-ctrl-socket ]];then - python3 /usr/local/bin/kea-exporter /tmp/kea6-ctrl-socket +if [[ -e /run/kea/kea-dhcp4-ctrl.sock ]] && [[ -e /run/kea/kea-dhcp6-ctrl.sock ]];then + python3 /usr/local/bin/kea-exporter /run/kea/kea-dhcp4-ctrl.sock /run/kea/kea-dhcp6-ctrl.sock +elif [[ -e /run/kea/kea-dhcp4-ctrl.sock ]];then + python3 /usr/local/bin/kea-exporter /run/kea/kea-dhcp4-ctrl.sock +elif [[ -e /run/kea/kea-dhcp6-ctrl.sock ]];then + python3 /usr/local/bin/kea-exporter /run/kea/kea-dhcp6-ctrl.sock fi tail -f /dev/null \ No newline at end of file diff --git a/apps/kea-dhcp/patches/kea-ctrl-agent.patch b/apps/kea-dhcp/patches/kea-ctrl-agent.patch new file mode 100644 index 0000000..e0e1d12 --- /dev/null +++ b/apps/kea-dhcp/patches/kea-ctrl-agent.patch @@ -0,0 +1,30 @@ +--- kea-ctrl-agent.conf 2024-05-13 04:17:12 ++++ kea-ctrl-agent-new.conf 2024-05-13 04:15:11 +@@ -32,15 +32,15 @@ + "control-sockets": { + "dhcp4": { + "socket-type": "unix", +- "socket-name": "/tmp/kea4-ctrl-socket" ++ "socket-name": "/run/kea/kea-dhcp4-ctrl.sock" + }, + "dhcp6": { + "socket-type": "unix", +- "socket-name": "/tmp/kea6-ctrl-socket" ++ "socket-name": "/run/kea/kea-dhcp6-ctrl.sock" + }, + "d2": { + "socket-type": "unix", +- "socket-name": "/tmp/kea-ddns-ctrl-socket" ++ "socket-name": "/run/kea/kea-dhcp-ddns-ctrl.sock" + } + }, + +@@ -73,7 +73,7 @@ + // - syslog (logs to syslog) + // - syslog:name (logs to syslog using specified name) + // Any other value is considered a name of the file +- "output": "/data/log/kea-ctrl-agent.log" ++ "output": "stdout" + + // Shorter log pattern suitable for use with systemd, + // avoids redundant information diff --git a/apps/kea-dhcp/patches/kea-dhcp-ddns.patch b/apps/kea-dhcp/patches/kea-dhcp-ddns.patch new file mode 100644 index 0000000..ab5fe83 --- /dev/null +++ b/apps/kea-dhcp/patches/kea-dhcp-ddns.patch @@ -0,0 +1,20 @@ +--- kea-dhcp-ddns.conf 2024-05-13 04:15:43 ++++ kea-dhcp-ddns-new.conf 2024-05-13 04:15:38 +@@ -23,7 +23,7 @@ + "port": 53001, + "control-socket": { + "socket-type": "unix", +- "socket-name": "/tmp/kea-ddns-ctrl-socket" ++ "socket-name": "/run/kea/kea-dhcp-ddns-ctrl.sock" + }, + "tsig-keys": [], + "forward-ddns" : {}, +@@ -44,7 +44,7 @@ + // - syslog (logs to syslog) + // - syslog:name (logs to syslog using specified name) + // Any other value is considered a name of the file +- "output": "/data/log/kea-ddns.log" ++ "output": "stdout" + + // Shorter log pattern suitable for use with systemd, + // avoids redundant information diff --git a/apps/kea-dhcp/patches/kea-dhcp4.patch b/apps/kea-dhcp/patches/kea-dhcp4.patch new file mode 100644 index 0000000..eccfe17 --- /dev/null +++ b/apps/kea-dhcp/patches/kea-dhcp4.patch @@ -0,0 +1,20 @@ +--- kea-dhcp4.conf 2024-05-13 04:15:59 ++++ kea-dhcp4-new.conf 2024-05-13 04:15:50 +@@ -49,7 +49,7 @@ + // more. For detailed description, see Sections 8.8, 16 and 15. + "control-socket": { + "socket-type": "unix", +- "socket-name": "/tmp/kea4-ctrl-socket" ++ "socket-name": "/run/kea/kea-dhcp4-ctrl.sock" + }, + + // Use Memfile lease database backend to store leases in a CSV file. +@@ -436,7 +436,7 @@ + // - syslog (logs to syslog) + // - syslog:name (logs to syslog using specified name) + // Any other value is considered a name of the file +- "output": "/data/log/kea-dhcp4.log" ++ "output": "stdout" + + // Shorter log pattern suitable for use with systemd, + // avoids redundant information diff --git a/apps/kea-dhcp/patches/kea-dhcp6.patch b/apps/kea-dhcp/patches/kea-dhcp6.patch new file mode 100644 index 0000000..20790aa --- /dev/null +++ b/apps/kea-dhcp/patches/kea-dhcp6.patch @@ -0,0 +1,20 @@ +--- kea-dhcp6.conf 2024-05-13 04:16:09 ++++ kea-dhcp6-new.conf 2024-05-13 04:16:10 +@@ -43,7 +43,7 @@ + // description, see Sections 9.12, 16 and 15. + "control-socket": { + "socket-type": "unix", +- "socket-name": "/tmp/kea6-ctrl-socket" ++ "socket-name": "/run/kea/kea-dhcp6-ctrl.sock" + }, + + // Use Memfile lease database backend to store leases in a CSV file. +@@ -395,7 +395,7 @@ + // - syslog (logs to syslog) + // - syslog:name (logs to syslog using specified name) + // Any other value is considered a name of the file +- "output": "/data/log/kea-dhcp6.log" ++ "output": "stdout" + + // Shorter log pattern suitable for use with systemd, + // avoids redundant information