Skip to content

Commit

Permalink
Bump Kservice to 0.6, fixes and doc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent-DeSousa-Tereso authored and tekton-robot committed May 30, 2019
1 parent 3c93673 commit 03eeb7c
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 229 deletions.
9 changes: 9 additions & 0 deletions webhooks-extension/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 7 additions & 26 deletions webhooks-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,12 @@ The Webhooks Extension for Tekton allows users to set up Git webhooks that will

In addition to Tekton/Knative Eventing glue, it includes an extension to the Tekton Dashboard.

## Dependencies

This project requires Knative [eventing](https://knative.dev/docs/eventing/), [eventing sources](https://knative.dev/docs/eventing/sources/), and [serving](https://knative.dev/docs/serving/). Install these components [here](https://knative.dev/docs/install/).
## Runtime Dependencies
- [Tekton](https://github.com/tektoncd/pipeline) & [Tekton Dashboard](https://github.com/tektoncd/dashboard)
- Knative [eventing](https://knative.dev/docs/eventing/), [eventing sources](https://knative.dev/docs/eventing/sources/), & [serving](https://knative.dev/docs/serving/)

## Install

Verify that you have installed the [dependencies](#dependencies).

Until such a time an official release is hosted you will need to use the development process to install this extension.

If you have `ko`:

```
$ docker login
$ export KO_DOCKER_REPO=docker.io/<mydockername>
$ ko apply -f config/
```

Alternatively, without `ko`, you can use the install script we provided:

The script will build the image, push to your registry of choice and then kubectl apply the relevant yaml into the specified namespace. Please note this namespace needs to be the namespace into which you have installed the Tekton Dashboard.

To initiate this installation, run `development_install.sh`.

_Note: Your git provider must be able to reach the address of this extension's sink. The sink is deployed with a Knative service, so you may need to configure Knative serving. We recommend [setting up a custom domain](https://knative.dev/v0.3-docs/serving/using-a-custom-domain/) with the extension `.nip.io`._
Please see the [development installation guide](https://github.com/tektoncd/experimental/blob/master/webhooks-extension/test/README.md#scripting)

## Running tests

Expand Down Expand Up @@ -69,10 +50,10 @@ Reference the [Knative eventing GitHub source sample](https://knative.dev/docs/e

## Limitations

- Only GitHub webhooks are currently supported.
- Only Git Hub webhooks are currently supported.
- Only `push` and `pull_request` events are supported at the moment. The webhook is currently only created with both `push` and `pull_request` events.
- All knative event sources are created in the namespace into which the dashboard and this extension are installed.
- Currently the docker registry to which built images are pushed is hard coded from the registry you specified at install time, there is work underway to change this restriction.
- All Knative event sources are created in the namespace into which the dashboard and this extension are installed.
- Currently the Docker registry to which built images are pushed is hard coded from the registry you specified at install time, there is work underway to change this restriction.
- Only one webhook can be created for each git repository, so each repository will only be able to trigger a PipelineRun from one webhook.

- Three pipeline definitions are currently supported.
Expand Down
10 changes: 4 additions & 6 deletions webhooks-extension/cmd/sink/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ func main() {

// Serve
logging.Log.Info("Creating server and entering wait loop.")
port := ":8080"
portnum := os.Getenv("PORT")
if portnum != "" {
port = ":" + portnum
logging.Log.Infof("Port number from config: %s.", portnum)
port := os.Getenv("PORT")
if port == "" {
logging.Log.Fatal("Knative runtime contract should specify PORT env via single container port in yaml")
}
server := &http.Server{Addr: port, Handler: wsContainer}
server := &http.Server{Addr: ":"+port, Handler: wsContainer}
logging.Log.Fatal(server.ListenAndServe())
}
40 changes: 18 additions & 22 deletions webhooks-extension/config/sink-kservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@ metadata:
labels:
app: webhooks-extension-sink
spec:
runLatest:
configuration:
revisionTemplate:
spec:
container:
image: "github.com/tektoncd/experimental/webhooks-extension/cmd/sink"
imagePullPolicy: Always
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /liveness
readinessProbe:
httpGet:
path: /readiness
env:
- name: PORT
value: "8080"
- name: INSTALLED_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
template:
spec:
containers:
- image: "github.com/tektoncd/experimental/webhooks-extension/cmd/sink"
imagePullPolicy: Always
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /liveness
readinessProbe:
httpGet:
path: /readiness
env:
# PORT var resolved via containerPort by Knative
# TODO: Find better way to provide INSTALL_NAMESPACE since Knative does not support Downward API
- name: INSTALLED_NAMESPACE
value: "default"
50 changes: 0 additions & 50 deletions webhooks-extension/development_install.sh

This file was deleted.

107 changes: 57 additions & 50 deletions webhooks-extension/test/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
# Testing and scripting

# Scripting
This directory will contain scripts used for several related purposes.

- As a developer I want to set up a local test environment
- From clean: install all prerequisites
- From CLEAN: install all prerequisites
- Having prereqs installed, set up a pipeline and webhook for a simple test repository
- We'll want automated tests that do much the same things.

This is a work in progress and will take a while to settle down.

## Clean Docker Desktop: Install prereqs
## Install tooling requirements
You must install these tools:

- check test/config.sh
- `test/install_prereqs.sh`
- go: The language Tekton Pipelines is built in
- git: For source control
- dep: For managing external Go dependencies. - Please Install dep v0.5.0 or greater.
- ko: For development. ko version v0.1 or higher is required for pipeline to work correctly.
- kubectl: For interacting with your kube cluster
- helm: Templating is used to install Istio according to [Knative docs](https://knative.dev/docs/install/installing-istio/)

## Install Dashboard and wehooks extension

- you need a docker hub ID and will be prompted to 'docker login' if you've not all ready done so
- check that GOPATH is set
## Dependency Versioning
The installation script installs the latest version of Istio and known compatible versions of Knative as per values in the version section of [config.sh](https://github.com/tektoncd/experimental/blob/master/webhooks-extension/test/config.sh). Knative Serving 0.6 has made considerable changes to the service definition so levels below this are not supported.

## Install Dependencies/Prereqs
- Update `config.sh` as necessary
- Run `install_prereqs.sh`.

## Install Dashboard and wehooks extension
- Update `config.sh` as necessary
- Check that `GOPATH` is set properly
- `docker login` (or be prompted later within execution)
- `export KO_DOCKER_REPO=docker.io/[your_dockerhub_id]`
- `test/install_dashboard_and_extension.sh`
- Run `install_dashboard_and_extension.sh`

# Testing
## Test with a webhook
_Note: Your git provider must be able to reach the address of this extension's sink. The sink is deployed with a Knative service, so you may need to configure Knative serving. We recommend [setting up a custom domain](https://knative.dev/v0.3-docs/serving/using-a-custom-domain/) with the extension `.nip.io`. The `install_prereqs.sh` script patches the workstation IP is patched into the knative serving config-map (config-domain) as mentioned in the previous link._

As we state in config.sh,
```
# Note that to receive webhooks, your github must be able to http POST to your Tekton installation.
# Our initial testing has used Docker Desktop and GitHub Enterprise.
```

Webhooks are outbound HTTP requests from (in this case GitHub) to your Kubernetes environment. If you are behind a firewall it's unlikely that github.com will be able to reach you. So the two most common testing scenarios are,
- An in-house GitHub Enterprise to your Docker Desktop
Webhooks are outbound HTTP requests from (in this case Git Hub) to your Kubernetes environment. If you are behind a firewall, it's unlikely that github.com will be able to reach you. The two most common testing scenarios are:
- An in-house Git Hub Enterprise to your Docker Desktop
- github.com to your internet-facing kubernetes cluster in a commercial public cloud environment

The checked-in defaults current reflect the first of these two options. To test with a webhook you need to do some setup work.
Expand Down Expand Up @@ -70,42 +78,41 @@ Now you're ready to go:

For example,
```
k get pods -w
kubectl get pods -w
NAME READY STATUS RESTARTS AGE
knative-demo-test-1557836364-build-simple-fgzjr-pod-e47e4d 0/4 Completed 0 15m
knative-demo-test-1557836364-deploy-simple-vpjst-pod-dcd3e2 0/4 Completed 0 14m
knative-demo-test-qqdkd-rq9w6-deployment-5f999f6f87-mlcpd 0/3 PodInitializing 0 7s
tekton-dashboard-fdc9ff8cc-4f4w2 1/1 Running 0 23h
webhooks-extension-5b849f7d78-flbb7 1/1 Running 0 23h
knative-demo-test-qqdkd-rq9w6-deployment-5f999f6f87-mlcpd 2/3 Running 0 12s
knative-demo-test-qqdkd-rq9w6-deployment-5f999f6f87-mlcpd 3/3 Running 0 13s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 Pending 0 0s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 Pending 0 0s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 Init:0/1 0 0s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 PodInitializing 0 2s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 1/3 Running 0 8s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 2/3 Running 0 8s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 3/3 Running 0 13s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Pending 0 0s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Pending 0 0s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Pending 0 8s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Init:0/2 0 8s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Init:1/2 0 10s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 PodInitializing 0 11s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 3/4 Running 0 18s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 2/4 Running 0 37s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Completed 0 47s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Pending 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Pending 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Init:0/2 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Init:1/2 0 3s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 PodInitializing 0 4s
myapp-566f7f7fd-6szzf 0/1 Pending 0 0s
myapp-566f7f7fd-6szzf 0/1 Pending 0 0s
myapp-566f7f7fd-6szzf 0/1 ContainerCreating 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 1/4 Running 0 10s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Completed 0 11s
myapp-566f7f7fd-6szzf 1/1 Running 0 3s
knative-demo-test-qqdkd-rq9w6-deployment-5f999f6f87-mlcpd 2/3 Running 0 12s
knative-demo-test-qqdkd-rq9w6-deployment-5f999f6f87-mlcpd 3/3 Running 0 13s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 Pending 0 0s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 Pending 0 0s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 Init:0/1 0 0s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 0/3 PodInitializing 0 2s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 1/3 Running 0 8s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 2/3 Running 0 8s
webhooks-extension-sink-zx6pm-deployment-756759c79c-x9vqn 3/3 Running 0 13s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Pending 0 0s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Pending 0 0s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Pending 0 8s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Init:0/2 0 8s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Init:1/2 0 10s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 PodInitializing 0 11s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 3/4 Running 0 18s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 2/4 Running 0 37s
knative-demo-test-1557837318-build-simple-h72pb-pod-8b6aed 0/4 Completed 0 47s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Pending 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Pending 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Init:0/2 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Init:1/2 0 3s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 PodInitializing 0 4s
myapp-566f7f7fd-6szzf 0/1 Pending 0 0s
myapp-566f7f7fd-6szzf 0/1 Pending 0 0s
myapp-566f7f7fd-6szzf 0/1 ContainerCreating 0 0s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 1/4 Running 0 10s
knative-demo-test-1557837318-deploy-simple-tvk7v-pod-64fb78 0/4 Completed 0 11s
myapp-566f7f7fd-6szzf 1/1 Running 0 3s
```

The running `myapp` is the built and deployed code from GITHUB_REPO
The running `myapp` is the built and deployed code from `GITHUB_REPO`
13 changes: 10 additions & 3 deletions webhooks-extension/test/config.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/bash

# Version specs
export KNATIVE_VERSION="v0.5.0"
##### Version specs
# These defaults are known compatible versions
export KNATIVE_VERSION="v0.6.0"
export TEKTON_VERSION="0.3.0"
# You can also Specify exact version/release: https://github.com/istio/istio/releases
export ISTIO_VERSION="latest"
# Side car injection gets stuck in "Container Creating" state when disabled
export ISTIO_SIDECAR_INJECTION="true"
# To prevent Git Hub rate limiting when pulling latest Istio
export GITHUB_TOKEN=''

# Dashboard specs
##### Dashboard specs
export DASHBOARD_INSTALL_NS="default"

# Note that to receive webhooks, your github must be able to http POST to your Tekton installation.
Expand Down
2 changes: 1 addition & 1 deletion webhooks-extension/test/credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
DOCKERHUB_USERNAME=[your-dockerhub-id]
DOCKERHUB_PASSWORD=[your-docker-hub-password]
GITHUB_USERNAME=[your-github-login-id]
GITHUB_TOKEN=[github-token-with-wehooks-permissions]
GITHUB_TOKEN=[github-token-with-wehooks-permissions]
2 changes: 1 addition & 1 deletion webhooks-extension/test/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export test_dir="${tekton_repo_dir}/webhooks-extension/test"
source ${test_dir}/config.sh
source ${test_dir}/util.sh

install_istio ${KNATIVE_VERSION}
install_istio
install_knative_serving ${KNATIVE_VERSION}
install_knative_eventing ${KNATIVE_VERSION}
install_knative_eventing_sources ${KNATIVE_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion webhooks-extension/test/setup_webhook_simple_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [ ! -f $GOPATH/src/github.com/tektoncd/experimental/webhooks-extension/test/c
exit 1
fi
pushd $GOPATH/src/github.com/tektoncd/experimental/webhooks-extension/test
. ./credentials.sh
source credentials.sh

kubectl apply -f dashboard-service.yaml -n ${DASHBOARD_INSTALL_NS}

Expand Down

0 comments on commit 03eeb7c

Please sign in to comment.