From 7b88de9680fea5225f6e2664dd7a47fbacfbb3e6 Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Mon, 6 Aug 2018 15:40:57 +0100 Subject: [PATCH] Update dev instructions - add instructions for mounting config.json Signed-off-by: Alex Ellis --- docs/DEV.md | 34 +++++++++++++++++++++++----------- of-builder/README.md | 21 +++++++++++++++++++-- of-builder/deploy_swarm.sh | 2 -- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/docs/DEV.md b/docs/DEV.md index 07fcbb6c9..5629fb68e 100644 --- a/docs/DEV.md +++ b/docs/DEV.md @@ -51,9 +51,15 @@ Before you start you'll need to create a free GitHub app and select these OAuth - "Repository contents" read-only - "Commit statuses" read and write -Now select only the "push" event. +* Now select only the "push" event. -Now download the private key for your GitHub App which we will use later in the guide for allowing OpenFaaS Cloud to write to commit statuses when a build passes or fails. +* Where can this GitHub App be installed? + +Any account + +* Save the new app. + +* Now download the private key for your GitHub App which we will use later in the guide for allowing OpenFaaS Cloud to write to commit statuses when a build passes or fails. The GitHub app will deliver webhooks to your OpenFaaS Cloud instance every time code is pushed in a user's function repository. Make sure you provide the public URL for your OpenFaaS gateway to the GitHub app. Like: `http://my.openfaas.cloud/function/github-push` @@ -67,7 +73,7 @@ environment: The shared secret is used to securely verify each message came from GitHub and not a third party. -* Add github appId to `github.yml` +* Add the github appId to `github.yml` ```yaml environment: @@ -83,11 +89,14 @@ To enable this set `report_status: "true"` in `github.yml` before deploying the A private key must also be mounted as a Docker / Kubernetes secret so that the code can authenticate and update statuses. -* Find the .pem file from the GitHub App page +* Create GitHub App secret + +Download the .pem file from the GitHub App page, then save it as a file named `private-key` with no extension. Create Docker secret + ``` -docker secret create private-key .pem +docker secret create private-key private-key ``` * Update the remote gateway URL in `stack.yml` or set the `OPENFAAS_URL` environmental variable. @@ -101,16 +110,17 @@ provider: You will need to edit `stack.yml` and make sure `buildshiprun_limits_swarm.yml` is listed instead of `buildshiprun_limits_k8s.yml`. +On Swarm you also need to edit all other YAML files to remove the `.openfaas` DNS suffix. -* Deploy the registry and of-builder +* Deploy of-builder and of-buildkit -Using the instructions given in the repo deploy of-builder (buildkit as a HTTP service) and the registry +Deploy the image builder (of-builder and of-buildkit) using these [instructions](./of-builder). -https://github.com/openfaas/openfaas-cloud/tree/master/of-builder +Optionally deploy a registry locally, or mount your `~/.docker/config.json` file to access a remote registry. -* Build/deploy +* Build/deploy (optional) -> Before running this build/push/deploy script change the Docker Hub image prefix from `alexellis2/` to your own. +Before running this build/push/deploy script change the Docker Hub image prefix from `alexellis2/` to your own. ```sh $ faas-cli build --parallel=4 \ @@ -184,7 +194,9 @@ kubectl create secret generic private-key -n openfaas-fn --from-file=private-key Set application ID -* Update gateway_config.yml +* Update `gateway_config.yml` + +On Swarm you have to remove any suffixes found such as `.openfaas`. I.e. diff --git a/of-builder/README.md b/of-builder/README.md index 3db2a77ee..46bb47641 100644 --- a/of-builder/README.md +++ b/of-builder/README.md @@ -4,9 +4,26 @@ of-builder is an image builder for OpenFaaS images, it needs to be deployed with The following instructions are for Docker Swarm but OpenFaaS Cloud works well on Kubernetes. [Documentation for Kubernetes](https://github.com/openfaas/openfaas-cloud/blob/master/docs/DEV.md#appendix-for-kubernetes) -## Setup +> Before you start deploy OpenFaaS via https://docs.openfaas.com/ -Before you start deploy OpenFaaS via https://docs.openfaas.com/ +## Kubernetes + +For Kubernetes skip this section, it is documented in the developer guide with YAML files. + +## Installation-only (Swarm) + +For Docker Swarm run `./deploy_swarm.sh` + +If you are using a remote Docker registry then mount your `~/.docker/config.json` file into the of-builder service. You will also need to create that file on each node. Example: + +Assuming you are logged into your server as `root`: + +``` +docker service create --mount type=bind,src=/root/.docker/,dst=/home/app/.docker/ --detach=true \ + --network func_functions --name of-builder openfaas/of-builder:$OF_BUILDER_TAG +``` + +## For development (Swarm) ### Setup the registry diff --git a/of-builder/deploy_swarm.sh b/of-builder/deploy_swarm.sh index c5cd46f04..6db8e450a 100755 --- a/of-builder/deploy_swarm.sh +++ b/of-builder/deploy_swarm.sh @@ -14,5 +14,3 @@ export OF_BUILDER_TAG=0.4.2 docker service rm of-builder docker service create --detach=true --network func_functions --name of-builder openfaas/of-builder:$OF_BUILDER_TAG - -