Kubernetes中如何配置pod的/etc/hosts文件?

提问者:帅平 问题分类:运维
Kubernetes中如何配置pod的/etc/hosts文件?比如我想配置下: 1.1.1.1 www.aaa.com 需要怎么做?

 您阅读本篇文章共花了: 

1 个回答
浅时光
浅时光
在kubernetes中,不能手动对pod修改host,只能在创建的时候使用hostAliases定义host,示例如下:
apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  restartPolicy: Never
  hostAliases:
  - ip: "127.0.0.1"
    hostnames:
    - "foo.local"
    - "bar.local"
  - ip: "10.1.2.3"
    hostnames:
    - "foo.remote"
    - "bar.remote"
  containers:
  - name: cat-hosts
    image: busybox
    command:
    - cat
    args:
    - "/etc/hosts"
发布于:2年前 (2022-10-27) IP属地:未知
我来回答