Skip to content

Instantly share code, notes, and snippets.

@robgmills
Last active July 29, 2020 21:12
Show Gist options
  • Select an option

  • Save robgmills/9beeb901d94de3a1be43ef00d63510aa to your computer and use it in GitHub Desktop.

Select an option

Save robgmills/9beeb901d94de3a1be43ef00d63510aa to your computer and use it in GitHub Desktop.
Network troubleshooting for Kubernetes

Network Troubleshooting For Kubernetes

This Kubernetes Pod descriptor will deploy a pod to your kubernetes cluster.

It contains common network troubleshooting tools:

  • dig
  • netcat
  • curl
  • nslookup

Instructions

Run the following in a terminal:

kubectl apply -f https://gist.githubusercontent.com/robgmills/9beeb901d94de3a1be43ef00d63510aa/raw/netbox.yaml && \
kubectl exec -it -n default netbox -- /bin/bash && \
kubectl delete pod -n default netbox

Or, add the following to your .bashrc or .zshrc:

function debugk() {
  kubectl apply -f https://gist.githubusercontent.com/robgmills/9beeb901d94de3a1be43ef00d63510aa/raw/netbox.yaml && \
  kubectl exec -it -n default netbox -- /bin/bash && \
  kubectl delete pod -n default netbox
}

And call it like so:

debugk
apiVersion: v1
kind: Pod
metadata:
name: netbox
namespace: default
spec:
containers:
- name: netbox
image: dj80hd/mybb
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
restartPolicy: Always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment