0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Apache OpenWhiskをdocker-composeで起動させる(結論上手くいかず)

Posted at

目的

FaaSをLinuxに導入して仕組みや簡単な動作検証を行う環境を作ってみたいと思います。

結論

色々と試しましたが、結局今回の手順ではうまく環境を構築するに至りませんでした。

導入先OS

CentOS Stream 9上に導入しようと思います。

# cat /etc/redhat-release 
CentOS Stream release 9
# uname -a
Linux localhost.localdomain 5.14.0-319.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 25 19:53:58 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

必要なパッケージ

  • make
  • npm
  • lsof
  • docker
  • docker-compose
  • rsync

Apache OpenWhiskの導入開始

以下のURLを参考に動かしてみようと思います。
https://github.com/apache/openwhisk-devtools/blob/master/docker-compose/README.md
まずは、作業用のユーザを適当に作成します。

# useradd openwhisk
# passwd openwhisk
# visudo
# su - openwhisk

GitHubリポジトリからリソースをクローンします。

[openwhisk@localhost ~]$ git clone https://github.com/apache/openwhisk-devtools.git
-bash: git: コマンドが見つかりません
[openwhisk@localhost ~]$ 

CentOS 9を最小構成でインストールしていたので、gitパッケージが導入されていませんでした。インストールしていきます。

[openwhisk@localhost ~]$ sudo dnf install -y git
[openwhisk@localhost ~]$ git clone https://github.com/apache/openwhisk-devtools.git
[openwhisk@localhost ~]$ cd openwhisk-devtools/docker-compose/
[openwhisk@localhost docker-compose]$ make quick-start
-bash: make: コマンドが見つかりません
[openwhisk@localhost docker-compose]$ 

今度はmakeコマンドがありませんでした。インストールしていきます。この後、docker、lsof、docker-composeコマンドも不足していため合わせてインストールしていきます。

[openwhisk@localhost docker-compose]$ sudo dnf install -y docker lsof docker-compose
引数に一致する結果がありません: docker-compose
エラー: 一致するものが見つかりません: docker-compose
[openwhisk@localhost docker-compose]$ 

docker-composeだけ既存のリポジトリからインストールできなかったので、別の方法を探してインストールしてみます。

bash

[openwhisk@localhost docker-compose]$ sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[openwhisk@localhost docker-compose]$ sudo chmod +x /usr/local/bin/docker-compose
[openwhisk@localhost docker-compose]$ docker-compose version
Docker Compose version v2.33.0
[openwhisk@localhost docker-compose]$ 

無事docker-composeがインストールできたので再度quick-startを実行してみます。

[openwhisk@localhost docker-compose]$ make quick-start
〜省略〜
host ip address: localhost
checking required ports ... 
 ... OK
  ... preparing api-gateway configuration
pinging minio...
.WARN[0000] /home/openwhisk/openwhisk-devtools/docker-compose/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion 
unable to get image 'minio/minio:RELEASE.2018-07-13T00-09-07Z': Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
........

Docker daemonが起動していないことと、minioのイメージが取得できないと出力されている様に見えるので個別に対応していきます。dockerはパッケージのみインストールされており、サービスとして登録や起動を実施していない様なので進めていきます。

[openwhisk@localhost docker-compose]$ sudo systemctl status docker.service
Unit docker.service could not be found.
[openwhisk@localhost docker-compose]$ which docker
/usr/bin/docker
[openwhisk@localhost docker-compose]$ docker version
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
WARN[0000] The cgroupv2 manager is set to systemd but there is no systemd user session available 
WARN[0000] For using systemd, you may need to log in using a user session 
WARN[0000] Alternatively, you can enable lingering with: `loginctl enable-linger 1000` (possibly as root) 
WARN[0000] Falling back to --cgroup-manager=cgroupfs    
Client:       Podman Engine
Version:      5.3.2
API Version:  5.3.2
Go Version:   go1.23.4 (Red Hat 1.23.4-1.el9)
Built:        Tue Feb  4 22:21:22 2025
OS/Arch:      linux/amd64
[openwhisk@localhost docker-compose]$ sudo systemctl enable --now docker
Failed to enable unit: Unit file docker.service does not exist.

dockerサービスがインストールされたと思っていたのですが、よく見るとpodmanが導入されていました。そのためもちろんdocker.serviceもインストールされていませんでした。一度podmanを取り除き、dockerをインストールしてみようと思います。

[openwhisk@localhost docker-compose]$ sudo sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
[openwhisk@localhost docker-compose]$ sudo dnf -y install dnf-plugins-core
[openwhisk@localhost docker-compose]$ sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[openwhisk@localhost docker-compose]$ sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
[openwhisk@localhost docker-compose]$ docker version
Client: Docker Engine - Community
 Version:           27.5.1
 API version:       1.47
 Go version:        go1.22.11
 Git commit:        9f9e405
 Built:             Wed Jan 22 13:42:47 2025
 OS/Arch:           linux/amd64
 Context:           default
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[openwhisk@localhost docker-compose]$ sudo systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[openwhisk@localhost docker-compose]$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled)
     Active: active (running) since Sat 2025-02-15 22:45:33 JST; 5s ago

無事にdockerサービスを起動できた様です。それではmake quick-startをまた実行していきます。

どうやら通常ユーザではダメな様です。また、他にも足りていないコマンドがある様なのでさらに追加していきます。
```bash
[openwhisk@localhost docker-compose]$ sudo dnf install -y net-tools
[openwhisk@localhost docker-compose]$ sudo make quick-start
〜省略〜
Digest: sha256:43d965c99cc94d9ee0690f9bbc4f95d774facf97ee2544044ebdbde05fde9b67
Status: Downloaded newer image for openwhisk/invoker:nightly
docker.io/openwhisk/invoker:nightly
host ip address: 192.168.11.55
checking required ports ... 
 ... OK
cat: /root/tmp/openwhisk/local.env: そのようなファイルやディレクトリはありません
cat: /root/tmp/openwhisk/local.env: そのようなファイルやディレクトリはありません
cat: /root/tmp/openwhisk/local.env: そのようなファイルやディレクトリはありません
cat: /root/tmp/openwhisk/local.env: そのようなファイルやディレクトリはありません
cat: /root/tmp/openwhisk/local.env: そのようなファイルやディレクトリはありません
  ... preparing api-gateway configuration
/bin/bash: 行 1: docker-compose: コマンドが見つかりません
pinging minio...
.......
[openwhisk@localhost docker-compose]$ 

sudoを実行した際に/usr/local/binがPATHに含まれていないので見つからないと思うので、実行時に設定して実行する。

[openwhisk@localhost docker-compose]$ sudo PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin make quick-start
〜省略〜
apigateway-1       | 2025/02/15 14:07:11 Executing sync cmd: rclone sync minio:api-gateway /etc/api-gateway/
apigateway-1       | nginx: the configuration file /etc/api-gateway/api-gateway.conf syntax is ok
apigateway-1       | nginx: configuration file /etc/api-gateway/api-gateway.conf test is successful
 ... OK: all containers up!
waiting for the database to come up ... on 192.168.11.55
apigateway-1       | 2025/02/15 14:07:11 done
.kafka-rest-1       | library initialization failed - unable to allocate file descriptor table - out of memoryAborted (core dumped)
kafka-1            | library initialization failed - unable to allocate file descriptor table - out of memory
.apigateway-1       | 2025/02/15 14:07:21 Executing sync cmd: rclone sync minio:api-gateway /etc/api-gateway/
apigateway-1       | 2025/02/15 14:07:21 Executing Reload Cmd
apigateway-1       | 2025/02/15 14:07:21 Executing sync cmd: api-gateway -s reload
apigateway-1       | Error waiting for Cmd exit status 1
〜省略〜

今までの中で一番進んだ様だが、エラー出力を見るとメモリ不足の様にも見えるが8GB中4GB程度しか使われていないので直接的なメモリ不足なのかわからない。ファイルディスクリプタ数不足の可能性も考えられるので増やしてみます。ファイルの最後に以下4行を追加します。

[openwhisk@localhost ~]$ sudo vi /etc/security/limits.conf

* soft nofile 65536
* hard nofile 65536
root soft nofile 65536
root hard nofile 65536

結局上の設定を入れてもダメでした。結局docker-compose.ymlの必要なサービスに以下定義を追加することで解消しました。

ulimits:
      nofile:
        soft: 1048576  # ソフトリミット(推奨最大)
        hard: 1048576  # ハードリミット(絶対最大)

再度make quick-startを実行すると進んでいる様に見えますが、またパッケージ不足エラーです。rsyncがありません。

db-1               | [info] 2025-02-15T14:31:22.133808Z nonode@nohost <0.9.0> -------- Application snappy started on node nonode@nohost
db-1               | [notice] 2025-02-15T14:31:22.729683Z nonode@nohost <0.314.0> f506348418 192.168.11.55:5984 192.168.11.55 undefined HEAD /_all_dbs 200 ok 43
initializing the database ... on 192.168.11.55
/bin/bash: 行 1: rsync: コマンドが見つかりません
make: *** [Makefile:354: init-couchdb] エラー 127
[openwhisk@localhost docker-compose]$ apigateway-1       | 2025/02/15 14:31:26 Executing sync cmd: rclone sync minio:api-gateway /etc/api-gateway/
apigateway-1       | 2025/02/15 14:31:27 done

docker-composeで起動後に停止しているコンテナは4つある様です。

[openwhisk@localhost ~]$ sudo docker ps -a|grep Exit
39cb2c8a8205   openwhisk/invoker:nightly                  "/bin/sh -c 'exec /i…"   6 minutes ago   Exited (1) About a minute ago                                                                                                                                                                                openwhisk-invoker-1
8860d9b63a14   openwhisk/controller:nightly               "/bin/sh -c 'exec /i…"   6 minutes ago   Exited (1) About a minute ago                                                                                                                                                                                openwhisk-controller-1
5a2d5240ac7c   confluentinc/cp-kafka-rest:3.3.1           "/etc/confluent/dock…"   6 minutes ago   Exited (1) About a minute ago                                                                                                                                                                                openwhisk-kafka-rest-1
dbbc26c82d52   wurstmeister/kafka:0.11.0.1                "start-kafka.sh"          6 minutes ago   Exited (1) About a minute ago                                                                                                                                                                                openwhisk-kafka-1
[openwhisk@localhost ~]$ 

openwhisk-kafka-1は、「client version 1.23 is too old」と出力されているので、おそらく指定しているイメージが古く、内容パッケージが古いためエラーが発生していると推測します。

[openwhisk@localhost ~]$ sudo docker logs openwhisk-kafka-1 | grep -A 10 -i error
Error response from daemon: {"message":"client version 1.23 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}
java.lang.IllegalArgumentException: Error creating broker listeners from 'PLAINTEXT://kafka:': Unable to parse PLAINTEXT://kafka: to a broker endpoint
	at kafka.utils.CoreUtils$.listenerListToEndPoints(CoreUtils.scala:274)
	at kafka.server.KafkaConfig.getAdvertisedListeners(KafkaConfig.scala:1115)
	at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1075)
	at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:867)
	at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:864)
	at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:28)
	at kafka.Kafka$.main(Kafka.scala:58)
	at kafka.Kafka.main(Kafka.scala)
Caused by: kafka.common.KafkaException: Unable to parse PLAINTEXT://kafka: to a broker endpoint
	at kafka.cluster.EndPoint$.createEndPoint(EndPoint.scala:57)
Error response from daemon: {"message":"client version 1.23 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}
--
java.lang.IllegalArgumentException: Error creating broker listeners from 'PLAINTEXT://kafka:': Unable to parse PLAINTEXT://kafka: to a broker endpoint
	at kafka.utils.CoreUtils$.listenerListToEndPoints(CoreUtils.scala:274)
	at kafka.server.KafkaConfig.getAdvertisedListeners(KafkaConfig.scala:1115)
	at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1075)
	at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:867)
	at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:864)
	at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:28)
	at kafka.Kafka$.main(Kafka.scala:58)
	at kafka.Kafka.main(Kafka.scala)
Caused by: kafka.common.KafkaException: Unable to parse PLAINTEXT://kafka: to a broker endpoint
	at kafka.cluster.EndPoint$.createEndPoint(EndPoint.scala:57)
[openwhisk@localhost ~]$ 

結果

ということで、なかなか先が長そうなので、今回は導入失敗でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?