trying to run ping from GKE pod, error: ping: socket: Operation not permitted

158 Views Asked by At

Trying to run a one-off container based on this image with command: kubectl run --rm utils -it --image arunvelsriram/utils bash which works but when I try to ping I get:

ping google.com
ping: socket: Operation not permitted

Some solutions to this mention to try running:

setcap cap_net_raw=ep $(which ping)

but then I get error: bash: setcap: command not found If I try installing it I keep running into this error:

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Is there any image that allows me to ping from kubernetes pod in GKE?

1

There are 1 best solutions below

3
Ali Kahoot On

I tried running this and it worked fine, see if you have any additional restrictions on your cluster, that it drops linux capabilities

kubectl run --rm utils -it --image arunvelsriram/utils bash
If you don't see a command prompt, try pressing enter.
utils@utils:~$ ping google.com
PING google.com (209.85.202.102) 56(84) bytes of data.
64 bytes from dg-in-f102.1e100.net (209.85.202.102): icmp_seq=1 ttl=101 time=1.45 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.457/1.457/1.457/0.000 ms
utils@utils:~$