Skip to content

Commit

Permalink
Refactor to use Kubernetes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Flynn committed Feb 21, 2017
1 parent 68c7863 commit 25e9dd6
Show file tree
Hide file tree
Showing 37 changed files with 173 additions and 570 deletions.
105 changes: 84 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,103 @@ The Tools

Tools we'll be using:

1. [docker](https://www.docker.com/)
2. [docker-compose](https://docs.docker.com/compose/)
3. [envoy](https://lyft.github.io/envoy/)
1. [minikube](https://github.com/kubernetes/minikube)
2. [envoy](https://lyft.github.io/envoy/)

You'll need to get `docker` and `docker-compose` installed (Mac users, see below). You do _not_ need to install `envoy` though! It will magically Just Happen as we build containers out.
You'll need to get Minikube installed before starting. You do _not_ need to install `envoy` though! It will magically Just Happen as we build containers out.

MAC USERS TAKE NOTE
-------------------
The Process
-----------

If (like me) you're on a Mac, the Docker driver matters. I've been using the `xhyve` driver because I don't feel like installing VirtualBox on my Mac, but there's an issue with this: the `xhyve` driver doesn't do the right thing with mounting host files in the container.
We're going to work with a very, very simple application: a simple Flask app that allows creating users, then reading them back.

In the Official Envoy Examples, the `envoy` config files are mounted in containers, just to make things easier when tweaking `envoy` configs. We don't do that in this walkthrough, because it doesn't work on my Mac.
Step 0: Minikube
================

The Process
-----------
First we need to start Minikube. On a Mac for your first startup, you need to decide if you're going to use the VirtualBox driver for Minikube, or the `xhyve` driver. I use `xhyve`:

```minikube start --vm-driver xhyve```

Once minikube is started, run

```eval $(minikube docker-env)```

to get hooked up to the Minikube Docker daemon (which we'll be using when we build Docker images later).

Step 1: Basic Flask App
=======================

Start the Postgres and `usersvc` containers:

```
sh postgres/up.sh
sh usersvc/up.sh
```

and then you should be able to check things out:

```
curl $(minikube service --url usersvc)/user/health
```

should show you something like

We're going to work with a very, very simple application. We've broken the process up into steps -- to follow along, you'll go through each step by looking at the `README.md` in that step's directory.
```
{

"hostname": "usersvc-1941676296-zlrt2",
"msg": "user health check OK",
"ok": true,
"resolvedname": "172.17.0.10"

}
```

Next up we can try saving and retrieving a user:

```
curl -X PUT \
-H "Content-Type: application/json" \
-d '{ "fullname": "Alice", "password": "alicerules" }' \
$(minikube service --url usersvc)/user/alice
```

This should give us a user record for Alice, including her UUID but not her password:

```
{
"fullname": "Alice",
"hostname": "usersvc-1941676296-zlrt2",
"ok": true,
"resolvedname": "172.17.0.10",
"uuid": "44FD5687B15B4AF78753E33E6A2B033B"

}
```

So let's get started!
and we should be able to read the user back (sans password again) with

Step 0: The Docker Machine
==========================
```
curl $(minikube service --url usersvc)/user/alice
```

We'll use a `docker-machine` called "esteps" for this example, so let's get that set up. On my Mac, that's
Step 2: Enter Envoy
===================

Start the `edge-envoy` container:

```
docker-machine create --driver xhyve esteps
eval $(docker-machine env esteps)
sh edge-envoy/up.sh
```

The `xhyve` driver is specific to the Mac; Linux users should drop the `--driver` parameter.
then drop the `usersvc` container and replace it with the `usersvc2` container:

Step 1: Postgres and Docker and Flask, oh my!
=============================================
```
sh usersvc/down.sh
sh usersvc2/up.sh
```

and now going through Envoy should work:

We'll start by using `docker-compose` to create an application with a Flask front end to a Postgres database. Check it out in `STEP-1/README.md`.
```
curl $(minikube service --url edge-envoy)/user/health
curl $(minikube service --url edge-envoy)/user/alice
```

137 changes: 0 additions & 137 deletions STEP-1/README.md

This file was deleted.

42 changes: 0 additions & 42 deletions STEP-1/docker-compose.yml

This file was deleted.

37 changes: 0 additions & 37 deletions STEP-1/kube-all.sh

This file was deleted.

17 changes: 0 additions & 17 deletions STEP-1/postgres/service.yaml

This file was deleted.

Loading

0 comments on commit 25e9dd6

Please sign in to comment.