Writing Host Aliases in Kubernetes Manifests
kubernetes
2022-04-22 13:24 (4 years ago)

I often forget this, so here's a note.
https://kubernetes.io/ja/docs/tasks/network/customize-hosts-file-for-pods/
apiVersion: apps/v1
kind: Deployment
spec:
...
template:
...
spec:
hostAliases:
- hostnames:
- target-host.example.com
ip: 192.168.0.XX
How to check
$ cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
172.31.XX.XX podname-aaaabbbb
# Entries added by HostAliases.
192.168.0.XX target-host.example.com
Please rate this article (No signup or login required)
Currently unrated
Related posts
Return Custom Response Headers with Kubernetes Ingress
Fix: no matches for kind "CronJob" in version "batch/v1beta1" on Kubernetes 1.25 — switch to batch/v1
I reinstalled the DNS plugin because name resolution stopped working in Kubernetes (Microk8s)
Items to Check to Prevent Timeout for Slow Responses in Kubernetes Ingress + Uwsgi Configuration
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.