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?

今更minikubeでOpenTelemetry Demoを建てる #minikube編

0
Last updated at Posted at 2026-04-23

はじめに

InstanaとOpenTelemetryの勉強を進めたいので
minikube環境にOpenTelemetry Demoを作りました。
記事は3本建てで、今回はminikube環境のみを作ります。
minikubeはdocker desktopなどで代替できます。
私は手持ちの環境の都合上Ubuntu VMを使用してminikubeを作りました。

記事全体で作るもの

  • Ubuntu上にminikubeでKubernetesクラスタを構築(この記事の対象)
  • OpenTelemetry Demo(マイクロサービスECサイト)をデプロイ
  • InstanaでOpenTelemetry Demoのトレースを確認する

構成

Ubuntu 20.04 LTS (VM)
├─ Docker Engine
├─ minikube (Kubernetesクラスタ)
└─ OpenTelemetry Demo + Grafana Alloy
↓ OTLP
Instana(SaaS)

前提条件

  • minikubeを建てられる仮想マシン環境がある。
    • ubuntu 20.04 LTS
    • CPUコア 4コア程度は欲しい
    • メモリ 8GB程度は欲しい
    • ディスク 50GBもあれば足ります

minikubeのinstall方法

minikube環境は下記の手順で環境を構築します
1. Docker Engine のインストール
2. kubectl, Helm, minikube のインストール
3. minikube 起動

Step 1: Docker Engineのインストール

Ubuntu VMにSSH接続して作業します。Docker DesktopではなくDocker Engine (CE) を使います。

# 必要パッケージ
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release

# Docker 公式 GPG キー
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# リポジトリ追加
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# インストール
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# sudo なしで docker コマンドを使えるようにする
sudo usermod -aG docker $USER
newgrp docker

# 動作確認
docker run hello-world


# 実行結果.
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Step 2: kubectl / Helm / minikubeのインストール

kubectl

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client

Helm(ここで1つ目の罠)

いくつかインストール方法はあるのですが、
スクリプトを使ってインストールします.

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4
chmod 700 get_helm.sh
./get_helm.sh

実を言うと生成AIを使ってこの環境はDeployしました。
apt経由のインストールを試したのですが当初インストールがコケました。

curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt update
W: Failed to fetch https://baltocdn.com/helm/stable/debian/dists/all/InRelease
Could not resolve 'baltocdn.com'

なぜかbaltocdn.comが名前解決できない怒られました。
どうやら生成AIが古い技術ブログを確認していたようです。
helmについてはリポジトリホストが Balto から Buildkite への移行中で、
DNS解決失敗や 403 Forbidden が頻発しているようです。
参考: Debian/Ubuntu Helm Apt Repository Move

公式ドキュメントを確認すると
buildkite.comを指定しているので、次にデプロイする場合はこちらを試してみます。
(要確認)
参考:Installing Helm

sudo apt-get install curl gpg apt-transport-https --yes
curl -fsSL https://packages.buildkite.com/helm-linux/helm-debian/gpgkey | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/helm.gpg] https://packages.buildkite.com/helm-linux/helm-debian/any/ any main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

minikube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
rm minikube-linux-amd64
minikube version

# 実行結果
minikube version: v1.38.1
commit: c93a4cb9311efc66b90d33ea03f75f2c4120e9b0

Versionが確認できているので、インストールが出来ています。

Step 3: minikubeクラスタの起動

OpenTelemetry Demoは20個以上のPodが立ち上がるため、リソースを多めに確保します。

minikube start \
  --driver=docker \
  --cpus=4 \
  --memory=8192 \
  --disk-size=40g \
  --kubernetes-version=stable

起動確認:

kubectl get nodes
NAME       STATUS   ROLES           AGE   VERSION
minikube   Ready    control-plane   29s   v1.35.1

アドオンも有効化しておきます。

minikube addons enable metrics-server
minikube addons enable ingress

metrics-serverは通常のk8sクラスターであれば標準でついてくるのですが、
minikubeは標準では上記コマンドが必要です。

metrics-serverをオンにすることで直近のCPU使用率やメモリ使用率がわかります。

# インストール
# nodeのCPU使用率を調べる
kubectl top nodes
# 実行結果
NAME       CPU(cores)   CPU(%)   MEMORY(bytes)   MEMORY(%)
minikube   2287m        38%      7591Mi          47%

#podのCPU/メモリ使用状況を調べる
#(手元の環境で打っていますのでOTEL-demoのpodを調べています)
kubectl top pod -n otel-demo
NAME                               CPU(cores)   MEMORY(bytes)
accounting-5ccf5cf965-vvtxr        4m           119Mi
ad-5547bd5bd9-wpc9c                2m           246Mi
cart-74f5bf48d9-dvxlq              4m           56Mi
checkout-546dd7dbd9-cs24g          3m           18Mi
currency-5c757d5f4-fsdwn           1m           5Mi
email-78fcc8d79-2pds7              2m           53Mi
flagd-5ff58bc756-j8xbj             3m           116Mi
fraud-detection-74c96487b7-pbzb6   5m           277Mi
frontend-6bd6cb5df4-54rz5          19m          78Mi
frontend-proxy-697fbd5699-xjt6n    12m          22Mi
grafana-78d45767bc-xp2sb           12m          239Mi
image-provider-76655d4b8d-qlspd    1m           9Mi
jaeger-6799894d46-qxlvb            6m           400Mi
kafka-84d959f89d-qjvfc             15m          591Mi
llm-fb88677f7-tjg9m                19m          47Mi
load-generator-d8b6686fb-zlzzf     1397m        1001Mi
opensearch-0                       26m          848Mi
otel-collector-agent-2cxpr         66m          142Mi
payment-5c5df75598-rnlgg           10m          99Mi
postgresql-66fff77f5d-ftn9h        10m          49Mi
product-catalog-d6db96fb7-zdlr2    7m           17Mi
product-reviews-5996cd4c78-jlgtl   17m          72Mi
prometheus-685b54b847-68kcv        16m          312Mi
quote-6cdc7d568f-9tqwl             1m           21Mi
recommendation-78c689f8cf-qrn2k    13m          42Mi
shipping-78f88699cd-p559x          2m           6Mi
valkey-cart-779654c7f4-qccjz       3m           9Mi

一応minikubeの動作確認をしておきましょう。

kubectl create deployment hello-nginx --image=nginx
kubectl expose deployment  hello-nginx --type=NodePort --port=80
minikube service hello-nginx
kubectl get pods -l app=hello-nginx

# 最後のコマンドの実行結果
NAME                          READY   STATUS    RESTARTS   AGE
hello-nginx-b99884d4b-tk2z5   1/1     Running   0          117s

お疲れ様でした。

次はOpentelemetry Demoをminikube上に建てます。

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?