Skip to content

Instantly share code, notes, and snippets.

@bbrowning
Last active August 22, 2018 15:59
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bbrowning/713ed5355324c1a65ad37dded503c4c1 to your computer and use it in GitHub Desktop.
Save bbrowning/713ed5355324c1a65ad37dded503c4c1 to your computer and use it in GitHub Desktop.
Running Apache OpenWhisk on OpenShift

Running Apache OpenWhisk on OpenShift

Prerequisites

These instructions assume you are using Minishift 1.0.1 or newer as your OpenShift installation.

You'll also need a wsk binary in your $PATH to interact with OpenWhisk after it's deployed. Download the latest version for your OS from https://github.com/apache/incubator-openwhisk-cli/releases/

Instructions

First, start minishift and fix a networking bug in current releases:

minishift start
minishift ssh -- sudo ip link set docker0 promisc on
eval $(minishift oc-env)

Then, deploy OpenWhisk:

oc new-project openwhisk
oc create -f https://raw.githubusercontent.com/projectodd/incubator-openwhisk-deploy-kube/simplify-deployment-openshift/configure/openwhisk_openshift.yml
watch "oc get all"

Make sure all pods enter the Running state before moving on. If not, something is broken and start troubleshooting by looking in the logs of the failing pods.

The install-openwhisk-catalog-xxxxx and preload-openwhisk-runtimes-xxxxx pods should transition from Running to Completed as they finish installing the default OpenWhisk catalog of packages and pulling the default OpenWhisk runtime container images.

Then, wait until the controller recognizes the invoker as healthy:

oc logs -f $(oc get pods | grep controller | awk '{print $1}') | grep "invoker status changed"

You're looking for a message like invoker status changed to invoker0: Healthy. Once you see that message, OpenWhisk is running and you need to configure the client authentication to your controller:

export AUTH_SECRET=$(oc get configmap openwhisk-config -o yaml | grep 'AUTH_WHISK_SYSTEM=' | awk -F '=' '{print $2}')
export API_HOST=http://$(oc get route/controller --template={{.spec.host}})
wsk property set --auth $AUTH_SECRET --apihost $API_HOST

Finally, you're ready to test actions:

wsk list
wsk action invoke /whisk.system/utils/echo -p message hello -b

Now you can follow along with the OpenWhisk docs on creating actions.

@cescoffier
Copy link

Thank you so much for these instructions!

What about switching to another project / namespace ?

oc new-project openwhisk

The watch command should be watch "oc get all" (it may come from my system - Mac OS X + ZSH)
About the jobs, while the pod state is going to be completed, the job state is "successful". Maybe it should be mentioned:

> oc get jobs
NAME                              DESIRED   SUCCESSFUL   AGE
jobs/install-openwhisk-catalog    1         1            6m
jobs/preload-openwhisk-runtimes   1         1            6m

I wonder if there is a better wait to wait for the invoker healthy-ness.

Anyway, working like a charm for me!

@bbrowning
Copy link
Author

Thanks for the feedback! You should be able to deploy this to any project / namespace you'd like, but I didn't want to imply that a specific namespace of openwhisk was required. And, you're right about looking at jobs instead of pods is a more reliable way and I'll think about a better way to know when the invoker is actually up.

Good to know it worked!

@gastaldi
Copy link

I got some errors like

[2017-06-19T21:40:09.572Z] [ERROR] [??] [KafkaProducerConnector] sending message on topic 'health' failed: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms. �
[2017-06-19T21:40:09.572Z] [ERROR] [??] [Invoker] failed to ping the controller: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms. �

while starting up, but they were all solved when I restarted minishift.

The oc new-project openwhisk also was essential to avoid errors like

Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create serviceaccounts in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create rolebindings in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create configmaps in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create extensions.deployments in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create services in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create extensions.deployments in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create services in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create extensions.deployments in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create services in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create configmaps in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create extensions.deployments in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create services in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create routes in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create configmaps in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create apps.statefulsets in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create services in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create batch.jobs in project "default"
Error from server (Forbidden): error when creating "openwhisk_openshift.yml": User "system" cannot create batch.jobs in project "default"

@mattf
Copy link

mattf commented Jul 10, 2017

@gastaldi that's probably an issue where kafka hasn't started cleanly. check it's log. in my first attempt zookeeper came up after kafka and kafka stopped, but the pod didn't. you can manually delete the kafka pod to get it to restart and discover zookeeper. i then found i needed to manually delete the invoker pod as well.

@szinck1
Copy link

szinck1 commented Sep 8, 2017

@bbrowning

Thanks for putting these instructions together, but it looks like projectodd has gotten rid of the openshift specific yml?

c:\>oc create -f https://raw.githubusercontent.com/projectodd/incubator-openwhis k-deploy-kube/simplify-deployment-openshift/configure/openwhisk_openshift.yml error: unable to read URL "https://raw.githubusercontent.com/projectodd/incubato r-openwhisk-deploy-kube/simplify-deployment-openshift/configure/openwhisk_opensh ift.yml", server reported 404 Not Found, status code=404

@dyindude
Copy link

Looks like projectodd moved this into a branch:
https://github.com/projectodd/incubator-openwhisk-deploy-kube/tree/simplify-deployment-openshift/resources

Something like this should get you started:

$ git clone https://github.com/projectodd/incubator-openwhisk-deploy-kube.git
$ cd incubator-openwhisk-deploy-kube/
$ git pull origin simplify-deployment-openshift
$ git checkout simplify-deployment-openshift
$ cd resources
$ oc create -f openshift/ -f k8s/

@magick93
Copy link

magick93 commented Feb 7, 2018

Hello Ben

What is the best place to follow for updates on developments on OpenWhisk on OpenShift?

@pfuetz
Copy link

pfuetz commented Mar 8, 2018

It even again changed, it's now:

git clone https://github.com/projectodd/incubator-openwhisk-deploy-kube.git
cd incubator-openwhisk-deploy-kube/
git pull origin simplify-deployment-openshift
git checkout simplify-deployment-openshift
oc create -f openshift/ -f kubernetes/

@pfuetz
Copy link

pfuetz commented Mar 8, 2018

@MohamedElso
Copy link

Helllo,
i have this issue while i am deploying the project any suggestions?

Back-off pulling image "ip is here:5000/openwhiskpoc/action-nodejs-6@sha256:bd3176824ead9191cbdd4b87ab2ec594c14f9b86cf37f7bab4d254a19792ef1

Failed to pull image "ip is here:5000/openwhiskpoc/action-nodejs-6@sha256:bd3176824ead9191cbdd4b87ab2ec594c14f9b86cf37f7bab4d254a19792ef16": rpc error: code = 2 desc = error parsing HTTP 404 response body: json: cannot unmarshal number 26127387204478855749579231745064946906907528528017493594637314555907791619576171082385394356139169755107133986033749473388559359577965310236560793842159672352998188275733121329782977925539432178979272640459280859543041674529812834306640225314670576908231309421139564022006283384566200877614403769736240219800704419296356645172000983359470201919082469532030168768547885052410857206563020118476060577598701564392773871103296920341043357522881165179972992633580357026796423084574537495002909781564206812286457301786760873597074845531321156438191111716172772245757406247360161871964480950056880533135625953557884008555797 into Go struct field Error.detail of type float64: "{"errors":[{"code":"MANIFEST_UNKNOWN","message":"manifest unknown","detail":{"… See All2 times in the last 6 minutes

4:14:31 PM | Normal | Pulling | pulling image "ip is here:5000/openwhiskpoc/action-nodejs-6@sha256:bd3176824ead9191cbdd4b87ab2ec594c14f9b86cf37f7bab4d254a19792ef16"

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment