Kubernetes Pod Container Default hostname

Conclusion

Container’s default hostname is set to pod’s name.

If you use ‘hostNetwork’ option, Container’s hostname is set to the physical host’s name where container is running.

Test

  • Create a basic ubuntu pod

k8s ubuntu pod yaml example

  • Exec the pod container’s sh and check hostname

k8s exec container sh and check

Leave a comment