Kubernetes - 绑定hosts
2021-10-13
Deployment配置
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx-hosts-alis
spec:
spec:
hostAliases:
- hostnames:
- foo.local
- bar.local
ip: 127.0.0.1
- hostnames:
- foo.remote
- bar.remote
ip: 10.1.2.3
效果
root@nginx-hosts-alis-5db8d7c54c-gf6km:/# 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.16.2.188 nginx-hosts-alis-5db8d7c54c-gf6km
# Entries added by HostAliases.
127.0.0.1 foo.local bar.local
10.1.2.3 foo.remote bar.remote