Writing Host Aliases in Kubernetes Manifests

kubernetes
2022-04-22 22:24 (2 years ago) ytyng

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
Current rating: 1
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Archive

2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011