Skip to content

Instantly share code, notes, and snippets.

@christarazi
Created August 21, 2020 04:35
Show Gist options
  • Save christarazi/11aadf01d353112eb10ed82373569155 to your computer and use it in GitHub Desktop.
Save christarazi/11aadf01d353112eb10ed82373569155 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
pod="${1}" # Cilium pod name (e.g. cilium-2341d)
op="${2}" # iptables operation (e.g. append or delete)
etcd="${3}" # Etcd node IP to apply iptable rules to (e.g. hostname or IP addr)
if [[ "${op}" == "append" ]]; then
op="-A"
else
op="-D"
fi
set -x
kubectl -n kube-system exec -it "${pod}" -- bash -c "
iptables ${op} INPUT -s ${etcd} -p TCP --sport 2379 -j DROP
iptables ${op} OUTPUT -d ${etcd} -p TCP --dport 2379 -j DROP
"
set +x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment