Skip to content

Commit 8e41aed

Browse files
authored
Merge pull request #25080 from RA489/updatefmt
add code formatting to commands in expose-external-ip-address tutorial
2 parents ce04399 + 2abce40 commit 8e41aed

File tree

1 file changed

+65
-59
lines changed

1 file changed

+65
-59
lines changed

content/en/docs/tutorials/stateless-application/expose-external-ip-address.md

Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ weight: 10
99
This page shows how to create a Kubernetes Service object that exposes an
1010
external IP address.
1111

12-
13-
14-
1512
## {{% heading "prerequisites" %}}
1613

17-
1814
* Install [kubectl](/docs/tasks/tools/install-kubectl/).
1915

2016
* Use a cloud provider like Google Kubernetes Engine or Amazon Web Services to
@@ -25,19 +21,12 @@ external IP address.
2521
* Configure `kubectl` to communicate with your Kubernetes API server. For
2622
instructions, see the documentation for your cloud provider.
2723

28-
29-
30-
3124
## {{% heading "objectives" %}}
3225

33-
3426
* Run five instances of a Hello World application.
3527
* Create a Service object that exposes an external IP address.
3628
* Use the Service object to access the running application.
3729

38-
39-
40-
4130
<!-- lessoncontent -->
4231

4332
## Creating a service for an application running in five pods
@@ -50,37 +39,46 @@ external IP address.
5039
kubectl apply -f https://k8s.io/examples/service/load-balancer-example.yaml
5140
```
5241

53-
5442
The preceding command creates a
55-
{{< glossary_tooltip text="Deployment" term_id="deployment" >}}
56-
and an associated
57-
{{< glossary_tooltip term_id="replica-set" text="ReplicaSet" >}}.
58-
The ReplicaSet has five
59-
{{< glossary_tooltip text="Pods" term_id="pod" >}}
60-
each of which runs the Hello World application.
43+
{{< glossary_tooltip text="Deployment" term_id="deployment" >}}
44+
and an associated
45+
{{< glossary_tooltip term_id="replica-set" text="ReplicaSet" >}}.
46+
The ReplicaSet has five
47+
{{< glossary_tooltip text="Pods" term_id="pod" >}}
48+
each of which runs the Hello World application.
6149

6250
1. Display information about the Deployment:
6351

64-
kubectl get deployments hello-world
65-
kubectl describe deployments hello-world
52+
```shell
53+
kubectl get deployments hello-world
54+
kubectl describe deployments hello-world
55+
```
6656

6757
1. Display information about your ReplicaSet objects:
6858

69-
kubectl get replicasets
70-
kubectl describe replicasets
59+
```shell
60+
kubectl get replicasets
61+
kubectl describe replicasets
62+
```
7163

7264
1. Create a Service object that exposes the deployment:
7365

74-
kubectl expose deployment hello-world --type=LoadBalancer --name=my-service
66+
```shell
67+
kubectl expose deployment hello-world --type=LoadBalancer --name=my-service
68+
```
7569

7670
1. Display information about the Service:
7771

78-
kubectl get services my-service
72+
```shell
73+
kubectl get services my-service
74+
```
7975

8076
The output is similar to this:
8177

82-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
83-
my-service LoadBalancer 10.3.245.137 104.198.205.71 8080/TCP 54s
78+
```
79+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
80+
my-service LoadBalancer 10.3.245.137 104.198.205.71 8080/TCP 54s
81+
```
8482

8583
{{< note >}}
8684

@@ -96,23 +94,27 @@ The preceding command creates a
9694

9795
1. Display detailed information about the Service:
9896

99-
kubectl describe services my-service
97+
```shell
98+
kubectl describe services my-service
99+
```
100100

101101
The output is similar to this:
102102

103-
Name: my-service
104-
Namespace: default
105-
Labels: app.kubernetes.io/name=load-balancer-example
106-
Annotations: <none>
107-
Selector: app.kubernetes.io/name=load-balancer-example
108-
Type: LoadBalancer
109-
IP: 10.3.245.137
110-
LoadBalancer Ingress: 104.198.205.71
111-
Port: <unset> 8080/TCP
112-
NodePort: <unset> 32377/TCP
113-
Endpoints: 10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more...
114-
Session Affinity: None
115-
Events: <none>
103+
```
104+
Name: my-service
105+
Namespace: default
106+
Labels: app.kubernetes.io/name=load-balancer-example
107+
Annotations: <none>
108+
Selector: app.kubernetes.io/name=load-balancer-example
109+
Type: LoadBalancer
110+
IP: 10.3.245.137
111+
LoadBalancer Ingress: 104.198.205.71
112+
Port: <unset> 8080/TCP
113+
NodePort: <unset> 32377/TCP
114+
Endpoints: 10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more...
115+
Session Affinity: None
116+
Events: <none>
117+
```
116118

117119
Make a note of the external IP address (`LoadBalancer Ingress`) exposed by
118120
your service. In this example, the external IP address is 104.198.205.71.
@@ -124,21 +126,27 @@ The preceding command creates a
124126
addresses of the pods that are running the Hello World application. To
125127
verify these are pod addresses, enter this command:
126128

127-
kubectl get pods --output=wide
129+
```shell
130+
kubectl get pods --output=wide
131+
```
128132

129133
The output is similar to this:
130134

131-
NAME ... IP NODE
132-
hello-world-2895499144-1jaz9 ... 10.0.1.6 gke-cluster-1-default-pool-e0b8d269-1afc
133-
hello-world-2895499144-2e5uh ... 10.0.1.8 gke-cluster-1-default-pool-e0b8d269-1afc
134-
hello-world-2895499144-9m4h1 ... 10.0.0.6 gke-cluster-1-default-pool-e0b8d269-5v7a
135-
hello-world-2895499144-o4z13 ... 10.0.1.7 gke-cluster-1-default-pool-e0b8d269-1afc
136-
hello-world-2895499144-segjf ... 10.0.2.5 gke-cluster-1-default-pool-e0b8d269-cpuc
135+
```
136+
NAME ... IP NODE
137+
hello-world-2895499144-1jaz9 ... 10.0.1.6 gke-cluster-1-default-pool-e0b8d269-1afc
138+
hello-world-2895499144-2e5uh ... 10.0.1.8 gke-cluster-1-default-pool-e0b8d269-1afc
139+
hello-world-2895499144-9m4h1 ... 10.0.0.6 gke-cluster-1-default-pool-e0b8d269-5v7a
140+
hello-world-2895499144-o4z13 ... 10.0.1.7 gke-cluster-1-default-pool-e0b8d269-1afc
141+
hello-world-2895499144-segjf ... 10.0.2.5 gke-cluster-1-default-pool-e0b8d269-cpuc
142+
```
137143

138144
1. Use the external IP address (`LoadBalancer Ingress`) to access the Hello
139145
World application:
140146

141-
curl http://<external-ip>:<port>
147+
```shell
148+
curl http://<external-ip>:<port>
149+
```
142150

143151
where `<external-ip>` is the external IP address (`LoadBalancer Ingress`)
144152
of your Service, and `<port>` is the value of `Port` in your Service
@@ -148,29 +156,27 @@ The preceding command creates a
148156

149157
The response to a successful request is a hello message:
150158

151-
Hello Kubernetes!
152-
153-
154-
159+
```shell
160+
Hello Kubernetes!
161+
```
155162

156163
## {{% heading "cleanup" %}}
157164

158-
159165
To delete the Service, enter this command:
160166

161-
kubectl delete services my-service
167+
```shell
168+
kubectl delete services my-service
169+
```
162170

163171
To delete the Deployment, the ReplicaSet, and the Pods that are running
164172
the Hello World application, enter this command:
165173

166-
kubectl delete deployment hello-world
167-
168-
169-
174+
```shell
175+
kubectl delete deployment hello-world
176+
```
170177

171178
## {{% heading "whatsnext" %}}
172179

173-
174180
Learn more about
175181
[connecting applications with services](/docs/concepts/services-networking/connect-applications-service/).
176182

0 commit comments

Comments
 (0)