This article completes a series of translation notes about OpenWhisk from the author Priti Desai. Today we will look at the process of deploying OpenWhisk on top of Kubernetes with corrected commands for performance with current versions of applications. It will also describe how to run OpenWhisk functions using Knative and TektonCD on Kubernetes using the Nodejs runtime.
Deploying OpenWhisk on Kubernetes
Over the course of a few days, I experimented with deploying OpenWhisk to Kubernetes to create a simple and fast testing ground. And since I'm new to Kubernetes, I guess a day and a half was spent on a successful deployment. IN This The repositories have very clear instructions for deploying OpenWhisk to Kubernetes. There will be instructions for deployment made for Mac (I will also do everything on Linux because I prefer Linux. - approx. translator).
Installing the package manager asdf, after which we automatically correct ~/.bash_profile or its equivalent like this:
[Again, skip this step on Linux. - approx. translator]
Install minikube and kubelet:
$ asdf install kubectl 1.9.0
$ asdf global kubectl 1.9.0
$ asdf install minikube 0.25.2
$ asdf global minikube 0.25.2
[specific versions are put, but I tested everything on the latest available versions for Linux; I suspect that you can safely put latest. - approx. translator]
$ wsk property set --apihost 192.168.99.100:31001
$ wsk property set --auth 23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP
We check:
$ wsk -i list
Entities in namespace: default
packages
actions
triggers
rules
Problems and solutions
getsockopt: connection refused
$ wsk -i list
error: Unable to obtain the list of entities for namespace 'default': Get http://192.168.99.100:31001/api/v1/namespaces/_/actions?limit=0&skip=0: dial tcp 192.168.99.100:31001: getsockopt: connection refused
Checking that containers are in namespace openwhisk in status Running, because sometimes it crashes CreateContainerConfigError.
Invoker still initializing - Init:1/2
The process of downloading various runtime environments can take a long time. To speed up, you can specify a reduced minimum list in the file mycluster.yaml:
whisk:
runtimes: "runtimes-minimal-travis.json"
named container -install-packages- throws in Error
Just increase the timeouts for liveness tests.
Installing OpenWhisk on top of Knative
Priti Desai installed on top of a cluster in the IBM cloud, as well as on a regular minikube using Knative Build and BuildTemplates. I will also install on top of minukube, based on how it was described in our blog earlier - using the latest versions of the software. Since Knative Build and BuildTemplates are officially deprecated, I will use the recommended replacement in the form of Tekton Pipelines. The rest of the article was written after reading the documentation for Tekton Pipelines, but based on the ideas of Priti. To work, you will need access to some Docker Registry - I, like the original author, will use DockerHub.
$ sed 's/${DOCKER_USERNAME}/'"$DOCKER_USERNAME"'/' -i taskrun.yaml
We apply:
$ kubectl apply -f taskrun.yaml
pipelineresource.tekton.dev/openwhisk-nodejs-runtime-git created
pipelineresource.tekton.dev/openwhisk-nodejs-helloworld-image created
taskrun.tekton.dev/openwhisk-nodejs-helloworld created
Checking the work is to get the name of the pod, view its status. You can also view the execution log of each step, for example:
$ kubectl get taskrun
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
openwhisk-nodejs-helloworld True Succeeded 5m15s 44s
$ kubectl get pod openwhisk-nodejs-helloworld-pod-4640d3
NAME READY STATUS RESTARTS AGE
openwhisk-nodejs-helloworld-pod-4640d3 0/6 Completed 0 5m20s
$ kubectl logs openwhisk-nodejs-helloworld-pod-4640d3 -c step-git-source-openwhisk-nodejs-runtime-git-r8vhr
{"level":"info","ts":1576532931.5880227,"logger":"fallback-logger","caller":"logging/config.go:69","msg":"Fetch GitHub commit ID from kodata failed: open /var/run/ko/refs/heads/master: no such file or directory"}
{"level":"info","ts":1576532936.538926,"logger":"fallback-logger","caller":"git/git.go:81","msg":"Successfully cloned https://github.com/apache/openwhisk-runtime-nodejs.git @ master in path /workspace/runtime-git"}
{"level":"warn","ts":1576532936.5395331,"logger":"fallback-logger","caller":"git/git.go:128","msg":"Unexpected error: creating symlink: symlink /tekton/home/.ssh /root/.ssh: file exists"}
{"level":"info","ts":1576532936.8202565,"logger":"fallback-logger","caller":"git/git.go:109","msg":"Successfully initialized and updated submodules in path /workspace/runtime-git"}
After execution, we will have an image in the Registry that can be deployed using the kn utility, designed to work with Knative services, for example:
kn service create nodejs-helloworld --image docker.io/${DOCKER_USERNAME}/openwhisk-nodejs-helloworld
Service 'nodejs-helloworld' successfully created in namespace 'default'.
Waiting for service 'nodejs-helloworld' to become ready ... OK
Service URL:
http://nodejs-helloworld.default.example.com
In the case of using Gloo, you can check the performance as follows: