kubectl exec: Permission denied

Try to append some new entries to /etc/hosts in pods, but failed:

$   ips=$  (cat ips.txt); kubectl exec -u root myspark-master-5d6656bd84-5zf2h echo "$  ips" >> /etc/hosts -sh: /etc/hosts: Permission denied 

How to fix this?

Thanks