Skip to content

Commit 7fbe6d4

Browse files
authored
Merge pull request #39585 from windsonsea/appclu
Clean up /service-access-application-cluster.md
2 parents a5883ed + fc933ba commit 7fbe6d4

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

content/en/docs/tasks/access-application-cluster/service-access-application-cluster.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,15 @@ This page shows how to create a Kubernetes Service object that external
1010
clients can use to access an application running in a cluster. The Service
1111
provides load balancing for an application that has two running instances.
1212

13-
14-
15-
1613
## {{% heading "prerequisites" %}}
1714

18-
1915
{{< include "task-tutorial-prereqs.md" >}}
2016

21-
22-
23-
2417
## {{% heading "objectives" %}}
2518

26-
27-
* Run two instances of a Hello World application.
28-
* Create a Service object that exposes a node port.
29-
* Use the Service object to access the running application.
30-
31-
32-
19+
- Run two instances of a Hello World application.
20+
- Create a Service object that exposes a node port.
21+
- Use the Service object to access the running application.
3322

3423
<!-- lessoncontent -->
3524

@@ -41,9 +30,11 @@ Here is the configuration file for the application Deployment:
4130

4231
1. Run a Hello World application in your cluster:
4332
Create the application Deployment using the file above:
33+
4434
```shell
4535
kubectl apply -f https://k8s.io/examples/service/access/hello-application.yaml
4636
```
37+
4738
The preceding command creates a
4839
{{< glossary_tooltip text="Deployment" term_id="deployment" >}}
4940
and an associated
@@ -52,30 +43,35 @@ Here is the configuration file for the application Deployment:
5243
{{< glossary_tooltip text="Pods" term_id="pod" >}}
5344
each of which runs the Hello World application.
5445

55-
5646
1. Display information about the Deployment:
47+
5748
```shell
5849
kubectl get deployments hello-world
5950
kubectl describe deployments hello-world
6051
```
6152

6253
1. Display information about your ReplicaSet objects:
54+
6355
```shell
6456
kubectl get replicasets
6557
kubectl describe replicasets
6658
```
6759

6860
1. Create a Service object that exposes the deployment:
61+
6962
```shell
7063
kubectl expose deployment hello-world --type=NodePort --name=example-service
7164
```
7265

7366
1. Display information about the Service:
67+
7468
```shell
7569
kubectl describe services example-service
7670
```
71+
7772
The output is similar to this:
78-
```shell
73+
74+
```none
7975
Name: example-service
8076
Namespace: default
8177
Labels: run=load-balancer-example
@@ -90,19 +86,24 @@ Here is the configuration file for the application Deployment:
9086
Session Affinity: None
9187
Events: <none>
9288
```
89+
9390
Make a note of the NodePort value for the service. For example,
9491
in the preceding output, the NodePort value is 31496.
9592

9693
1. List the pods that are running the Hello World application:
94+
9795
```shell
9896
kubectl get pods --selector="run=load-balancer-example" --output=wide
9997
```
98+
10099
The output is similar to this:
101-
```shell
100+
101+
```none
102102
NAME READY STATUS ... IP NODE
103103
hello-world-2895499144-bsbk5 1/1 Running ... 10.200.1.4 worker1
104104
hello-world-2895499144-m1pwt 1/1 Running ... 10.200.2.5 worker2
105105
```
106+
106107
1. Get the public IP address of one of your nodes that is running
107108
a Hello World pod. How you get this address depends on how you set
108109
up your cluster. For example, if you are using Minikube, you can
@@ -117,13 +118,16 @@ Here is the configuration file for the application Deployment:
117118
cloud providers offer different ways of configuring firewall rules.
118119

119120
1. Use the node address and node port to access the Hello World application:
121+
120122
```shell
121123
curl http://<public-node-ip>:<node-port>
122124
```
125+
123126
where `<public-node-ip>` is the public IP address of your node,
124127
and `<node-port>` is the NodePort value for your service. The
125128
response to a successful request is a hello message:
126-
```shell
129+
130+
```none
127131
Hello Kubernetes!
128132
```
129133

@@ -133,12 +137,8 @@ As an alternative to using `kubectl expose`, you can use a
133137
[service configuration file](/docs/concepts/services-networking/service/)
134138
to create a Service.
135139

136-
137-
138-
139140
## {{% heading "cleanup" %}}
140141

141-
142142
To delete the Service, enter this command:
143143

144144
kubectl delete services example-service
@@ -148,9 +148,6 @@ the Hello World application, enter this command:
148148

149149
kubectl delete deployment hello-world
150150

151-
152-
153-
154151
## {{% heading "whatsnext" %}}
155152

156153
Follow the

0 commit comments

Comments
 (0)