tweak code snippets (#9977)

pull/10004/head
makocchi 2018-08-21 23:52:36 +09:00 committed by k8s-ci-robot
parent 82ffe60269
commit 814da53cd7
1 changed files with 38 additions and 10 deletions

View File

@ -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