All-in-one docker image for debugging on Kubernetes and Docker
Note: Insecure, only for debugging
kubectl create deploy --image=amaya382/k8s-debugkit debugkit
kubectl expose --port=80 --type={type you need} deploy debugkit
wget http://{debugkit's ip addr}/info/ip
{
"globalIp": "XXX.XXX.XXX.XXX",
"ip": [
"1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000",
" link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00",
" inet 127.0.0.1/8 scope host lo",
" valid_lft forever preferred_lft forever",
" inet6 ::1/128 scope host ",
" valid_lft forever preferred_lft forever",
"3: eth0@if42: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default ",
" link/ether 92:8b:f7:b2:9f:df brd ff:ff:ff:ff:ff:ff link-netnsid 0",
" inet 10.1.1.16/24 scope global eth0",
" valid_lft forever preferred_lft forever",
" inet6 fe80::908b:f7ff:feb2:9fdf/64 scope link ",
" valid_lft forever preferred_lft forever"
]
}
A global ip k8s environment uses by default is XXX.XXX.XXX.XXX
wget http://{debugkit's ip addr}/info/hostname
{
"hostname": "debugkit-798cb977b-zjvfz"
}
hostname means pod name on k8s
wget http://{debugkit's ip addr}/exec/dig/google.com
{
"dig": [
"; <<>> DiG 9.10.3-P4-Debian <<>> google.com",
";; global options: +cmd",
";; Got answer:",
";; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29948",
";; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1",
"",
";; OPT PSEUDOSECTION:",
"; EDNS: version: 0, flags:; udp: 512",
";; QUESTION SECTION:",
";google.com.\t\t\tIN\tA",
"",
";; ANSWER SECTION:",
"google.com.\t\t185\tIN\tA\t172.217.26.46",
"",
";; Query time: 40 msec",
";; SERVER: 10.152.183.10#53(10.152.183.10)",
";; WHEN: Mon May 06 07:42:12 UTC 2019",
";; MSG SIZE rcvd: 55"
]
}
Working! Succeeded in resolving google.com
k8s-debugkit provides a HTTP server returning information and executing some commands from pod (container). You can check a lot of pod information by using just HTTP GET.
Get all information
Get common info based on request context
Get hostname. hostname in container means container id or pod name on k8s.
Get local nic info and global ip
Get the number of cpus
Get the amount of available memory
Get /etc/hosts
Get /etc/resolv.conf
Get all environmental values
You can execute commands (from container!) via HTTP GET
echo POST data
ping to dst
Resolve name by default name server
traceroute to dst
Exec a http get request to dst
List files
Get an environmental value by name
You can directly use the CLI tools below on container by kubectl exec -it {pod_name} bash
or docker exec -it {container_name} bash
kubectl
ping
curl
wget
dig
nslookup
traceroute