Example: Deploying PHP Guestbook application with Redis [page]deterministic
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.io/) to store guestbook entries * Multiple web frontend instances
##
* Start up a Redis leader. * Start up two Redis followers. * Start up the guestbook frontend. * Expose and view the Frontend Service. * Clean up.
##
## Start up the Redis Database
The guestbook application uses Redis to store its data.
### Creating the Redis Deployment
The manifest file, included below, specifies a Deployment controller that runs a single replica Redis Pod.
1. Launch a terminal window in the directory you downloaded the manifest files. 1. Apply the Redis Deployment from the `redis-leader-deployment.yaml` file:
```shell kubectl apply -f https://k8s.io/examples/application/guestbook/redis-leader-deployment.yaml ```
1. Query the list of Pods to verify that the Redis Pod is running:
```shell kubectl get pods ```
The response should be similar to this:
``` NAME READY STATUS RESTARTS AGE redis-leader-fb76b4755-xjr2n 1/1 Running 0 13s ```
1. Run the following command to view the logs from the Redis leader Pod:
```shell kubectl logs -f deployment/redis-leader ```
### 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.
1. Apply the Redis Service from the following `redis-leader-service.yaml` file:
```shell kubectl apply -f https://k8s.io/examples/application/guestbook/redis-leader-service.yaml ```
1. Query the list of Services to verify that the Redis Service is running:
```shell kubectl get service ```
The response should be similar to this:
``` NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 1m redis-leader ClusterIP 10.103.78.24 <none> 6379/TCP 16s ```
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.
### 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.
1. Apply the Redis Deployment from the following `redis-follower-deployment.yaml` file:
```shell kubectl apply -f https://k8s.io/examples/application/guestbook/redis-follower-deployment.yaml ```
1. Verify that the two Redis follower replicas are running by querying the list of Pods:
```shell kubectl get pods ```
The response should be similar to this:
``` NAME READY STATUS RESTARTS AGE redis-follower-dddfbdcc9-82sfr 1/1 Running 0 37s redis-follower-dddfbdcc9-qrt5k 1/1 Running 0 38s redis-leader-fb76b4755-xjr2n 1/1 Running 0 11m ```
### 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/).
1. Apply the Redis Service from the following `redis-follower-service.yaml` file:
```shell kubectl apply -f https://k8s.io/examples/application/guestbook/redis-follower-service.yaml ```
1. Query the list of Services to verify that the Redis Service is running:
```shell kubectl get service ```
The response should be similar to this:
``` NAME TYPE …(trimmed)