Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access kubernetes pod ips + service ips + kube-dns #8

Open
aisangelos opened this issue Jun 7, 2023 · 2 comments
Open

access kubernetes pod ips + service ips + kube-dns #8

aisangelos opened this issue Jun 7, 2023 · 2 comments

Comments

@aisangelos
Copy link

aisangelos commented Jun 7, 2023

#!/bin/sh
#[email protected]

found=$(which sshuttle)
if [ $? -ne 0 ]
then
echo "Please install sshuttle"
echo "apt-get install sshuttle or brew install shuttle or whatever"
exit 1
fi

echo grabbing Nodes IP range
ipnodes="$(kubectl get nodes | grep -v NAME | sed -e 's/.us-[we][ea]st.*//g' | cut -f2,3 -d- | sort | uniq | sed -e 's/-/./g').0.0/16"
echo Nodes IP range: $ipnodes

echo grabbing services IP range
ipservices="$(kubectl get services | awk '{print $3}' | grep -v CLUSTER | grep -v [Nn]one | cut -f1,2 -d. | uniq).0.0/16"
echo Services IP range: $ipservices

echo grabbing DNS host
dnshost=$(kubectl -n kube-system get service kube-dns | awk '{print $3}' | grep -v CLUSTER)
echo DNS service: $dnshost

echo spawning kuttle-${USER} If it errors with "already exists" it is fine
kubectl run kuttle-${USER} --image=alpine:latest --restart=Never -- sh -c 'apk add python3 --update && exec tail -f /dev/null'

#Enable this for laptops with dnsmasq ( most of them)
DNSMASQ="--dns --ns-hosts=127.0.0.1 --to-ns=$dnshost"
#Uncomment to disable
#DNSMASQ=""

echo starting sshutle, you wil need a SUDO password
sshuttle -r kuttle-${USER} -e kuttle $DNSMASQ $ipnodes $ipservices

@kayrus
Copy link
Owner

kayrus commented Jun 7, 2023

@aisangelos thanks for your contribution. Could you please describe the problem you're trying to solve and adjust the post formatting?

@aisangelos
Copy link
Author

aisangelos commented Jun 7, 2023

To Be able to access Pod Ips + Service IPs + Service FQDNs all in one go. Apologies if it is a bit childish but that's a user requirement ;-)
Ah, it is AWS specific btw...

@aisangelos aisangelos changed the title pod ips + service ips + dns access kubernetes pod ips + service ips + kube-dns Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants