Skip to content
Merged
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
49 changes: 49 additions & 0 deletions contrib/systemd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Introduction

This is a starter systemd unit and associated install instructions, to save new users the time of building up everything
from scratch.

This was created and works as intended on Ubuntu 22.04 LTS (Jammy Jellyfish)

# Motivations

- Save researching time for new users
- Adding common starting point for deployment files for distributions, if, as and when kafdrop gets included into
packaging systems by linux distributions further downstream.

*Note: I could also contribute packaging information for rpm and deb formats, if that's something that'll be useful.*

# Installation steps

***Note: The assumed path of installation ($INSTALLDIR) is `/opt/kafdrop`. If any other path is used, then the service
file needs to be modified to use that path in the `# Paths` commented section.***

1. Create the directory `$INSTALLDIR` and download the latest release there.

2. Create the kafdrop user and group:
```
systemd-sysusers --inline 'u kafdrop - "KafDrop user" $INSTALLDIR /usr/sbin/nologin'
```

3. Copy `start.sh` to `$INSTALLDIR`, edit it to fix the startup parameters and options for your use case, and give it
execute permissions
```
chmod 755 $INSTALLDIR/start.sh
```

4. Copy the `kafdrop.service` file to `$INSTALLDIR` and create a link to it in `/etc/systemd/system`
```
(cd /etc/systemd/system && ln -s $INSTALLDIR/kafdrop.service)
```

5. Refresh systemd runtime configuration.
```
systemctl daemon-reload
```

6. Enable and start service.
```
systemctl enable kafdrop.service && systemctl start kafdrop.service
```

7. Profit!!
31 changes: 31 additions & 0 deletions contrib/systemd/kafdrop.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Systemd unit file for KafDrop
# Thanks to Kafka users on the internet for the starter template

[Unit]
Description=KafDrop server
Documentation=https://github.com/obsidiandynamics/kafdrop
Requires=network.target remote-fs.target
After=network.target remote-fs.target kafka.target

[Service]
Type=simple
ExecStart=/opt/kafdrop/start.sh
SuccessExitStatus=143
Restart=on-abnormal
# Logging
SyslogIdentifier=kafdrop
# Paths
User=kafdrop
Group=kafdrop
PrivateTmp=yes
# Network service
AmbientCapabilities=CAP_NET_BIND_SERVICE
# Restrict privileges
NoNewPrivileges=true
# paths
WorkingDirectory=/opt/kafdrop
ReadOnlyPaths=/opt/kafdrop
RuntimeDirectory=kafdrop

[Install]
WantedBy=multi-user.target
12 changes: 12 additions & 0 deletions contrib/systemd/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Variables for single point of customization
BOOTSTRAP_SERVER="localhost:9092"
VERSION="4.1.0"
LISTEN_PORT=8080

# Running from JAR
exec java --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \
-jar kafdrop-"${VERSION}".jar \
--kafka.brokerConnect="${BOOTSTRAP_SERVER}" \
--server.port=${LISTEN_PORT} --management.server.port=${LISTEN_PORT}