1
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?

More than 3 years have passed since last update.

OCI上で、Istioのサンプル(Bookinfo)を動かす→動いてません

Posted at

はじめに

どーも、のぶこふです。

前回は、OCI上にIstioの環境構築を行ったので、今回はサンプルのBookinfoを動かしてみようとおもいます。

前回記事 | OCI(Always Free)上に、サービスメッシュ(Istio)の動作環境をまるっと一式構築する

結果、うまく動かせていないことをご了承ください。
「いや、ここを、こうすれば、出来るじゃん!」と、踏み台になるなら・・・と思い、記事は残しておこうと思います。

やるよ

本編の内容はこちらを和訳。
Istio/Bookinfo

実施環境については、前回の記事を参照してください。

Minikubeの起動

configは、すでに設定されているものとします。

minikube start --kubernetes-version=v1.22.0 --nodes 3

Istioの起動

前回記事では、istioctlへのPathが通っていなかったので、~/.bashrcあたりにistio/binのPathを指定して、source ~/.bashrcを実行してください。

ターミナルを2つ起動しておき、Istioctl installを実行していきます。

terminal-1
istioctl install --set hub=docker.io/querycapistio --set profile=demo -y

下記メッセージが出たら、Terminal-2で操作します。

Processing resources for Egress gateways, Ingress gateways. Waiting for Deployment/istio-system/istio-egressgateway, Deployment/istio-...

ターミナル2で、下記コマンドを実行します。

terminal-2
kubectl scale deployment --replicas=0 istio-ingressgateway -n istio-system
kubectl scale deployment --replicas=0 istio-egressgateway -n istio-system

すると、ターミナル1で実行していたistioctl installが終了します。
そのままターミナル1で、Deploymentを修正します(arm64の追記)。

kubectl edit deployment istio-ingressgateway -n istio-system
kubectl edit deployment istio-egressgateway -n istio-system
# 変更内容は両方とも同じ
---
matchExpressions:
  - key: kubernetes.io/arch
    operator: In
      values:
+       - arm64 
        - amd64
---
nodeSelectorTerms:
  - matchExpressions:
    - key: kubernetes.io/arch
      operator: In
        values:
+         - arm64 
          - amd64

(参考)viで操作するなら・・・

ファイル末尾まで移動:Shift + g
検索          :?
amdの文字列     :amd → Enter
行コピー         :yy
貼り付け         :p
編集モード        :i
amdをarmに変更
編集モード終了     :esc

修正したDeploymentを反映させます。

terminal-1
kubectl scale deployment --replicas=1 istio-ingressgateway -n istio-system
kubectl scale deployment --replicas=1 istio-egressgateway -n istio-system

Sampleの実行

ローカルの情報をMinikubeに引き継ぎます

eval $(minikube docker-env)

Istioをインストールした時に、Sampleも含まれているので、ディレクトリ移動します

# xxxは適宜読み替えてください
cd xxx/istio-1.12.2/samples/bookinfo
# ns=default で Istio が使えるようにします
kubectl label namespace default istio-injection=enabled
# アプリケーションをデプロイします
kubectl apply -f platform/kube/bookinfo.yaml

・・・うまくいきません。
ずっと、CrashLoopBackOffです。

というのも、Istioは、arm64向けのコンテナイメージを提供していないので、アーキテクチャの違いで、コンテナが起動出来ないのが原因です。
例えば、「reviews」のイメージは下記ですが、「Linux/amd64」となっており、使用できません。
https://hub.docker.com/r/istio/examples-bookinfo-reviews-v1/tags

image.png

試しに、pull して、run してみても、同様の結果となります。

$ docker pull istio/examples-bookinfo-reviews-v1
$ docker images
REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE
istio/examples-bookinfo-reviews-v1   latest    dccfa4b82422   11 months ago   695MB
$ docker run -it istio/examples-bookinfo-reviews-v1 uname -m
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:228: exec user process caused: exec format error

docker pullの時に--platformを付けたとしても、イメージが提供されていないので、使用できません。
ということで、強引にやってもNGでした。

それならば。と、arm64用のDockerImageでも作るか~と思いましたが、色々と詰まったので、サンプルを動かすのは諦めました。
サンプルを動かしたいわけじゃない。

以下、激戦の傷跡です(いいすぎ)
# Dockerの試験的機能の有効化するために環境変数を追加
vi ~/.bashrc
# ---
# Dockerの試験的機能の有効化
export DOCKER_CLI_EXPERIMENTAL=enabled
# ---
# 反映
source ~/.bashrc

# Dockerの試験的機能の有効化の確認
docker --help
# ---
# buildx* があることを確認
Management Commands:
  app*        Docker App (Docker Inc., v0.9.1-beta3)
  builder     Manage builds
  buildx*     Docker Buildx (Docker Inc., v0.7.1-docker)
# ---

# 他プラットフォームのイメージを取得
docker run --privileged --rm tonistiigi/binfmt --install all

# arm、amdがあることを確認
docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS  PLATFORMS
  default * docker
  default default         running linux/arm64, linux/arm/v7, linux/arm/v6, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386

# ビルダーの作成
docker buildx create --name mybuilder

# ビルダーの適用
docker buildx use mybuilder

# 確認
docker buildx ls
NAME/NODE    DRIVER/ENDPOINT             STATUS   PLATFORMS
  mybuilder *  docker-container
  mybuilder0 unix:///var/run/docker.sock inactive
  default      docker
  default    default                     running  linux/arm64, linux/arm/v7, linux/arm/v6, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386

# 起動
docker buildx inspect --bootstrap

# nodejs(npm) install
sudo yum install nodejs npm

# OCIのIngressルールに9080を追加
# OCIインスタンスのFirewallに9080を追加
firewall-cmd --add-port=9080/tcp
# DockerHubへログイン
docker login

# Dockerfileの取得
## productpage-v1
mkdir productpage-v1
cd productpage-v1
curl -s https://raw.githubusercontent.com/istio/istio/release-1.13/samples/bookinfo/src/ratings/package.json -o package.json

## Dockerfileの取得
curl -s https://raw.githubusercontent.com/istio/istio/release-1.12/samples/bookinfo/src/productpage/Dockerfile -o Dockerfile

## Dockerfileからimageのビルド
docker build -t nobkovskii/productpage-v1 .

## ratings
mkdir ratings
cd ratings
cp ../productpage-v1/package.json ./
curl -s https://raw.githubusercontent.com/istio/istio/release-1.13/samples/bookinfo/src/ratings/ratings.js -o ratings.js
curl -s https://raw.githubusercontent.com/istio/istio/release-1.12/samples/bookinfo/src/ratings/Dockerfile -o Dockerfile

docker build -t nobkovskii/ratings .

## details
mkdir details
cd ratings
cp ../productpage-v1/package.json ./
curl -s https://raw.githubusercontent.com/istio/istio/release-1.12/samples/bookinfo/src/details/Dockerfile -o Dockerfile

docker build -t nobkovskii/ratings .

# DockerHubへPush
docker buildx build --platform linux/amd64,linux/arm/v7 -t nobkovskii/istio-bookinfo-productpage-v1 --push .


git clone https://github.com/istio/istio.git
cd istio/samples/bookinfo/src

# ratings
docker build -t istio/examples-bookinfo-ratings-v1:1.12.2 -f ratings/Dockerfile --build-arg service_version=v1 ratings

# details
docker build -t istio/examples-bookinfo-details-v1:1.12.2 -f details/Dockerfile --build-arg service_version=v1 details

# productpage
docker build -t istio/examples-bookinfo-productpage-v1:1.12.2 -f productpage/Dockerfile productpage

# mysql
docker build -t istio/examples-bookinfo-mysqldb:1.12.2 -f mysql/Dockerfile mysql

# mongodb
docker build -t istio/examples-bookinfo-mongodb:1.12.2 -f mongodb/Dockerfile mongodb

# reviews v1~v3
# ====
# openliberty周りが解決出来ず、断念。
# reviews以外は動きそう・・・
# ====
## 「websphere-liberty」がarm64に非対応のため、「[adoptopenjdk](https://hub.docker.com/layers/adoptopenjdk/openjdk8/aarch64-centos-jdk8u322-b06/images/sha256-cee09193dd57ef05e9bf93cecf428e8bc322a319dd3f700055acd59b562c3275?context=explore)」を使用する
git clone https://github.com/OpenLiberty/ci.docker.git
cd ci.docker/releases/latest/kernel-slim
vi Dockerfile.ubi.ibmjava8
# --- diff
- FROM ibmjava:8-ubi
+ FROM adoptopenjdk/openjdk8:aarch64-centos-jdk8u322-b06
# ---
docker build -t openliberty/aarch64-jdk8:latest -f ./Dockerfile.ubi.ibmjava8 .

vi reviews/reviews-wlpcfg/Dockerfile
# --- diff
- FROM websphere-liberty:20.0.0.6-full-java8-ibmjava
+ FROM openliberty/aarch64-jdk8:latest
# ---

docker build -t istio/examples-bookinfo-reviews-v1:1.12.2 -f reviews/reviews-wlpcfg/Dockerfile --build-arg service_version=v1 reviews/reviews-wlpcfg/
docker build -t istio/examples-bookinfo-reviews-v2:1.12.2 -f reviews/reviews-wlpcfg/Dockerfile --build-arg service_version=v2 --build-arg enable_ratings=true reviews/reviews-wlpcfg/
docker build -t istio/examples-bookinfo-reviews-v3:1.12.2 -f reviews/reviews-wlpcfg/Dockerfile --build-arg service_version=v3 --build-arg enable_ratings=true --build-arg star_color=red reviews/reviews-wlpcfg/

おわりに

今回は非常にくやしい結果となりました・・・
サンプルも早いとこ、arm64に対応してくれると嬉しいなぁ。

次回は、サンプルではなく、普通にIstioを導入してみたいと思います。
(出来るのかな?出来るよね?)

1
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
1
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?