| commit | 7930a5cb4c94f3fd7283865c594414db534f3986 | [log] [tgz] |
|---|---|---|
| author | Jim Crossley <jim@crossleys.org> | Fri Apr 13 08:56:48 2018 -0400 |
| committer | Jim Crossley <jim@crossleys.org> | Fri Apr 13 08:56:48 2018 -0400 |
| tree | 42966bd155733c634109c7c65287ed95d6fe36b3 | |
| parent | 2c5b43a58222be5557dfcd5e2a2f902d74b86c10 [diff] |
Pick up centos-based controller invoker [OCF-39] This completes all of the porting of upstream images to RHT-supported ones
This repository contains the necessary templates and compatible docker images for deploying OpenWhisk on OpenShift.
wskminishiftThe following command will deploy OpenWhisk in your OpenShift project using the latest ephemeral template in this repo:
oc process -f https://git.io/openwhisk-template | oc create -f -
The shortened URL redirects to https://raw.githubusercontent.com/projectodd/openwhisk-openshift/master/template.yml
This will take a few minutes. Verify that all pods eventually enter the Running or Completed state. For convenience, use the watch command.
watch oc get all
The system is ready when the controller recognizes the invoker as healthy:
oc logs -f controller-0 | grep "invoker status changed"
You should see a message like invoker status changed to 0 -> Healthy
wskOnce your cluster is ready, you need to configure your wsk binary. If necessary, download a recent one from https://github.com/apache/incubator-openwhisk-cli/releases/, ensure it's in your PATH, and:
AUTH_SECRET=$(oc get secret whisk.auth -o yaml | grep "system:" | awk '{print $2}' | base64 --decode)
wsk property set --auth $AUTH_SECRET --apihost $(oc get route/openwhisk --template="{{.spec.host}}")
That configures wsk to use your OpenWhisk. Use the -i option to avoid the validation error triggered by the self-signed cert in the nginx service.
wsk -i list wsk -i action invoke /whisk.system/utils/echo -p message hello -b
If either fails, ensure you have the latest wsk installed.
The alarms package is not technically a part of the default OpenWhisk catalog, but since it's a simple way of experimenting with triggers and rules, we include a resource specification for it in our templates.
Try the following wsk commands:
wsk -i trigger create every-5-seconds \
--feed /whisk.system/alarms/alarm \
--param cron '*/5 * * * * *' \
--param maxTriggers 25 \
--param trigger_payload "{\"name\":\"Odin\",\"place\":\"Asgard\"}"
wsk -i rule create \
invoke-periodically \
every-5-seconds \
/whisk.system/samples/greeting
wsk -i activation poll
First, start minishift and fix a networking bug in current releases:
minishift start --memory 8GB minishift ssh -- sudo ip link set docker0 promisc on
Put your oc command in your PATH:
eval $(minishift oc-env)
Assuming you have this repo cloned to your local workspace, run:
./tools/travis/build.sh
That will create an openwhisk project, install the resources from template.yml into it, and wait for all components to be ready. When it completes, you should have a functioning OpenWhisk platform, to which you can then point your wsk command.
If you prefer not to clone this repo, you can simply follow the installation steps after creating a new project:
oc new-project openwhisk oc process -f https://git.io/openwhisk-template | oc create -f -
If you‘d like to test local changes you make to upstream OpenWhisk, e.g. the controller or invoker, first ensure you’re using minishift's docker repo:
eval $(minishift docker-env)
Then when you build the OW images, override the prefix and tag:
./gradlew distDocker -PdockerImagePrefix=projectodd -PdockerImageTag=whatever
The projectodd prefix and whatever tag can be anything you like. You'll patch the running StatefulSets to refer to them so that any new pods they create will use your images.
# Patch the controller's StatefulSet
oc patch statefulset controller -p '{"spec":{"template":{"spec":{"containers":[{"name":"controller","image":"projectodd/controller:whatever"}]}}}}'
# Patch the invoker's StatefulSet
oc patch statefulset invoker -p '{"spec":{"template":{"spec":{"containers":[{"name":"invoker","image":"projectodd/invoker:whatever"}]}}}}'
# Now delete one or both pods to run your latest images
oc delete --force --now pod invoker-0 controller-0
With the StatefulSets patched, your build-test-debug cycle amounts to this: edit the source, run your distDocker task, e.g. core:controller:distDocker or core:invoker:distDocker with the above prefix/tag, and finally delete the relevant pod, e.g. controller-0 or invoker-0. This will trigger your patched StatefulSet to create a new pod with your changes.
Allow some time for the components to cleanly shutdown and rediscover themselves, of course. And while you're waiting, consider coming up with some good unit tests instead. ;)
And if you wish to publish your changes to DockerHub's projectodd organization:
COMMIT=$(git rev-parse HEAD | cut -c 1-7) ./gradlew distDocker -PdockerImagePrefix=projectodd -PdockerImageTag=$COMMIT -PdockerRegistry=docker.io
All of the OpenWhisk resources can be shutdown gracefully using the template. The -f parameter takes either a local file or a remote URL.
oc process -f template.yml | oc delete -f - oc delete all -l template=openwhisk
Alternatively, you can just delete the project:
oc delete project openwhisk
If you‘d like for data to survive reboots, there’s a persistent-template.yml that will setup PersistentVolumeClaims.
There are some sensible defaults for larger persistent clusters in larger.env that you can use like so:
oc process -f persistent-template.yml --param-file=larger.env | oc create -f -
Adjust the connection count and test duration of both below as needed. On a large system, be sure to test with connection counts in the hundreds.
abFor simple testing, use ab:
ab -c 5 -n 300 -k -m POST -H "Authorization: Basic $(oc get secret whisk.auth -o yaml | grep "system:" | awk '{print $2}')" "https://$(oc get route/openwhisk --template={{.spec.host}})/api/v1/namespaces/whisk.system/actions/utils/echo?blocking=true&result=true"
wrkYou can generate in-cluster load with wrk
echo -e "function main() {\n return {body: 'Hello world'};\n}" > helloWeb.js
wsk -i action create helloWeb helloWeb.js --web=true
oc run -it --image williamyeh/wrk wrk --restart=Never --rm --overrides='{"apiVersion":"v1", "spec":{"volumes":[{"name": "data", "emptyDir": {}}], "containers":[{"name": "wrk", "image": "williamyeh/wrk", "args": ["--threads", "4", "--connections", "50", "--duration", "30s", "--latency", "--timeout", "10s", "http://nginx/api/v1/web/whisk.system/default/helloWeb"], "volumeMounts": [{"mountPath": "/data", "name": "data"}]}]}}'
The bin/activationStats.sh script can output throughput and waitTime numbers for recent function activations. This is useful when spot-checking overall system load and how long functions are waiting in queues inside OpenWhisk before being invoked.
You can inspect the catalog of actions by calling wsk action list. It might happen that after installing OpenWhisk there is only a single action:
$ wsk action list actions /whisk.system/invokerHealthTestAction0 private
If that happens, chances are that the default action catalog was not installed properly. This could be due to the installation process being slow, e.g.
$ oc get job NAME DESIRED SUCCESSFUL AGE install-catalog 1 0 1d preload-openwhisk-runtimes 1 1 1d
To get back the catalog, delete and execute the job again. This can be done by extracting the install-catalog definition into a separate file and executing it again:
$ oc delete job install-catalog job "install-catalog" deleted $ oc create -f install-catalog.yml job "install-catalog" created $ oc get pods NAME READY STATUS RESTARTS AGE ... install-catalog-gj7r6 0/1 Completed 0 30s
Finally, retrieve the action list again:
$ wsk action list actions /whisk.system/samples/greeting private nodejs:6 /whisk.system/watson-speechToText/speechToText private nodejs:6 /whisk.system/weather/forecast private nodejs:6 /whisk.system/watson-textToSpeech/textToSpeech private nodejs:6 ...
The requested resource does not exist when creating an actionIt might happen that when creating an action you get an error that the requested resource does not exist:
$ wsk -i action create md5hasher target/maven-java.jar --main org.apache.openwhisk.example.maven.App error: Unable to create action 'md5hasher': The requested resource does not exist. (code 619)
If this happens, it could be that the API host is incorrect. So, start by inspecting the property values:
$ wsk property get client cert Client key whisk auth 789c46b1-... whisk API host http://openwhisk-openwhisk.192.168.64.8.nip.io whisk API version v1 whisk namespace _ whisk CLI version 2018-02-28T21:13:48.864+0000 whisk API build 2018-01-01T00:00:00Z whisk API build number latest
API host should only contain the host name, no http:// in front. Fix it by resetting the API host:
$ wsk property set --apihost openwhisk-openwhisk.192.168.64.8.nip.io ok: whisk API host set to openwhisk-openwhisk.192.168.64.8.nip.io
Now try adding the action again:
$ wsk -i action create md5hasher target/maven-java.jar --main org.apache.openwhisk.example.maven.App ok: created action md5hasher