Cleanup guestbook tutorials
This PR fixes two typos and reformat the guestbook tutorial.
This commit is contained in:
@@ -14,7 +14,10 @@ source: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
|
|||||||
---
|
---
|
||||||
|
|
||||||
<!-- overview -->
|
<!-- overview -->
|
||||||
This tutorial shows you how to build and deploy a simple _(not production ready)_, multi-tier web application using Kubernetes and [Docker](https://www.docker.com/). This example consists of the following components:
|
This tutorial shows you how to build and deploy a simple _(not production
|
||||||
|
ready)_, multi-tier web application using Kubernetes and
|
||||||
|
[Docker](https://www.docker.com/). This example consists of the following
|
||||||
|
components:
|
||||||
|
|
||||||
* A single-instance [Redis](https://www.redis.com/) to store guestbook entries
|
* A single-instance [Redis](https://www.redis.com/) to store guestbook entries
|
||||||
* Multiple web frontend instances
|
* Multiple web frontend instances
|
||||||
@@ -65,7 +68,7 @@ The manifest file, included below, specifies a Deployment controller that runs a
|
|||||||
|
|
||||||
The response should be similar to this:
|
The response should be similar to this:
|
||||||
|
|
||||||
```shell
|
```
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
redis-leader-fb76b4755-xjr2n 1/1 Running 0 13s
|
redis-leader-fb76b4755-xjr2n 1/1 Running 0 13s
|
||||||
```
|
```
|
||||||
@@ -78,7 +81,10 @@ The manifest file, included below, specifies a Deployment controller that runs a
|
|||||||
|
|
||||||
### Creating the Redis leader Service
|
### Creating the Redis leader Service
|
||||||
|
|
||||||
The guestbook application needs to communicate to the Redis to write its data. You need to apply a [Service](/docs/concepts/services-networking/service/) to proxy the traffic to the Redis Pod. A Service defines a policy to access the Pods.
|
The guestbook application needs to communicate to the Redis to write its data.
|
||||||
|
You need to apply a [Service](/docs/concepts/services-networking/service/) to
|
||||||
|
proxy the traffic to the Redis Pod. A Service defines a policy to access the
|
||||||
|
Pods.
|
||||||
|
|
||||||
{{< codenew file="application/guestbook/redis-leader-service.yaml" >}}
|
{{< codenew file="application/guestbook/redis-leader-service.yaml" >}}
|
||||||
|
|
||||||
@@ -101,23 +107,26 @@ The guestbook application needs to communicate to the Redis to write its data. Y
|
|||||||
|
|
||||||
The response should be similar to this:
|
The response should be similar to this:
|
||||||
|
|
||||||
```shell
|
```
|
||||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||||
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 1m
|
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 1m
|
||||||
redis-leader ClusterIP 10.103.78.24 <none> 6379/TCP 16s
|
redis-leader ClusterIP 10.103.78.24 <none> 6379/TCP 16s
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
This manifest file creates a Service named `redis-leader` with a set of labels that match the labels previously defined, so the Service routes network traffic to the Redis Pod.
|
This manifest file creates a Service named `redis-leader` with a set of labels
|
||||||
|
that match the labels previously defined, so the Service routes network
|
||||||
|
traffic to the Redis Pod.
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
### Set up Redis followers
|
### Set up Redis followers
|
||||||
|
|
||||||
Although the Redis leader is a single Pod, you can make it highly available and meet traffic demands by adding a few Redis followers, or replicas.
|
Although the Redis leader is a single Pod, you can make it highly available
|
||||||
|
and meet traffic demands by adding a few Redis followers, or replicas.
|
||||||
|
|
||||||
{{< codenew file="application/guestbook/redis-follower-deployment.yaml" >}}
|
{{< codenew file="application/guestbook/redis-follower-deployment.yaml" >}}
|
||||||
|
|
||||||
1. Apply the Redis Service from the following `redis-follower-deployment.yaml` file:
|
1. Apply the Redis Deployment from the following `redis-follower-deployment.yaml` file:
|
||||||
|
|
||||||
<!---
|
<!---
|
||||||
for local testing of the content via relative file path
|
for local testing of the content via relative file path
|
||||||
@@ -136,15 +145,18 @@ Although the Redis leader is a single Pod, you can make it highly available and
|
|||||||
|
|
||||||
The response should be similar to this:
|
The response should be similar to this:
|
||||||
|
|
||||||
```shell
|
```
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
redis-follower-dddfbdcc9-82sfr 1/1 Running 0 37s
|
redis-follower-dddfbdcc9-82sfr 1/1 Running 0 37s
|
||||||
redis-follower-dddfbdcc9-qrt5k 1/1 Running 0 38s
|
redis-follower-dddfbdcc9-qrt5k 1/1 Running 0 38s
|
||||||
redis-leader-fb76b4755-xjr2n 1/1 Running 0 11m
|
redis-leader-fb76b4755-xjr2n 1/1 Running 0 11m
|
||||||
|
```
|
||||||
|
|
||||||
### Creating the Redis follower service
|
### Creating the Redis follower service
|
||||||
|
|
||||||
The guestbook application needs to communicate with the Redis followers to read data. To make the Redis followers discoverable, you must set up another [Service](/docs/concepts/services-networking/service/).
|
The guestbook application needs to communicate with the Redis followers to
|
||||||
|
read data. To make the Redis followers discoverable, you must set up another
|
||||||
|
[Service](/docs/concepts/services-networking/service/).
|
||||||
|
|
||||||
{{< codenew file="application/guestbook/redis-follower-service.yaml" >}}
|
{{< codenew file="application/guestbook/redis-follower-service.yaml" >}}
|
||||||
|
|
||||||
@@ -167,7 +179,7 @@ The guestbook application needs to communicate with the Redis followers to read
|
|||||||
|
|
||||||
The response should be similar to this:
|
The response should be similar to this:
|
||||||
|
|
||||||
```shell
|
```
|
||||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||||
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3d19h
|
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3d19h
|
||||||
redis-follower ClusterIP 10.110.162.42 <none> 6379/TCP 9s
|
redis-follower ClusterIP 10.110.162.42 <none> 6379/TCP 9s
|
||||||
@@ -175,14 +187,21 @@ The guestbook application needs to communicate with the Redis followers to read
|
|||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
This manifest file creates a Service named `redis-follower` with a set of labels that match the labels previously defined, so the Service routes network traffic to the Redis Pod.
|
This manifest file creates a Service named `redis-follower` with a set of
|
||||||
|
labels that match the labels previously defined, so the Service routes network
|
||||||
|
traffic to the Redis Pod.
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
## Set up and Expose the Guestbook Frontend
|
## Set up and Expose the Guestbook Frontend
|
||||||
|
|
||||||
Now that you have the Redis storage of your guestbook up and running, start the guestbook web servers. Like the Redis followers, the frontend is deployed using a Kubernetes Deployment.
|
Now that you have the Redis storage of your guestbook up and running, start
|
||||||
|
the guestbook web servers. Like the Redis followers, the frontend is deployed
|
||||||
|
using a Kubernetes Deployment.
|
||||||
|
|
||||||
The guestbook app uses a PHP frontend. It is configured to communicate with either the Redis follower or leader Services, depending on whether the request is a read or a write. The frontend exposes a JSON interface, and serves a jQuery-Ajax-based UX.
|
The guestbook app uses a PHP frontend. It is configured to communicate with
|
||||||
|
either the Redis follower or leader Services, depending on whether the request
|
||||||
|
is a read or a write. The frontend exposes a JSON interface, and serves a
|
||||||
|
jQuery-Ajax-based UX.
|
||||||
|
|
||||||
### Creating the Guestbook Frontend Deployment
|
### Creating the Guestbook Frontend Deployment
|
||||||
|
|
||||||
@@ -216,12 +235,22 @@ The guestbook app uses a PHP frontend. It is configured to communicate with eith
|
|||||||
|
|
||||||
### Creating the Frontend Service
|
### Creating the Frontend Service
|
||||||
|
|
||||||
The `Redis` Services you applied is only accessible within the Kubernetes cluster because the default type for a Service is [ClusterIP](/docs/concepts/services-networking/service/#publishing-services-service-types). `ClusterIP` provides a single IP address for the set of Pods the Service is pointing to. This IP address is accessible only within the cluster.
|
The `Redis` Services you applied is only accessible within the Kubernetes
|
||||||
|
cluster because the default type for a Service is
|
||||||
|
[ClusterIP](/docs/concepts/services-networking/service/#publishing-services-service-types).
|
||||||
|
`ClusterIP` provides a single IP address for the set of Pods the Service is
|
||||||
|
pointing to. This IP address is accessible only within the cluster.
|
||||||
|
|
||||||
If you want guests to be able to access your guestbook, you must configure the frontend Service to be externally visible, so a client can request the Service from outside the Kubernetes cluster. However a Kubernetes user you can use `kubectl port-forward` to access the service even though it uses a `ClusterIP`.
|
If you want guests to be able to access your guestbook, you must configure the
|
||||||
|
frontend Service to be externally visible, so a client can request the Service
|
||||||
|
from outside the Kubernetes cluster. However a Kubernetes user you can use
|
||||||
|
`kubectl port-forward` to access the service even though it uses a
|
||||||
|
`ClusterIP`.
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
Some cloud providers, like Google Compute Engine or Google Kubernetes Engine, support external load balancers. If your cloud provider supports load balancers and you want to use it, uncomment `type: LoadBalancer`.
|
Some cloud providers, like Google Compute Engine or Google Kubernetes Engine,
|
||||||
|
support external load balancers. If your cloud provider supports load
|
||||||
|
balancers and you want to use it, uncomment `type: LoadBalancer`.
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
{{< codenew file="application/guestbook/frontend-service.yaml" >}}
|
{{< codenew file="application/guestbook/frontend-service.yaml" >}}
|
||||||
@@ -272,7 +301,8 @@ Some cloud providers, like Google Compute Engine or Google Kubernetes Engine, su
|
|||||||
|
|
||||||
### Viewing the Frontend Service via `LoadBalancer`
|
### Viewing the Frontend Service via `LoadBalancer`
|
||||||
|
|
||||||
If you deployed the `frontend-service.yaml` manifest with type: `LoadBalancer` you need to find the IP address to view your Guestbook.
|
If you deployed the `frontend-service.yaml` manifest with type: `LoadBalancer`
|
||||||
|
you need to find the IP address to view your Guestbook.
|
||||||
|
|
||||||
1. Run the following command to get the IP address for the frontend Service.
|
1. Run the following command to get the IP address for the frontend Service.
|
||||||
|
|
||||||
@@ -290,12 +320,15 @@ If you deployed the `frontend-service.yaml` manifest with type: `LoadBalancer` y
|
|||||||
1. Copy the external IP address, and load the page in your browser to view your guestbook.
|
1. Copy the external IP address, and load the page in your browser to view your guestbook.
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
Try adding some guestbook entries by typing in a message, and clicking Submit. The message you typed appears in the frontend. This message indicates that data is successfully added to Redis through the Services you created earlier.
|
Try adding some guestbook entries by typing in a message, and clicking Submit.
|
||||||
|
The message you typed appears in the frontend. This message indicates that
|
||||||
|
data is successfully added to Redis through the Services you created earlier.
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
## Scale the Web Frontend
|
## Scale the Web Frontend
|
||||||
|
|
||||||
You can scale up or down as needed because your servers are defined as a Service that uses a Deployment controller.
|
You can scale up or down as needed because your servers are defined as a
|
||||||
|
Service that uses a Deployment controller.
|
||||||
|
|
||||||
1. Run the following command to scale up the number of frontend Pods:
|
1. Run the following command to scale up the number of frontend Pods:
|
||||||
|
|
||||||
@@ -348,7 +381,8 @@ You can scale up or down as needed because your servers are defined as a Service
|
|||||||
|
|
||||||
## {{% heading "cleanup" %}}
|
## {{% heading "cleanup" %}}
|
||||||
|
|
||||||
Deleting the Deployments and Services also deletes any running Pods. Use labels to delete multiple resources with one command.
|
Deleting the Deployments and Services also deletes any running Pods. Use
|
||||||
|
labels to delete multiple resources with one command.
|
||||||
|
|
||||||
1. Run the following commands to delete all Pods, Deployments, and Services.
|
1. Run the following commands to delete all Pods, Deployments, and Services.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user