From 5a0c3014fc123de33aca9d30ef183d9528701f55 Mon Sep 17 00:00:00 2001 From: Kyle Bai Date: Sat, 16 Sep 2017 07:30:06 +0800 Subject: [PATCH] Improve host aliases page (#5443) * Fix confusion code block * Add more detail command * Add pod wide output --- ...ries-to-pod-etc-hosts-with-host-aliases.md | 25 ++++++++++++++++--- .../services-networking/hostaliases-pod.yaml | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md b/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md index c087868b8f..fb16b51dbf 100644 --- a/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md +++ b/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md @@ -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 diff --git a/docs/concepts/services-networking/hostaliases-pod.yaml b/docs/concepts/services-networking/hostaliases-pod.yaml index aa57b9a9e5..643813b34a 100644 --- a/docs/concepts/services-networking/hostaliases-pod.yaml +++ b/docs/concepts/services-networking/hostaliases-pod.yaml @@ -3,6 +3,7 @@ kind: Pod metadata: name: hostaliases-pod spec: + restartPolicy: Never hostAliases: - ip: "127.0.0.1" hostnames: