1
1
---
2
2
title : 使用 HostAliases 向 Pod /etc/hosts 文件添加条目
3
- content_type : concept
3
+ content_type : task
4
4
weight : 60
5
5
min-kubernetes-server-version : 1.7
6
6
---
@@ -22,7 +22,7 @@ Adding entries to a Pod's /etc/hosts file provides Pod-level override of hostnam
22
22
23
23
Modification not using HostAliases is not suggested because the file is managed by Kubelet and can be overwritten on during Pod creation/restart.
24
24
-->
25
- 当 DNS 配置以及其它选项不合理的时候,通过向 Pod 的 /etc/hosts 文件中添加条目,
25
+ 当 DNS 配置以及其它选项不合理的时候,通过向 Pod 的 ` /etc/hosts ` 文件中添加条目,
26
26
可以在 Pod 级别覆盖对主机名的解析。你可以通过 PodSpec 的 HostAliases
27
27
字段来添加这些自定义条目。
28
28
@@ -86,7 +86,7 @@ fe00::2 ip6-allrouters
86
86
By default, the `hosts` file only includes IPv4 and IPv6 boilerplates like
87
87
`localhost` and its own hostname.
88
88
-->
89
- 默认情况下,hosts 文件只包含 IPv4 和 IPv6 的样板内容,像 ` localhost ` 和主机名称。
89
+ 默认情况下,` hosts ` 文件只包含 IPv4 和 IPv6 的样板内容,像 ` localhost ` 和主机名称。
90
90
91
91
<!--
92
92
## Adding Additional Entries with HostAliases
@@ -99,7 +99,7 @@ For example: to resolve `foo.local`, `bar.local` to `127.0.0.1` and `foo.remote`
99
99
-->
100
100
## 通过 HostAliases 增加额外条目
101
101
102
- 除了默认的样板内容,我们可以向 hosts 文件添加额外的条目。
102
+ 除了默认的样板内容,我们可以向 ` hosts ` 文件添加额外的条目。
103
103
例如,要将 ` foo.local ` 、` bar.local ` 解析为 ` 127.0.0.1 ` ,
104
104
将 ` foo.remote ` 、 ` bar.remote ` 解析为 ` 10.1.2.3 ` ,我们可以在
105
105
` .spec.hostAliases ` 下为 Pod 配置 HostAliases。
@@ -136,7 +136,7 @@ hostaliases-pod 0/1 Completed 0 6s 10.200.0.5 w
136
136
<!--
137
137
The `hosts` file content looks like this:
138
138
-->
139
- hosts 文件的内容看起来类似如下这样 :
139
+ ` hosts ` 文件的内容看起来类似如下所示 :
140
140
141
141
``` shell
142
142
kubectl logs hostaliases-pod
0 commit comments