目的
前回同様FaaSを自前環境に導入しお試し環境を用意していきたいと思います。
前回の失敗
前回は、CentOS Stream 9上にdocker-composeを用いて環境構築する方法を試しましたが、手順が悪かったせいかうまく最後まで辿り着きませんでした。今回は、docker-composeを用いずstandalone環境の実行手順を参考に自前環境へFaaSを導入してみたいと思います。
導入環境
GitHub上に「ou will need Docker, Java and Node.js available on your machine.」と記載があるため、あらかじめインストールをしておく。
- CentOS Stream9(Minimal Install)
- git、java-21-openjdk(→java-11-openjdk)、nodejs、docker(非podman)
- firewalld(stop)、SELinux(disable)
- make
$ sudo dnf install -y git
$ sudo dnf install -y java-21-openjdk
$ dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
$ sudo systemctl enable --now docker.service
$ git clone https://github.com/apache/openwhisk.git
$ cd openwhisk
$ ./gradlew core:standalone:bootRun
[openwhisk@localhost openwhisk]$ ./gradlew core:standalone:runBoot
〜省略〜
* What went wrong:
Could not compile settings file '/home/openwhisk/openwhisk/settings.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 65
java.lang.IllegalArgumentException: Unsupported class file major version 65
〜省略〜
$
Javaのバージョンの指定はどこに書いてあったのか?少しづつバージョンを下げていくと11でエラーが出なくなった。
$ sudo dnf install -y java-11-openjdk
$ ./gradlew core:standalone:bootRun
Build using Scala 2.12
Scala sub-project 'gatling_tests' doesn't have Scoverage applied and will be ignored in parent project aggregation
> Task :core:standalone:bootRun FAILED
____ ___ _ _ _ _ _
/\ \ / _ \ _ __ ___ _ __ | | | | |__ (_)___| | __
/\ /__\ \ | | | | '_ \ / _ \ '_ \| | | | '_ \| / __| |/ /
/ \____ \ / | |_| | |_) | __/ | | | |/\| | | | | \__ \ <
\ \ / \/ \___/| .__/ \___|_| |_|__/\__|_| |_|_|___/_|\_\
\___\/ tm |_|
Git Commit: 7ef091c, Build Date: 2025-01-21T22:47:24+0900
================================================================================
Running pre flight checks ...
docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied.
〜省略〜
良さそうなところまで進んだがdocker関連で通常ユーザには権限がないためエラーのような出力がされたので、少し調べてみる。openwhiskユーザをdockerグループに所属させることで解決できる様である。再ログインやdockerサービスの再起動を行うことで反映させるかと思いきや解消せず。何も考えずrebootするとその後反映されたようでエラーが発生せず起動に成功した模様である。
[openwhisk@localhost openwhisk]$ ./gradlew core:standalone:bootRun
〜省略〜
Running pre flight checks ...
Local Host Name: 172.17.0.1
Local Internal Name: 172.17.0.1
[ OK ] 'docker' cli found. (Docker version 27.5.1, build 9f9e405)
[ OK ] 'docker' version 27.5.1 is newer than minimum supported 18.3.0
[ OK ] 'docker' is running.
[FAILURE] 'wsk' cli not found.
Download the cli from https://s.apache.org/openwhisk-cli-download
[ OK ] Server port [3233] is free
================================================================================
〜省略〜
[2025-02-17T01:37:31.498Z] [WARN] Binding with a connection source not supported with HTTP/2. Falling back to HTTP/1.1.
================================================================================
Launched service details
[ 3233 ] http://172.17.0.1:3233 (Controller)
[ 3232 ] http://172.17.0.1:3232/playground (Playground)
Local working directory - /home/openwhisk/.openwhisk/standalone/server-3233
================================================================================
〜省略〜
[2025-02-17T01:37:32.053Z] [WARN] Failed to attach the instrumentation because the Kamon Bundle is not present on the classpath
〜省略〜
[2025-02-17T01:37:34.200Z] [WARN] Binding with a connection source not supported with HTTP/2. Falling back to HTTP/1.1.
〜省略〜
[2025-02-17T01:37:36.761Z] [WARN] [#tid_sid_playground] [PlaygroundLauncher] Failed to launch browser java.io.IOException: Cannot run program "xdg-open": error=2, そのようなファイルやディレクトリはありません
<============-> 97% EXECUTING [2m 6s]
> :core:standalone:bootRun
WARNINGが幾つかとFAILUREが1つある様なので、FAILUREだけ対応して再実行してみる。
$ curl -LO https://github.com/apache/openwhisk-cli/releases/download/1.2.0/OpenWhisk_CLI-1.2.0-linux-amd64.tgz
$ sudo tar -xvzf OpenWhisk_CLI-1.2.0-linux-amd64.tgz -C /usr/local/bin/ wsk
動作確認
$ curl http://172.17.0.1:3233 | jq
〜省略〜
{
"api_paths": [
"/api/v1"
],
"description": "OpenWhisk",
〜省略〜
"runtimes": {
"rust": [
〜省略〜
"nodejs": [
〜省略〜
"java": [
〜省略〜
"go": [
〜省略〜
"php": [
〜省略〜
"python": [
〜省略〜
"dotnet": [
〜省略〜
"ruby": [
〜省略〜
"swift": [
〜省略〜
$ curl http://172.17.0.1:3232/playground/
{"code":"BFLPn6x3uSUtP8nW9ySwmkOLrKDm1dTl","error":"The requested resource could not be found."}
playgroundの方は、errorと出力されていますが何やらレスポンスを返す様にはできたみたいです。次回以降は、ブラウザやWeb APIを用い実行や操作していきたいと思います。