• How to add entries to a pod's /etc/hosts file

    2 min read

    hostAliases pod kubernetes

    The /etc/hosts file is a Kubernetes-managed file so we cannot add entries freely to it. If we want to add entries to it we will have to use the hostAliases field in the Pod's spec.

    $ kubectl exec -it demo-pod -- cat /etc/hosts
    # Kubernetes-managed hosts file. localhost
    ::1 localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    fe00::0 ip6-mcastprefix
    fe00::1 ip6-allnodes
    fe00::2 ip6-allrouters demo-pod



From pet to cattle
Treat your kubernetes clusters like cattle, not pets