Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guestbook revisions + Minikube Default Frontend Service #46

Merged
merged 10 commits into from Aug 4, 2017

Conversation

cody-clark
Copy link
Contributor

No description provided.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 1, 2017
@ahmetb ahmetb self-requested a review August 1, 2017 23:13
Copy link
Member

@ahmetb ahmetb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A preliminary review, will come back for more.

- [Troubleshooting](#troubleshooting)
- [Appendix: Accessing the guestbook site externally](#appendix-accessing-the-guestbook-site-externally)
- [Google Compute Engine External Load Balancer Specifics](#google-compute-engine-external-load-balancer-specifics)
**Note:** If you are using a [Google Container Engine](https://cloud.google.com/container-engine/) installation, please read [Create a Guestbook with Redis and PHP](https://cloud.google.com/container-engine/docs/tutorials/guestbook) instead. The basic concepts are the same, but the walkthrough is tailored to a Container Engine setup.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should delete such vendor-specific notes.

<!-- EXCLUDE_FROM_DOCS END -->

This example shows how to build a simple, multi-tier web application using Kubernetes and [Docker](https://www.docker.com/).
{% capture overview %}
This tutorial shows you how to build a simple, multi-tier web application using Kubernetes and [Docker](https://www.docker.com/). This example consists of the following:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build → build and deploy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following → following components

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->
* a web frontend
* a [Redis](https://redis.io/) master for storage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a single-instance redis master to store guestbook entries

<!-- BEGIN MUNGE: GENERATED_TOC -->
* a web frontend
* a [Redis](https://redis.io/) master for storage
* a replicated set of Redis slaves.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiple replicated redis instances
OR
multiple replicated redis instances, used to serve reads

I think "replicated set" is capturing the fact that this was once a ReplicaSet. but not antymore.

The example consists of:
{% capture objectives %}
* Start up a redis master.
* Start up a redis slave.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start up redis slaves


**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->
* a web frontend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiple web frontend instances


### Quick Start
### Creating the Redis Master Deployment
1. `cd` to the folder you saved the `.yaml.` files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrite as:

  1. Launch a terminal window in the directory you downloaded the manifest files
  2. Apply the Redis Master Deployment to the cluster using the redis-master-deployment.yaml file:

ditto for other steps.

service "frontend" created
deployment "frontend" created
```shell
kubectl create -f redis-master-deployment.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch to using kubectl apply. It has more benefits over kubectl create ,especially when updating.


Alternatively, you can start the guestbook by running:
{:start="3"}
3. Get the Pods to verify that the Redis Master Pod is running:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get the Pods → Query the list of Pods

Copy link
Member

@ahmetb ahmetb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost ready to go. Left some comments.

@@ -6,6 +6,8 @@ metadata:
app: guestbook
tier: frontend
spec:
# comment or delete the following line if you want to use a LoadBalancer
type: NodePort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need to update instructions on https://cloud.google.com/container-engine/docs/tutorials/guestbook#expose_frontend_on_an_external_ip_address after merging this.

maybe at some point we should have 2 service files (or a single file that describes both a NodePort service as well as a LoadBalancer). This way, minikube people can get it to work as well as people trying it out on the cloud.

Copy link
Contributor Author

@cody-clark cody-clark Aug 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I hadn't considered that. It looks like Minikube will just output <pending> for EXTERNAL-IP if I leave both type: NodePort and type: LoadBalancer uncommented, but I can otherwise still complete the tutorial.

Does including both types affect any for the Container Engine side?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cody-clark you can try, but I think we can't have both in the same YAML file. (I'm not sure it's a good practice to do so either.)

What would work in both platforms is to have 2 services (guestbook, guestbook-external) in a single file or separate files, but that would be more confusing. For now, let's keep it as is and I will update GKE tutorial.


### Prerequisites
## Start up the Redis Master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: always use empty line after headings to prevent rendering nuances in different markdown parsers

tier: backend
```
### Creating the Redis Master Service
The guestbook applications needs to communicate to the Redis master to write its data. You need to apply a [Service](https://kubernetes.io/docs/concepts/services-networking/service/) to proxy the traffic to the Redis master Pod. A Service defines a set of Pods and a policy to access them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a policy to access them.

Service doesn't define a policy. Consider removing that part.


#### Create a Service
kubectl apply -f redis-master-service.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have too much space, the rendered code block has 4 spaces at the beginning, throughout the doc. Please start all code block lines at 4 spaces.


#### Create a Deployment
kubectl apply -f redis-slave-deployment.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has 1 extra space character at the beginning (click View button for this file on github UI)

redis-slave-2005841000-phfv9 0/1 ContainerCreating 0 6s

### Creating the Redis Slave Service
The guestbook application needs to communicate to Redis workers to read data. To make the Redis workers discoverable, you need to set up a Service. A Service provides transparent load balancing to a set of Pods.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slave vs. workers: You need to unify the terminology. It's ok if you decide to change slave work (incl. filenames) to worker.

I already use the word worker and not slave (that only comes from imported files/filenames) in GKE guestbook: https://cloud.google.com/container-engine/docs/tutorials/guestbook


#### Optional Interlude
## Set up and Expose the Guestbook Frontend
This tutorial uses a simple PHP server that is configured to talk to either the slave or master Services, depending on whether the client request is a read or a write. It exposes a simple JSON interface, and serves a jQuery-Ajax-based UX.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit too much detailed for anyone following the tutorial. suggested rewrite:

The guestbook application has a web frontend serving the HTTP requests written in PHP. It is configured to connect to the redis-master service for write requests and the redis-slave service for read requests.

#### Finding a Service

Kubernetes supports two primary modes of finding a Service — environment variables and DNS.
{:start="2"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a chance you might not need the {:start="2"} stuff. Consider the following markdown with quotes etc:

Rendering:


  1. Hello hello hello

  2. Hello this will be a quote:

    quote quote

  3. here's some code yo:

    code code
    i love coding
    
  4. last item (note how I still say 1 and it's still all numbered correctly)


Source:

1. Hello hello hello
1. Hello this will be a quote:

      > quote quote

1. here's some code yo:

       code code
       i love coding

1. last item (note how I still say 1 and it's still all numbered correctly)

not a big deal, just try it out on staging container (or in a separate PR to docs and see netlify staging). I've got a feeling like we can get rid of jekyll-specific stuff like this and rely more on Markdown semantics. It could be hard to get how many spaces you exactly need to add quotes/code blocks in a list, but it's not impossible.


1. Run the following command to delete all Pods, Deployments, and Services.

kubectl delete deployments,services -l "app in (redis, guestbook)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is REALLY cool actually TIL you can use comma like that, but it's simultaneously super confusing.

Let's expand this as:

kubectl delete deployment -l app=redis
kubectl delete service -l app=redis
kubectl delete deployment -l app=guestbook
kubectl delete service -l app=guestbook

the result should be the same.


#### Create a Deployment
Although the Redis master is a single pod, you can make it highly available to meet traffic demands by adding replica Redis workers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slave vs worker: please unify the terminology. either rename files (and name: fields) to worker, or just call them slave throughout the tutorial)


### Creating the Guestbook Frontend Deployment

1. Apply the frontend Deployment from the following `frontend-deployment.yaml` file:

kubectl apply -f frontend-deployment.yaml

{% include code.html language="yaml" file="frontend-deployment.yaml" ghlink="/docs/tutorials/docs/tutorials/stateless-application/frontend-deployment.yaml" %}
{% include code.html language="yaml" file="frontend-deployment.yaml" ghlink="/docs/tutorials/docs/tutorials/stateless-application/frontend-deployment.yaml" %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/docs/tutorials/docs/tutorials/ is incorrect


{% include code.html language="yaml" file="redis-master-deployment.yaml" ghlink="/docs/tutorials/docs/tutorials/stateless-application/redis-master-deployment.yaml" %}
{% include code.html language="yaml" file="redis-master-deployment.yaml" ghlink="/docs/tutorials/docs/tutorials/stateless-application/redis-master-deployment.yaml" %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • /docs/tutorials/docs/tutorials/ is wrong
  • can you please update the URL as if we created another directory, i.e. guestbook/ under stateless-deployment/?

- A [redis](http://redis.io/) master (for storage), and a replicated set of redis 'slaves'.
{% include task-tutorial-prereqs.md %}
Download the following configuration files:
1. [redis-master-deployment.yaml](https://kubernetes.io/docs/tutorials/docs/tutorials/stateless-application/redis-master-deployment.yaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a space below the 1. otherwise they all render on the same line (not as a list). also enumerating them as 1. 2. 3. is not important, you can just call them all 1. 1. 1., it will count the same.

markdown rule of thumb: when in doubt, add spaces.


If you are in a live Kubernetes cluster, you can just kill the pods by deleting the Deployments and Services. Using labels to select the resources to delete is an easy way to do this in one command.
The guestbook application has a web frontend serving the HTTP requests written in PHP. It is configured to connect to the 'redis-master' Service for write requests and the 'redis-slave' service for Read requests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of single-quotes, use backtick for <code> style for consistency.


If the `LoadBalancer` specification is used, it can take a short period for an external IP to show up in `kubectl get services` output, but you should then see it listed as well, e.g. like this:
**Note:** Some cloud providers, like Google Compute Engine or Google Container Engine, support external load balancers. If your cloud provider supports load balancers and you want to use it, simply delete or comment out `type: NodePort`, and uncomment `type: LoadBalancer`.
{: note}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing period in .note. callout doesn't render.


You can list the forwarding rules like this (the forwarding rule also indicates the external IP):
Once the frontend Service is running, you need to find the IP address to view your Guestbook.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add something like:

If you deployed this application to Minikube or a local cluster ...

[gce-firewall-docs]: https://cloud.google.com/compute/docs/networking#firewalls
### Viewing the Frontend Service via `LoadBalancer`

Once the frontend Service is running, you need to find the IP address to view your Guestbook.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add something like:

If you deployed the frontend-service.yaml manifest with type: LoadBalancer configuration...


deployment "redis-master" deleted
deployment "redis-slave" deleted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can delete these empty lines in the output, it looks more confusing IMO. Also there won't be empty lines in the output if I copypaste the commands above

{% endcapture %}

{% capture whatsnext %}
* Read more about [connecting applications](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this item, can you link to

  • WordPress+MySQL tutorial
  • Kubernetes Basics Interactive tutorial (/docs/tutorials/kubernetes-basics/)

@ahmetb
Copy link
Member

ahmetb commented Aug 4, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2017
@ahmetb ahmetb merged commit 00005df into kubernetes:master Aug 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants