Skip to content

Adding GitHub Sample for move from eventing.#339

Merged
knative-prow-robot merged 7 commits into
knative:masterfrom
n3wscott:eventing_samples
Aug 27, 2018
Merged

Adding GitHub Sample for move from eventing.#339
knative-prow-robot merged 7 commits into
knative:masterfrom
n3wscott:eventing_samples

Conversation

@n3wscott
Copy link
Copy Markdown
Contributor

Moving GitHub eventing sample from knative/eventing to knative/docs.

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 20, 2018
@n3wscott n3wscott changed the title [WIP] Staging for move from eventing. [WIP] Staging GitHub Sample for move from eventing. Aug 20, 2018
@n3wscott
Copy link
Copy Markdown
Contributor Author

/retest

Grant for LGTM:
/cc @grantr

Evan for Approval:
/assign @evankanderson

@n3wscott
Copy link
Copy Markdown
Contributor Author

related to knative/eventing#343

@n3wscott
Copy link
Copy Markdown
Contributor Author

/test pull-knative-docs-integration-tests

@n3wscott n3wscott changed the title [WIP] Staging GitHub Sample for move from eventing. Adding GitHub Sample for move from eventing. Aug 20, 2018
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 20, 2018
@n3wscott
Copy link
Copy Markdown
Contributor Author

READY! PTAL.

@grantr
Copy link
Copy Markdown
Contributor

grantr commented Aug 20, 2018

Is this intended to be exactly the same content as knative/eventing#343?

@n3wscott
Copy link
Copy Markdown
Contributor Author

Is this intended to be exactly the same content as knative/eventing#343?

Yes, but this branch is now slightly ahead in the samples code.

@n3wscott
Copy link
Copy Markdown
Contributor Author

istio...

/test pull-knative-docs-integration-tests

@samodell
Copy link
Copy Markdown
Contributor

Taking a look from the docs perspective today

@samodell samodell self-assigned this Aug 21, 2018
`(looks pretty legit)` to the PR title.

## Prerequisites

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Below the "Prerequisites" heading, add: "You will need:"

if you need to create one.
- [Docker](https://www.docker.com/) installed and running on your local machine,
and a Docker Hub account configured (you'll use it for a container registry).
- The Kubernetes cluster also has Knative eventing core installed. You can
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: "The Kubernetes cluster also has Knative eventing core installed." --> "Knative eventing core installed on your Kubernetes cluster."

## Configuring Knative

To use this sample, you'll need to install the `stub` ClusterBus and the
`github` EventSource.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"EventSource." --> "EventSource:"

`github` EventSource.

```shell
kubectl apply -f https://storage.googleapis.com/knative-releases/eventing/latest/release-clusterbus-stub.yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might add comments here; IE:
# Installs ClusterBus
# Installs EventSource

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(This parallels the k8sevents doc.)

@@ -0,0 +1,162 @@
# GitHub Flow
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Github Flow" --> "Creating a GitHub Flow Using Knative Eventing", or similar.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about "Reacting to GitHub Events"

kubectl apply -f eventing/samples/github-events/auth.yaml
```

## Build and deploy the sample
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Build and deploy the sample" --> "Building and deploying the sample"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

k8sevents has the same issue.

Do we have a standard template for these somewhere?


## Understanding what happened

<!--TODO:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be fleshed out now? I feel like there's a good start in the introduction, and it would add a lot to the sample.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 -- much of this should be able to be copied from the k8sevents source, with some additional detail on how the Feed for github has a provisioning step which both calls the GitHub API and creates an underlying service (receive adapter). The rest of the text should be able to be shared with the k8sevent doc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Requesting this update be a follow-up PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't love leaving a blank section in the guide, though. If you're set on not adding anything here for the moment, I'd move the heading inside the TODO so the rendered version of the file doesn't look like it has a blank section. @n3wscott


1. Use Docker to build the sample code into a container. To build and push with
Docker Hub, run these commands replacing `{username}` with your Docker Hub
username. Run the following from the _root_ of the `knative/docs` repo:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"run these commands replacing {username} with your Docker Hub username" -->
"run the following commands, replacing {username} with your Docker Hub username"

[assign a static IP address](https://github.com/knative/docs/blob/master/serving/gke-assigning-static-ip-address.md)
instructions.

## Configuring Knative
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Configuring Knative" doesn't really seem to describe what's going on here. Too generic.

Maybe "Installing ClusterBus and EventSource"? "Installing Eventing dependencies"? "Configuring Knative for Eventing"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW, this matches the k8sevents sample, so we should probably update both at the same time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok it will be a followup.

Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

I'm reviewing this in favor of knative/eventing#343, and will close that when this is submitted.

FROM golang AS builder

WORKDIR /go/src/github.com/knative/docs/
ADD . /go/src/github.com/knative/docs/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like you don't need to use dep, so this is much cleaner than what I had to do in the k8sevents commit (see f00e99d and d1b685a for the dep changes). Prior to needing dep, I used the following, which is even simpler than what you have here, and works from the sample directory:

FROM golang AS builder

ADD . /go/src/k8s-events
# Build the event processing function command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN go get k8s.io/api/core/v1 github.com/knative/eventing/pkg/event
RUN go install k8s-events

FROM gcr.io/distroless/base
COPY --from=builder /go/src/github.com/knative/docs/k8s-events /sample
...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I copied the k8s event docker file and changed the path of the runable. I was able to get this to work testing the README script just fine.

`Channel`, and the `Subscription`.

In response to a pull request event, the sample app _legit_ Service will add
`(looks pretty legit)` to the PR title.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd put this first -- this is actually what the interesting part of the sample is.

- A domain name that allows GitHub to call into the cluster: Follow the
[configure a custom domain](https://github.com/knative/docs/blob/master/serving/using-a-custom-domain.md) and
[assign a static IP address](https://github.com/knative/docs/blob/master/serving/gke-assigning-static-ip-address.md)
instructions.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this the order the instructions should be followed in (custom domain first, then static IP)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It makes more sense to get a static ip and then use that for the domain... flipped them.

```
- A domain name that allows GitHub to call into the cluster: Follow the
[configure a custom domain](https://github.com/knative/docs/blob/master/serving/using-a-custom-domain.md) and
[assign a static IP address](https://github.com/knative/docs/blob/master/serving/gke-assigning-static-ip-address.md)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@samodell Should these be relative links?

[assign a static IP address](https://github.com/knative/docs/blob/master/serving/gke-assigning-static-ip-address.md)
instructions.

## Configuring Knative
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW, this matches the k8sevents sample, so we should probably update both at the same time.


## Cleaning up

To clean up the function, `Flow`, auth, and secret:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to clean up auth.yaml? I think it's needed to make the github source able to operate at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes but I need help because I have not looked into what rbac arguments should look like

namespace: default
roleRef:
kind: ClusterRole
name: cluster-admin
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we avoid making this cluster-admin? Something like the following definition (instead of ClusterRoleBinding) should be sufficient IIUC:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: create-knative-service
  namespace: default
rules:
- apiGroups: ["serving.knative.dev"]
  resources: ["services"]
  verbs: ["get", "list", "watch", "create", "update", "delete", "patch"]
---
# This enables the feed-sa to deploy the receive adapter.
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: feed-sa-deploy
  namespace: default
subjects:
  - kind: ServiceAccount
    name: feed-sa
    namespace: default
roleRef:
  kind: Role
  name: create-knative-service
  apiGroup: rbac.authorization.k8s.io

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

awesome. 👍 thanks!!

serviceAccountName: feed-sa
trigger:
eventType: dev.knative.github.pullrequest
resource: n3wscott/kopond
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You probably want to update 5 to have the user change this resource before creating the Flow.

key: githubCredentials
action:
target:
kind: Route
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Service?


// Set up the auth for being able to talk to Github. It's
// odd that you have to also pass context around for the
// calls even after giving it to client. But, whatever.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a rant about Go?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is Ville's rant. hahahah

@n3wscott
Copy link
Copy Markdown
Contributor Author

/test pull-knative-docs-integration-tests

@n3wscott
Copy link
Copy Markdown
Contributor Author

PTAL?

@samodell
Copy link
Copy Markdown
Contributor

/lgtm
Will approve after blank section is either fleshed out or the heading is moved within the TODO comment.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 27, 2018
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 27, 2018
@samodell
Copy link
Copy Markdown
Contributor

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 27, 2018
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: n3wscott, samodell

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit b37d9ab into knative:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants