text
stringlengths
0
59.1k
matchLabels:
app: redis
role: master
template:
metadata:
labels:
app: redis
role: master
spec:
containers:
- name: redis-master
image: redis:7.2
ports:
- name: redis-server
containerPort: 6379
<|endoftext|>
# source: k8s_examples/web/guestbook-go/redis-replica-service.yaml type: yaml
kind: Service
apiVersion: v1
metadata:
name: redis-replica
labels:
app: redis
role: replica
spec:
ports:
- port: 6379
targetPort: redis-server
selector:
app: redis
role: replica
<|endoftext|>
# source: k8s_examples/web/guestbook-go/guestbook-controller.yaml type: yaml
kind: ReplicationController
apiVersion: v1
metadata:
name: guestbook
labels:
app: guestbook
spec:
replicas: 3
selector:
app: guestbook
template:
metadata:
labels:
app: guestbook
spec:
containers:
- name: guestbook
image: registry.k8s.io/guestbook:v3
ports:
- name: http-server
containerPort: 3000
<|endoftext|>
# source: k8s_examples/web/guestbook-go/README.md type: docs
## Guestbook Example
This example shows how to build a simple multi-tier web application using Kubernetes and Docker. The application consists of a web front end, Redis master for storage, and replicated set of Redis replicas, all for which we will create Kubernetes replication controllers, pods, and services.
If you are running a cluster in Google Container Engine (GKE), instead see the [Guestbook Example for Google Container Engine](https://cloud.google.com/container-engine/docs/tutorials/guestbook).
##### Table of Contents
* [Step Zero: Prerequisites](#step-zero)
* [Step One: Create the Redis master pod](#step-one)
* [Step Two: Create the Redis master service](#step-two)
* [Step Three: Create the Redis replica pods](#step-three)
* [Step Four: Create the Redis replica service](#step-four)
* [Step Five: Create the guestbook pods](#step-five)
* [Step Six: Create the guestbook service](#step-six)
* [Step Seven: View the guestbook](#step-seven)
* [Step Eight: Cleanup](#step-eight)
### Step Zero: Prerequisites <a id="step-zero"></a>
This example assumes that you have a working cluster. See the [Getting Started Guides](https://kubernetes.io/docs/setup/) for details about creating a cluster.
**Tip:** View all the `kubectl` commands, including their options and descriptions in the [kubectl CLI reference](https://kubernetes.io/docs/user-guide/kubectl-overview/).
### Step One: Create the Redis master pod<a id="step-one"></a>
Use the `examples/guestbook-go/redis-master-controller.yaml` file to create a [replication controller](https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/) and Redis master [pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/). The pod runs a Redis key-value server in a co...
1. Use the [redis-master-controller.yaml](redis-master-controller.yaml) file to create the Redis master deployment in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command:
```console
$ kubectl create -f guestbook-go/redis-master-controller.yaml
```
2. To verify that the redis-master controller is up, list the deployments you created in the cluster with the `kubectl get deployments` command(if you don't specify a `--namespace`, the `default` namespace will be used. The same below):
```console
$ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
redis-master 1/1 1 1 33m