Skip to content

Commit 71ce444

Browse files
committed
feat(blog): plex with socat for hdhr
1 parent 46b4d9b commit 71ce444

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
labels:
6+
app: plex
7+
name: plex
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: plex
13+
strategy:
14+
type: Recreate
15+
template:
16+
metadata:
17+
labels:
18+
app: plex
19+
spec:
20+
containers:
21+
- image: plexinc/pms-docker:1.41.3.9314-a0bfb8370
22+
name: plex
23+
env: [] # your env vars here
24+
volumeMounts: [] # your volume mounts here
25+
- image: alpine/socat:1.8.0.0
26+
name: socat
27+
command: ["socat", "-d", "-d", "-v", "udp4-recvfrom:65001,broadcast,fork", "udp4-sendto:192.168.20.20:65001"] # replace 192.168.20.20 with your HD Home Run's ip
28+
volumes: [] # your volumes here

blog/posts/2025_1_29.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
title: "Streaming Live TV with Plex and HDHomeRun inside Kubernetes"
2+
date: "1/29/2025"
3+
body:
4+
- section_title: "Background"
5+
text: "[HDHomeRuns](https://www.silicondust.com/hdhomerun/) are a great way to stream live TV to your home. These are devices produced by Silicon Dust that connect to an OTA antenna (or cable box) and can be connected to clients via USB or Ethernet.
6+
These can be found used for pretty cheap on eBay, but even their new products are reasonably priced. What piques most folks' interest in these is their ability to integrate with Plex, allowing you to stream live TV directly within Plex clients."
7+
- text: "In my case, I chose a Ethernet connected HDHomeRun, however this presented a challenge when running Plex inside Kubernetes. HDHomeRun connections are initiated by the client sending a UDP broadcast packet from port 65001.
8+
This is done to discover the HDHomeRun device. Once the HDHomeRun device is discovered by the client, it will present it as a connection option, as demonstrated in [this official Plex guide](https://support.plex.tv/articles/225877347-live-tv-dvr/).
9+
While this can easily work within a given network, what if you run your IOT devices in one VLAN, but run Plex in another? Furthermore, what if you are running Plex inside Kubernetes, which uses NAT between the pod networks and the hosts?"
10+
- section_title: "Solution"
11+
text: "Thankfully this is where socat (link) can help us. Socat is a versatile utility for bidirectional data transfer between two independent data streams, supporting various protocols like TCP, UDP, pipes, and files.
12+
As [meckhert on the Unifi forum](https://community.ui.com/questions/Howto-HDHomerun-discovery-on-different-LAN-segment/97db52c6-4add-4ba1-ab0d-27ee6f43db8f) shared, socat can be used to handle the VLAN traversal.
13+
In our case it can also handle the NATing issues from inside the Kubernetes cluster! By running socat in a sidecar container with Plex, it will be able to receive the broadcast packets Plex sends out, and forward them directly to the HDHomeRun device."
14+
- text: "An example deployment of this:"
15+
- code: "plex_with_socat.yaml"
16+
- text: "Don't forget to setup any firewall rules. I found the following needed to be allowed between my IOT and Kubernetes VLANs:"
17+
- text: "Allow HDHomeRun Discovery"
18+
- text: "- Protocol: IPv4 UDP"
19+
- text: "- Source: Kubernetes Host IPs"
20+
- text: "- Destination: HDHomeRun IP"
21+
- text: "- Destination port: 65001"
22+
- text: "Allow HDHomeRun streaming"
23+
- text: "- Protocol: IPv4 TCP"
24+
- text: "- Source: Kubernetes Host IPs"
25+
- text: "- Destination: HDHomeRun IP"
26+
- text: "- Destination Ports: 80, 5004"
27+
- text: "Hopefully by sharing this I can help someone else who runs into this case. Happy streaming!"

0 commit comments

Comments
 (0)