Often usefull for in-cluster debugging.
$ kubectl run --generator=run-pod/v1 --image=alpine:3.5 -it alpine-shell -- /bin/sh
detach (without killing the container):
CTRL+P,CTRL+Q
re-attach with:
$ kubectl attach -it alpine-shell
$ apk add --update postgresql-client
$ psql -h $PG_HOST -U $PG_USER -p 5432 -d $PG_DB
$ apk add --update redis
$ redis-cli -h $HOST PING
PONG
or just with telnet:
$ telnet $HOST 6379
> PING
+PONG
> QUIT
# telnet is part of busy box
$ telnet $HOST 11211
> stats
> e
$ apk add --update bind-tools
# test for srv records for the port named "client" of etcd cluster
$ dig +nostats +nocmd +nocomments SRV _client._tcp.example-etcd-cluster.default.svc.cluster.local
_client._tcp.exam...local. 30 IN SRV 10 100 2379 example-etcd-cluster.default.svc.cluster.local.
example-etcd-cluster.default.svc.cluster.local. 30 IN A 10.3.0.196
# this returned port 2379 and IP 10.3.0.196 (VIP for the service)
$ echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories
$ apk add --update etcd@testing
$ export ETCDCTL_API=3
$ export ETCDCTL_ENDPOINTS=example-etcd-cluster:2379
$ etcdctl endpoint health
$ etcdctl member list
notice:
$ kubectl get endpoints example-etcd-cluster -o json | jq -r ".subsets[].addresses[].ip"