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

documentation for running event-gateway on k8s #498

Merged
merged 33 commits into from
Aug 16, 2018

Conversation

sebito91
Copy link
Contributor

@sebito91 sebito91 commented Aug 6, 2018

What did you implement:

Update instructions on deploying to kubernetes, both local and remote clusters.

How did you implement it:

Helm charts, custom resource definitions and kubernetes

How can we verify it:

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@sebito91 sebito91 added the WIP label Aug 6, 2018
@sebito91 sebito91 self-assigned this Aug 6, 2018
@sebito91 sebito91 changed the title K8s documentation for running event-gateway on k8s Aug 6, 2018
@codecov
Copy link

codecov bot commented Aug 6, 2018

Codecov Report

Merging #498 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #498   +/-   ##
=======================================
  Coverage   71.01%   71.01%           
=======================================
  Files          37       37           
  Lines        2201     2201           
=======================================
  Hits         1563     1563           
  Misses        575      575           
  Partials       63       63

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b31577...1b8a70f. Read the comment docs.

README.md Outdated
@@ -92,6 +92,15 @@ Then run the binary in development mode with:
$ event-gateway -dev
```

### Kubernetes

We've added `helm` charts to the repo for a quick deploy to an existing cluster. Please note, the default
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of writing "we've added" we could change it to something like "There are"

command: ["--db-hosts=eg-etcd-cluster-client:2379", "--log-level=debug"]
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer the GNU CLI flags and changed these accordingly. In golang now there isn't really any difference between the single - and the double -- when processing long flags. IMHO, short flags are single - and long flags are --.

https://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html

If you're not happy with this change I'm happy to revert.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great to be consistent in the docs. Here https://github.com/serverless/event-gateway/blob/cd14c4004bb4aa3c3082526235fff0d8a357736d/docs/running-locally.md e.g. we use single -. I'm fine with both options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also a good call here, will update to keep the double -- for consistency.


With your environment set up, you can now jump to the [examples](#examples) section to put your `event-gateway` to use!

## Minikube or local clusters
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should simply link to this page https://kubernetes.io/docs/tasks/tools/install-minikube/

Copy link
Contributor

@mthenw mthenw Aug 13, 2018

Choose a reason for hiding this comment

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

Also lates version of Docker includes simply way to run K8s locally https://docs.docker.com/docker-for-mac/kubernetes/#override-the-default-orchestrator. I think we should also include that in this guide. Tho it can be done as a separate PR (task).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would disagree with your first comment, as the k8s documentation is notoriously difficult to read. I was debating where to include the raw fedora instructions but opted to do it ourselves because each environment is different. Still pending instructions on the MacOS side, but will update that shortly.

ACK on the second comment, will investigate this option soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding installation guide, so maybe better options is to extract it to separate md file? Probably most of the people interested in k8s will have minikube already installed. I think it will be better this guide will be straight-forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call on that, I'll move the instructions to a supplemental file and link to it here. Will ping you when that update is ready.

@sebito91 sebito91 removed the WIP label Aug 15, 2018
Copy link
Contributor

@alexdebrie alexdebrie left a comment

Choose a reason for hiding this comment

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

@sebito91 This looks great. Very clean scripts and the README is mostly pretty clear.

The biggest areas I got hung up on are:

  1. Minikube and what areas that affects.
  2. Duplicated helm portions in the quickstart?
  3. Environment variable vs. IP address for EG.

Happy to discuss further.

instructions [here](https://docs.helm.sh/using_helm/#quickstart) if you have not set this up previously.

**NOTE:** This portion of the config expects you to have a pre-existing kubernetes cluster (not minikube). For
local development please check the [minikube](MINIKUBE.md) information below.
Copy link
Contributor

Choose a reason for hiding this comment

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

@sebito91 I'm confused about this note. Couple questions:

  1. Is this different than the GKE vs. minikube note in the first paragraph of this section?

  2. Does it mean I don't run the helm commands below?

  3. It says to check the minikube information "below", but does that refer to the MINIKUBE.md doc? Don't see anything below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good call. @mthenw had comments earlier to move the minikube instructions from this doc to a standalone, the MINIKUBE.md you see now. I'll update this to remove the below from the statement.

Other than that, the instructions should be the exact same pushing to minikube locally or to GKE. I have to admit I have not tested the latter.


With your environment set up, you can now jump to the [examples](#examples) section to put your `event-gateway` to use!

### Using helm
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this Using helm section a duplicate of the section above? Should I be running both the commands above and the commands in this Using helm section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are indeed largely the same (if not exact now). Initially the requirements were different for minikube, specifically since minikube doesn't support LoadBalancers like GKE would. We replaced the LB with Ingress across the board, so the instructions are largely the same.

I think in honesty we should just remove each of the helm and CRD sections here, they are confusing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree that this section is confusing and seems redundant. Can we simply remove this and rename Quickstart as "Quickstart using helm". We can add a CRD Quickstart later

routing will ensure the request goes to the proper service managed by the cluster.

**DOUBLENOTE:** if you did not want to use an environment variable for connecting to the `event-gateway`, you can use
the IP address of your Ingress. Please check the [Quickstart](#quickstart) for reference.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused on the env variable vs. IP address split here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does say the same thing :/

It should reference the /etc/hosts instructions.

curl --request POST \
--url http://eventgateway.minikube/v1/spaces/default/eventtypes \
--header 'content-type: application/json' \
--data '{ "name": "eventgateway.function.invoked" }'
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be good to do the default http.request Event Type. Then, after setting up a subscription, show the user how to emit an http.request event and get a response.

On the other hand, it could require a working function example, which would add length to the tutorial. 🤔 Open to thoughts here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are loosely arranged in functions as a reference, not necessarily in any particular sequence. I think if anything we might want a separate tutorial on how to use an actual EG example from https://github.com/serverless/event-gateway/tree/master/examples

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep good point. Not worth including in this resource ATM.

Copy link
Contributor

@ganeshvlrk ganeshvlrk left a comment

Choose a reason for hiding this comment

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

@sebito91 Looks good overall. Left some comments for your review though

README.md Outdated

The repo contains `helm` charts for a quick deploy to an existing cluster. Please note, the default
installation requires proper `loadbalancer` support out of the box. If you don't have this enabled in your
cluster you can check the `minikube` instructions for more guidance.
Copy link
Contributor

Choose a reason for hiding this comment

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

@sebito91 When we say "requires proper loadbalancer support OOTB" what do we mean? Didn't we switch to using an ingress?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to be removed, great catch.

README.md Outdated
cluster you can check the `minikube` instructions for more guidance.

[Helm Chart](./contrib/helm/README.md)
[Minikube](./contrib/helm/README.md)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are both of these links correct?
Should Minikube link out to Minikube readme ?

# Event Gateway on Kubernetes (minikube)

To develop and deploy the `event-gateway` and all related elements locally, the easiest method includes using
the [minikube](https://github.com/kubernetes/minikube) toolset. To get started, set up your cluster with the
Copy link
Contributor

Choose a reason for hiding this comment

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

would recommend calling it "...set up your local cluster with..."

# Event Gateway on Kubernetes

This chart deploys the Event Gateway with etcd onto a Kubernetes cluster. Please note, the default instructions expect
an existing kubernetes cluster that supports ingress, such as GKE. If your environment doesn't have ingress support
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any instructions that users can use to test if their cluster supports ingress?

Also, here we say ingress, but in the top level Readme, we say load balancer which should be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIxed the top-level README but I'm not quite sure if there are examples to check for ingress enablement. From a minikube perspective we need to active enable the addons (e.g. minikube addons enable ingress), but from from hosted version of k8s I'm not sure.

I can dig into this and amend as necessary.


**etcd-operator**
```bash
helm install stable/etcd-operator --name ego [--namespace <namespace>]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the release name (--name) required? I guess its autogenerated if not specified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's correct. It's better to name it than to go searching for the service later.

[sborza@icebox]:~/src/github.com/serverless/event-gateway (k8s):$ helm install -h
This command installs a chart archive.

  ...

Usage:
  helm install [CHART] [flags]

Flags:
      --ca-file string           verify certificates of HTTPS-enabled servers using this CA bundle
      --cert-file string         identify HTTPS client using this SSL certificate file
      --dep-up                   run helm dependency update before installing the chart
      --devel                    use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
      --dry-run                  simulate an install
      --key-file string          identify HTTPS client using this SSL key file
      --keyring string           location of public keys used for verification (default "/home/sborza/.gnupg/pubring.gpg")
  -n, --name string              release name. If unspecified, it will autogenerate one for you
  ...


**event-gateway**
```bash
helm install event-gateway --name eg [--namespace <namespace>]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above


With your environment set up, you can now jump to the [examples](#examples) section to put your `event-gateway` to use!

### Using helm
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree that this section is confusing and seems redundant. Can we simply remove this and rename Quickstart as "Quickstart using helm". We can add a CRD Quickstart later

}
```

#### Register an event
Copy link
Contributor

Choose a reason for hiding this comment

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

We are registering an 'Event Type' as against an 'Event'. Would be good to update references in this section to reflect the same

1. [Quickstart](#quickstart)
1. [Using helm](#using-helm)
1. [Using custom resources](#using-custom-resources)
1. [Examples](#examples)
Copy link
Contributor

Choose a reason for hiding this comment

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

This section should ideally take the user through an end to end EG example that it links out to. Just providing Curl examples for the API is not incredibly satisfying as an outcome for what EG enables developers to do. Can be done in a follow up PR. @alexdebrie @sebito91 Please review.

Copy link
Contributor

@alexdebrie alexdebrie left a comment

Choose a reason for hiding this comment

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

A few more notes


To develop and deploy the `event-gateway` and all related elements locally, the easiest method includes using
the [minikube](https://github.com/kubernetes/minikube) toolset. To get started, set up your cluster with the
following instructions...
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "..."

instructions [here](https://docs.helm.sh/using_helm/#quickstart) if you have not set this up previously.

**NOTE:** This portion of the config expects you to have a pre-existing kubernetes cluster (not minikube). For
local development please check the [minikube](MINIKUBE.md) information.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this note still needed? As I understand it, the helm instructions work with both minikube and something like GKE?

Next we'll need to collect the Event Gateway IP to use on the CLI. We have a couple of options available to reference the
internal services of the kubernetes cluster exposed via Ingress:

1. add Ingress IP to /etc/hosts (recommended)
Copy link
Contributor

Choose a reason for hiding this comment

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

The switching between eventgateway.minikube and EVENT_GATEWAY_URL environment variable is confusing to me. I'd suggest consolidating on one or the other just to make it easier. The more forks in a tutorial, the more confusing it gets.

My guess would be to use the environment variable as some people may be averse to messing with their /etc/hosts file but will defer to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was hoping that showing both methods in various functions would be helpful, given that we need to specify a header in one version but not the other.

Do you think this would be better suited for the TUTORIAL.md we discussed offline?

curl --request POST \
--url http://eventgateway.minikube/v1/spaces/default/eventtypes \
--header 'content-type: application/json' \
--data '{ "name": "eventgateway.function.invoked" }'
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep good point. Not worth including in this resource ATM.

@serverless serverless deleted a comment from sebito91 Aug 16, 2018
@@ -0,0 +1,341 @@
# Event Gateway on Kubernetes
Copy link
Contributor

@mthenw mthenw Aug 16, 2018

Choose a reason for hiding this comment

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

This is readme for the whole contrib directory. It also contains other stuff (Terraform module) so please rename this README and create another one pointing also to https://github.com/serverless/event-gateway/blob/master/contrib/terraform/README.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I can move this down a level

@@ -0,0 +1,66 @@
# Event Gateway on Kubernetes (minikube)
Copy link
Contributor

Choose a reason for hiding this comment

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

This doc is about setting up minikube. I think we should rename the title.

```

### Kubernetes
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not point to the long readme file here. Only to MINIKUBE guide. I think it's worth to link "helm chart" to the /contrib/helm dir.

@@ -8,7 +8,6 @@
"@serverless/serverless-event-gateway-plugin": "^0.7.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove those files from this PR? :)

Copy link
Contributor

@alexdebrie alexdebrie left a comment

Choose a reason for hiding this comment

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

LGTM

@sebito91 sebito91 merged commit 02e8f5f into serverless:master Aug 16, 2018
@sebito91 sebito91 deleted the k8s branch August 16, 2018 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants