LoginSignup
2
0

More than 5 years have passed since last update.

入門 Kubernetes の手順通りに進めても Ghost のデプロイが上手く行かない件

Posted at

入門 Kubernetes (原題: Kubernetes: Up & Running) の 14 章「実用的なアプリケーションのデプロイ」という章の「14.2 Ghost」にある Ghost のデプロイ手順をそのままやってみたのですが、動きませんでした。

Pod のエラーログを追っているうちにいくつかの問題が見つかったので、修正して本家のリポジトリに Pull Request を出しています。

が、最近のリポジトリの動きをみてる限りでは取り入れてもらえるか微妙な感じなので、この記事を書くことにしました。

前提となるバージョン

大前提として minikube で動かしています。
kubectlminikube も、この記事を書いている 2018/04/08 時点でだいたい最新だと思います。

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-27T00:14:31Z", GoVersion:"go1.9.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"", Minor:"", GitVersion:"v1.9.4", GitCommit:"bee2d1505c4fe820744d26d41ecd3fdd4a3d6546", GitTreeState:"clean", BuildDate:"2018-03-21T21:48:36Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"linux/amd64"}

$ minikube version
minikube version: v0.25.2

また、この書籍の手順上、Ghost の最新の Docker image が参照されていますが、これは 2018/04/08 時点で 1.22.1 でした。

修正内容

上記の Pull Request を参照してください。

Ghost の config ファイルのパスを修正

これは書籍のミスなのですが、元の config ファイルは書籍上では以下のように ConfigMap として登録しています。

$ kubectl create cm --from-file ghost-config.js ghost-config

ghost-config.js というファイル名で登録しているので、これをファイルシステム上にマウントした場合は同じ名前で参照する必要があります。

diff --git a/14-4-ghost.yaml b/14-4-ghost.yaml
index 6e534ce..15c297f 100644
--- a/14-4-ghost.yaml
+++ b/14-4-ghost.yaml
@@ -18,7 +18,7 @@ spec:
         command:
         - sh
         - -c
-        - cp /ghost-config/config.js /var/lib/ghost/config.js
+        - cp /ghost-config/ghost-config.js /var/lib/ghost/config.js
           && /entrypoint.sh npm start
         volumeMounts:
         - mountPath: /ghost-config

最新の Ghost の Docker image に合わせた修正

これはおそらく原著が出て以降のどこかで Dockerfile の定義が変わったようです。

diff --git a/14-4-ghost.yaml b/14-4-ghost.yaml
index 15c297f..f553ac0 100644
--- a/14-4-ghost.yaml
+++ b/14-4-ghost.yaml
@@ -19,7 +19,7 @@ spec:
         - sh
         - -c
         - cp /ghost-config/ghost-config.js /var/lib/ghost/config.js
-          && /entrypoint.sh npm start
+          && docker-entrypoint.sh node current/index.js
         volumeMounts:
         - mountPath: /ghost-config
           name: config

それでもエラーが出たら

今後も Ghost 側の変更等の影響で動かなくなる可能性はあると思います。
その場合はやはり Kubernetes の Pod のエラーログを見ると良いでしょう。

今回の場合は Kubernets のダッシュボードからログを参照したところ、以下のようなエラーが出ていました。

cp: cannot stat '/ghost-config/config.js': No such file or directory
2
0
2

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
2
0