K8S pod hosts和resolv.conf

通过 HostAliases 增加额外的hosts条目

注:只能修改非hostNetwork的pod

apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  hostAliases:
  - ip: "127.0.0.1"
    hostnames:
    - "foo.local"
    - "bar.local"
  - ip: "1.2.3.4"
    hostnames:
    - "foo.remote"
    - "bar.remote"
  containers:
  - name: cat-hosts
    image: busybox
    command:
    - cat
    args:
    - "/etc/hosts"

自定义resolv.conf

 

posted @ 2019-10-29 15:02  凌枫恋  阅读(2535)  评论(0编辑  收藏  举报