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

feat: introduce LLDPD extension service #487

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ TARGETS += intel-ice-firmware
TARGETS += intel-ucode
TARGETS += iscsi-tools
TARGETS += kata-containers
TARGETS += lldpd
TARGETS += mdadm
TARGETS += mei
TARGETS += nut-client
Expand Down
40 changes: 40 additions & 0 deletions network/lldpd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# LLDPD

Adds https://lldpd.github.io/ as system extensions.
This means a lldpd server is started that sends/receives LLDP messages.

## Installation

See [Installing Extensions](https://github.com/siderolabs/extensions#installing-extensions).

## Usage

Configure the extension via `ExtensionServiceConfig` document. You can add any lldpd related configuration and these will be executed at the LLDPD server startup.

```yaml
---
apiVersion: v1alpha1
kind: ExtensionServiceConfig
name: lldpd
files:
- content: |
configure lldpd portidsubtype ifname
unconfigure lldp management-addresses-advertisements
unconfigure lldp capabilities-advertisements
configure system description "Talos Node"
mountPath: /usr/local/etc/lldpd/lldpd.conf
```

Then apply the patch to your node's MachineConfigs
```bash
talosctl patch mc -p @lldpd-config.yaml
```

You will then be able to verify that it is in place with the following command
```bash
talosctl get extensionserviceconfigs

NODE NAMESPACE TYPE ID VERSION
mynode runtime ExtensionServiceConfig lldpd 1
```

1 change: 1 addition & 0 deletions network/lldpd/files/group
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root:x:0:
1 change: 1 addition & 0 deletions network/lldpd/files/passwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root:x:0:0:root:/:/sbin/false
54 changes: 54 additions & 0 deletions network/lldpd/lldpd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#© 2024 Nokia
#Licensed under the Mozilla Public License 2.0
#SPDX-License-Identifier: MPL-2.0
name: lldpd
depends:
- service: cri
- network:
- addresses
- connectivity
- etcfiles
- configuration: true
container:
args:
- -d
- -u
- /var/run/lldpd/lldpd.socket
- -I
- eth*,enp*,ens*,eno*
entrypoint: /usr/local/sbin/lldpd
environment:
- PATH=/usr/local/sbin
mounts:
# release file
- source: /etc/os-release
destination: /etc/os-release
type: bind
options:
- bind
- ro
# libs
- source: /lib
destination: /lib
type: bind
options:
- bind
- ro
# more libs
- source: /usr/lib
destination: /usr/lib
type: bind
options:
- bind
- ro
# lldpd socket
- source: /var/run/lldpd
destination: /var/run/lldpd
type: bind
options:
- bind
- rw
security:
writeableRootfs: false
writeableSysfs: true
restart: always
13 changes: 13 additions & 0 deletions network/lldpd/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#© 2024 Nokia
#Licensed under the Mozilla Public License 2.0
#SPDX-License-Identifier: MPL-2.0
version: v1alpha1
metadata:
name: lldpd
version: "$VERSION"
author: Niklas Wik
description: |
LLDP adds a LLDP discovery service to Talos. LLDP cli can be used to interface with the daemon.
compatibility:
talos:
version: ">= v1.7.0"
67 changes: 67 additions & 0 deletions network/lldpd/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#© 2024 Nokia
#Licensed under the Mozilla Public License 2.0
#SPDX-License-Identifier: MPL-2.0
name: lldpd
variant: alpine
shell: /bin/bash
dependencies:
- stage: base
from: /
to: /base-rootfs
install:
- autoconf
- automake
- bash
- build-base
- bsd-compat-headers
- libtool
- linux-headers
- m4
- pkgconfig
steps:
- sources:
- url: https://github.com/lldpd/lldpd/releases/download/{{ .LLDPD_VERSION }}/lldpd-{{ .LLDPD_VERSION }}.tar.gz
destination: lldpd.tar.gz
sha256: 38cd319aa02ab61d9a2ad130e22f906795ccca9ac73a0a0d9dac19ca99a8a870
sha512: c8734221767cd879c98ea3ee6fa80e1dce2f8470a97b0f757cfe7ef8fe2adaf878fdedcda896cf65e1af980634f2ab312588658fb85f89c6d5b6cc9d2da52045
prepare:
- |
sed -i 's#$VERSION#{{ .VERSION }}#' /pkg/manifest.yaml
- |
tar -xf lldpd.tar.gz --strip-components=1
- |

./autogen.sh

export PKG_CONFIG_PATH=/usr/lib/pkgconfig
./configure \
--prefix=/usr/local \
--libexecdir=/usr/local/lib/lldpd \
--datadir=/usr/local/share/lldpd \
--sysconfdir=/usr/local/etc/lldpd \
--enable-hardening \
--with-privsep-user=root \
--with-privsep-group=root \
--with-privsep-chroot=/opt/lldpd
build:
- |
make -j $(nproc) all
install:
- |
make DESTDIR=/rootfs install-exec

containerRoot=/rootfs/usr/local/lib/containers/lldpd
mkdir -p "$containerRoot"/{etc,sbin,opt/lldpd}
mkdir -p "$containerRoot"/usr/local/{lldpd,sbin,share/lldpd,lib/lldpd,bin}
mv /rootfs/usr/local/lib/lib* "$containerRoot"/usr/local/lib/
cp /rootfs/usr/local/sbin/lldpcli "$containerRoot"/usr/local/sbin/lldpcli
cp /rootfs/usr/local/sbin/lldpctl "$containerRoot"/usr/local/sbin/lldpctl
cp /rootfs/usr/local/sbin/lldpd "$containerRoot"/usr/local/sbin/lldpd
cp /pkg/files/* "$containerRoot"/etc/
finalize:
- from: /rootfs
to: /rootfs
- from: /pkg/manifest.yaml
to: /
- from: /pkg/lldpd.yaml
to: /rootfs/usr/local/etc/containers/
4 changes: 4 additions & 0 deletions network/lldpd/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#© 2024 Nokia
#Licensed under the Mozilla Public License 2.0
#SPDX-License-Identifier: MPL-2.0
VERSION: "{{ .LLDPD_VERSION }}"
2 changes: 2 additions & 0 deletions network/vars.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# renovate: datasource=github-releases extractVersion=^v(?<version>.*)$ depName=tailscale/tailscale
TAILSCALE_VERSION: 1.72.1

LLDPD_VERSION: 1.0.18