Improve host aliases page (#5443)

* Fix confusion code block

* Add more detail command

* Add pod wide output
This commit is contained in:
Kyle Bai
2017-09-16 07:30:06 +08:00
committed by Andrew Chen
parent 34df90be81
commit 5a0c3014fc
2 changed files with 22 additions and 4 deletions
@@ -15,14 +15,19 @@ Modification not using HostAliases is not suggested because the file is managed
## Default Hosts File Content
Lets start an Nginx Pod which is assigned an Pod IP:
```
```shell
$ kubectl run nginx --image nginx --generator=run-pod/v1
pod "nginx" created
$ kubectl get pods --output=wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 Running 0 13s 10.200.0.4 worker0
```
The hosts file content would look like this:
```
```shell
$ kubectl exec nginx -- cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
@@ -42,8 +47,20 @@ In addition to the default boilerplate, we can add additional entries to the hos
{% include code.html language="yaml" file="hostaliases-pod.yaml" ghlink="/docs/concepts/services-networking/hostaliases-pod.yaml" %}
The hosts file content would look like this:
This Pod can be started with the following commands:
```shell
$ kubectl apply -f hostaliases-pod.yaml
pod "hostaliases-pod" created
$ kubectl get pod -a -o=wide
NAME READY STATUS RESTARTS AGE IP NODE
hostaliases-pod 0/1 Completed 0 6s 10.244.135.10 node3
```
The hosts file content would look like this:
```shell
$ kubectl logs hostaliases-pod
# Kubernetes-managed hosts file.
127.0.0.1 localhost
@@ -52,7 +69,7 @@ fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.200.0.4 hostaliases-pod
10.244.135.10 hostaliases-pod
127.0.0.1 foo.local
127.0.0.1 bar.local
10.1.2.3 foo.remote
@@ -3,6 +3,7 @@ kind: Pod
metadata:
name: hostaliases-pod
spec:
restartPolicy: Never
hostAliases:
- ip: "127.0.0.1"
hostnames: