Last active
October 21, 2024 19:46
-
-
Save dcasati/52f35d19ab5f8fcf355a36e0a1ee5e6a to your computer and use it in GitHub Desktop.
kubernetes - Kube-DNS port forwarding and DNS querying.
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
# Use dig to find out about the k8s records | |
# dig +vc -p 5300 @127.0.0.1 cluser.local | |
# Use dig to retrieve an A Record | |
# dig +vc -p 5300 @127.0.0.1 A cb-example-0000.default.svc.cluster.local | |
# Use dig to do a reverse lookup (-x flag) | |
#dig +vc -p 5300 @127.0.0.1 -x 10.0.50.156 | |
# Add the port forward | |
kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o template --template="{{range.items}}{{.metadata.name}}%{{end}}" | xargs -d % -L 1 -I{} kubectl port-forward --namespace=kube-system {} 5300:53 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot for this. Was trying to expose my k8s cluster's dns to my local and this worked perfectly!