From 814da53cd7ab1cc1d3826015646d24d98e8c0a5b Mon Sep 17 00:00:00 2001 From: makocchi Date: Tue, 21 Aug 2018 23:52:36 +0900 Subject: [PATCH] tweak code snippets (#9977) --- ...ries-to-pod-etc-hosts-with-host-aliases.md | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/content/en/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md b/content/en/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md index d874e3dffb..d472665b07 100644 --- a/content/en/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md +++ b/content/en/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.md @@ -22,10 +22,20 @@ Modification not using HostAliases is not suggested because the file is managed Lets start an Nginx Pod which is assigned a Pod IP: ```shell -$ kubectl run nginx --image nginx --generator=run-pod/v1 -pod "nginx" created +kubectl run nginx --image nginx --generator=run-pod/v1 +``` -$ kubectl get pods --output=wide +```shell +pod/nginx created +``` + +Examine a Pod IP: + +```shell +kubectl get pods --output=wide +``` + +```shell NAME READY STATUS RESTARTS AGE IP NODE nginx 1/1 Running 0 13s 10.200.0.4 worker0 ``` @@ -33,7 +43,10 @@ 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 +kubectl exec nginx -- cat /etc/hosts +``` + +```none # Kubernetes-managed hosts file. 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback @@ -59,18 +72,31 @@ In addition to the default boilerplate, we can add additional entries to the This Pod can be started with the following commands: ```shell -$ kubectl apply -f hostaliases-pod.yaml -pod "hostaliases-pod" created +kubectl apply -f hostaliases-pod.yaml +``` -$ kubectl get pod -o=wide +```shell +pod/hostaliases-pod created +``` + +Examine a Pod IP and status: + +```shell +kubectl get pod -o=wide +``` + +```shell NAME READY STATUS RESTARTS AGE IP NODE -hostaliases-pod 0/1 Completed 0 6s 10.244.135.10 node3 +hostaliases-pod 0/1 Completed 0 6s 10.200.0.5 worker0 ``` The `hosts` file content would look like this: ```shell -$ kubectl logs hostaliases-pod +kubectl logs hostaliases-pod +``` + +```none # Kubernetes-managed hosts file. 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback @@ -78,7 +104,9 @@ fe00::0 ip6-localnet fe00::0 ip6-mcastprefix fe00::1 ip6-allnodes fe00::2 ip6-allrouters -10.244.135.10 hostaliases-pod +10.200.0.5 hostaliases-pod + +# Entries added by HostAliases. 127.0.0.1 foo.local 127.0.0.1 bar.local 10.1.2.3 foo.remote