Created
January 23, 2022 15:25
-
-
Save winmillwill/5a0e7641a3d467e929d4860499af3efd to your computer and use it in GitHub Desktop.
for teeing to a new statsd host in kube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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