From 2b5c33f03535ee988508bb4f833f9873c0483efe Mon Sep 17 00:00:00 2001 From: rcmadhankumar Date: Wed, 23 Oct 2024 16:17:38 +0530 Subject: [PATCH] BCI images added for KEA DHCP --- src/bci_build/package/__init__.py | 2 + src/bci_build/package/kea.py | 38 ++++++++++++++++++ src/bci_build/package/kea/README.md.j2 | 44 +++++++++++++++++++++ src/bci_build/package/package_versions.json | 5 +++ 4 files changed, 89 insertions(+) create mode 100644 src/bci_build/package/kea.py create mode 100644 src/bci_build/package/kea/README.md.j2 diff --git a/src/bci_build/package/__init__.py b/src/bci_build/package/__init__.py index 6e14ad760..156eda0b9 100644 --- a/src/bci_build/package/__init__.py +++ b/src/bci_build/package/__init__.py @@ -1456,6 +1456,7 @@ def generate_disk_size_constraints(size_gb: int) -> str: from .cosign import COSIGN_CONTAINERS # noqa: E402 from .gcc import GCC_CONTAINERS # noqa: E402 from .golang import GOLANG_CONTAINERS # noqa: E402 +from .kea import KEA_DHCP_CONTAINERS # noqa: E402 from .kiwi import KIWI_CONTAINERS # noqa: E402 from .mariadb import MARIADB_CLIENT_CONTAINERS # noqa: E402 from .mariadb import MARIADB_CONTAINERS # noqa: E402 @@ -1522,6 +1523,7 @@ def generate_disk_size_constraints(size_gb: int) -> str: *TOMCAT_CONTAINERS, *GCC_CONTAINERS, *SPACK_CONTAINERS, + *KEA_DHCP_CONTAINERS, ) } diff --git a/src/bci_build/package/kea.py b/src/bci_build/package/kea.py new file mode 100644 index 000000000..e387dfdf4 --- /dev/null +++ b/src/bci_build/package/kea.py @@ -0,0 +1,38 @@ +"""KEA DHCP Server BCI container""" + +from bci_build.os_version import OsVersion +from bci_build.package import ApplicationStackContainer +from bci_build.package.versions import get_pkg_version + +_BASE_PODMAN_KEA_CMD = "podman run --replace -it --privileged --network=host" +_KEA_DHCP4_CONFIG_PATH = "/etc/kea/kea-dhcp4.conf" +_KEA_DHCP6_CONFIG_PATH = "/etc/kea/kea-dhcp6.conf" + +KEA_DHCP_CONTAINERS = [] +KEA_SUPPORTED_OS_VERSIONS = [ + OsVersion.SP7, + OsVersion.TUMBLEWEED, +] + +for os_version in KEA_SUPPORTED_OS_VERSIONS: + KEA_DHCP_CONTAINERS.append( + ApplicationStackContainer( + name="kea", + os_version=os_version, + version=get_pkg_version("kea", os_version), + license="MPL-2.0", + is_latest=True, + pretty_name="Kea DHCP Server", + package_list=["kea", "util-linux"], + custom_end=""" + RUN mkdir -p /var/run/kea + """, + extra_labels={ + "run": f"{_BASE_PODMAN_KEA_CMD} --name kea-dhcp4 -v /etc/kea:/etc/kea IMAGE kea-dhcp4 -c {_KEA_DHCP4_CONFIG_PATH}", + "runcwd": f"{_BASE_PODMAN_KEA_CMD} --name kea-dhcp4 -v .:/etc/kea IMAGE kea-dhcp4 -c {_KEA_DHCP4_CONFIG_PATH}", + "run_dhcp6": f"{_BASE_PODMAN_KEA_CMD} --name kea-dhcp6 -v /etc/kea:/etc/kea IMAGE kea-dhcp6 -c {_KEA_DHCP6_CONFIG_PATH}", + "runcwd_dhcp6": f"{_BASE_PODMAN_KEA_CMD} --name kea-dhcp6 -v .:/etc/kea IMAGE kea-dhcp6 -c {_KEA_DHCP6_CONFIG_PATH}", + }, + exposes_ports=["67", "67/udp"], + ) + ) diff --git a/src/bci_build/package/kea/README.md.j2 b/src/bci_build/package/kea/README.md.j2 new file mode 100644 index 000000000..2ba3cb6a6 --- /dev/null +++ b/src/bci_build/package/kea/README.md.j2 @@ -0,0 +1,44 @@ +# {{ image.pretty_name }} Container Image + +{% include 'badges.j2' %} + +Kea is an open-source DHCP server developed by the [Internet Systems +Consortium](https://www.isc.org/) and the successor of the now deprecated +DHCPd. The Kea distribution includes a DHCPv4 server, a DHCPv6 server, and a +Dynamic DNS (DDNS) server. Significant features include: support for IPv6 prefix +delegation, host reservations (which may be optionally stored in a separate back +end database), Preboot Execution Environment (PXE) boot, client classification, +shared networks, and high-availability (failover pairs). Kea can store leases +locally in a memfile, or in a PostgreSQL or MySQL database. Kea has a supported +API for writing optional extensions, using 'hooks'. + +## How to use this Container Image + + +The container image expects configuration file in the directory `/etc/kea`. +Execute the following command to run DHCP using the configuration provided in the directory `/etc/kea`: + +```ShellSession +podman container runlabel run \ + {{ image.pretty_reference }} +``` +To run a DHCP6 server using the configuration file supplied in the directory `/etc/kea`, execute the following command: + +```ShellSession +podman container runlabel run_dhcp6 \ + {{ image.pretty_reference }} +``` + +The Kea configuration file can also be provided in the current working directory. +To run a DHCP or a DHCP6 server using the configuration file in the current working directory, execute the following commands: + +```ShellSession +$ # for DHCP +$ podman container runlabel runcwd \ + {{ image.pretty_reference }} +$ # for DHCP6 +$ podman container runlabel runcwd_dhcp6 \ + {{ image.pretty_reference }} +``` + +{% include 'licensing_and_eula.j2' %} diff --git a/src/bci_build/package/package_versions.json b/src/bci_build/package/package_versions.json index 204c9b6ee..fd82611cd 100644 --- a/src/bci_build/package/package_versions.json +++ b/src/bci_build/package/package_versions.json @@ -20,6 +20,11 @@ "Tumbleweed": "3.16", "version_format": "minor" }, + "kea": { + "7": "2.6", + "Tumbleweed": "2.6", + "version_format": "minor" + }, "mariadb": { "5": "10.6", "6": "10.11",