Skip to content

Instantly share code, notes, and snippets.

@winmillwill
Created January 23, 2022 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winmillwill/5a0e7641a3d467e929d4860499af3efd to your computer and use it in GitHub Desktop.
Save winmillwill/5a0e7641a3d467e929d4860499af3efd to your computer and use it in GitHub Desktop.
for teeing to a new statsd host in kube
initContainers:
- args:
- |
apk add iptables
iptables -t mangle -L
iptables -t nat -L
SOURCE_IP=$(ip route get 1 | head -n1 | sed 's/.* src \([^ ]*\) .*/\1/')
iptables -t mangle -A PREROUTING -p UDP -i eth0 --dport 8125 -j TEE --gateway 127.0.0.2 -m state --state NEW,ESTABLISHED,RELATED
iptables -t nat -A PREROUTING -i eth0 -p UDP --dport 8125 -j DNAT --to 10.0.95.199:3031 -m state --state NEW,ESTABLISHED,RELATED
iptables -t nat -A POSTROUTING -p UDP --dport 3031 -j SNAT --to-source ${SOURCE_IP} -m state --state NEW,ESTABLISHED,RELATED
iptables -t mangle -L
iptables -t nat -L
command:
- sh
- -euxc
image: alpine:3.15
imagePullPolicy: IfNotPresent
name: init-iptables
resources: {}
securityContext:
capabilities:
add:
- NET_ADMIN
- NET_RAW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment