1. はじめに
本記事では、Kubernetes上にSpring Bootで構築したアプリを動作させるハンズオンをご紹介します。ひととおり実施して基本を理解いただければ、ご自身で開発したアプリもKubernetes上で運用できるようになると思いますので、トライしてもらえると幸いです。今回はStep3として、Ingressを導入することでKubernetesクラスタ外部からAP Podに接続する方法をご紹介します。
2. 前提環境
Kubernetesがインストールされている環境を準備ください。オンプレ。クラウドどちらでも構いません。
オンプレでKuberntesインストールからやってみたいという方がいれば、下記を参考にして構築してもらえればと思います。
【初心者向け】Kubernetes学習向けのハンズオン(Linux(CentOS))
まだDBコンテナ、APコンテナ作成が終わってないようでしたら下記を参考にして作成してください。
【初心者向けハンズオン】KubernetesでJava(Spring Boot)アプリデプロイ ~Step1:DBコンテナ作成~
【初心者向けハンズオン】KubernetesでJava(Spring Boot)アプリデプロイ ~Step2:APコンテナ作成~
3. システム構成
Step1、Step2ではシンプルにPod、Serviceの組み合わせで構成していましたが、Step3では要素が増えています。Step3で追加した要素は下記となります。
MetalLB | オープンソースのロードバランサとなります。クラウド環境においては、LoadBalanceサービスを作成すると自動的に外部からアクセス可能なIPアドレスを割り当ててくれますが、オンプレ環境においてはロードバランサを別途作成する必要があります。 |
Istio Ingerss Gateway | Istioはマイクロサービス間の通信を管理、制御するためのサービスメッシュというOSS技術となります。Isito Ingress GatewayはIstioが構成する要素のひとつで、外部トラフィックを受け入れるGatewayとしての機能を提供します。Kubernetes Ingressと比較するとより機能が充実しており、高度なルーティングやトラフィック制御を実現することができます。 |
Envoy(Istio Proxy) | EnvoyはOSSのプロキシとなります。今回はIstioによってEnvoyをカスタマイズしたIstio Proxyを導入します。Envoyは別名サイドカーと呼ばれており、Podにサイドカーコンテナとしてデプロイされます。 |
構成図も更新してますので参照ください。

4. Ingress導入手順
4.1 Istioインストール
適当なディレクトリに移動し、curlコマンドでIstioをダウンロードします。
[root@masternode ~]# cd /opt/
[root@masternode opt]#
[root@masternode opt]# curl -L https://istio.io/downloadIstio | sh -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 101 100 101 0 0 338 0 --:--:-- --:--:-- --:--:-- 341
100 5124 100 5124 0 0 7426 0 --:--:-- --:--:-- --:--:-- 7426
Downloading istio-1.24.3 from https://github.com/istio/istio/releases/download/1.24.3/istio-1.24.3-linux-amd64.tar.gz ...
Istio 1.24.3 download complete!
The Istio release archive has been downloaded to the istio-1.24.3 directory.
To configure the istioctl client tool for your workstation,
add the /opt/istio-1.24.3/bin directory to your environment path variable with:
export PATH="$PATH:/opt/istio-1.24.3/bin"
Begin the Istio pre-installation check by running:
istioctl x precheck
Try Istio in ambient mode
https://istio.io/latest/docs/ambient/getting-started/
Try Istio in sidecar mode
https://istio.io/latest/docs/setup/getting-started/
Install guides for ambient mode
https://istio.io/latest/docs/ambient/install/
Install guides for sidecar mode
https://istio.io/latest/docs/setup/install/
Need more information? Visit https://istio.io/latest/docs/
[root@masternode opt]#
[root@masternode opt]# ls -ld istio-1.24.3/
drwxr-x--- 6 root root 115 Feb 6 10:30 istio-1.24.3/
[root@masternode opt]#
istioctlコマンドが実行できるようにパスを設定します。istioctl versionコマンドにて、istioのバージョンが表示されれば成功です。
[root@masternode bin]# vi /etc/profile
[root@masternode bin]# cat /etc/profile |grep "export PATH="
export PATH=/opt/istio-1.24.3/bin:$PATH"
[root@masternode bin]# source /etc/profile
[root@masternode bin]# istioctl version
Istio is not present in the cluster: no running Istio pods in namespace "istio-system"
client version: 1.24.3
[root@masternode bin]#
istioctl x precheckコマンドを実行し、KubernetesクラスタがIstioをインストールできる状態になっていることを確認します。下記の通りNo issues foundと出力されることを確認してください。
[root@masternode bin]# istioctl x precheck
✔ No issues found when checking the cluster. Istio is safe to install or upgrade!
To get started, check out https://istio.io/latest/docs/setup/getting-started/.
[root@masternode bin]#
istioctl installコマンドを実行してIstioをインストールします。
[root@masternode bin]# istioctl install --set profile=demo -y
|\
| \
| \
| \
/|| \
/ || \
/ || \
/ || \
/ || \
/ || \
/______||__________\
____________________
\__ _____/
\_____/
✔ Istio core installed ⛵️
✔ Istiod installed 🧠
✔ Egress gateways installed 🛫
✔ Ingress gateways installed 🛬
✔ Installation complete
[root@masternode bin]#
Istio関連のリソースが作成されていることを確認してください。
[root@masternode bin]# kubectl get namespace |grep istio
istio-system Active 3m3s
[root@masternode bin]#
[root@masternode bin]# kubectl get all -n istio-system
NAME READY STATUS RESTARTS AGE
pod/istio-egressgateway-df8657bd7-pc8gg 1/1 Running 0 2m48s
pod/istio-ingressgateway-7cdbd79c7f-jml4z 1/1 Running 0 2m48s
pod/istiod-9497b5dff-zwrxc 1/1 Running 0 3m13s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/istio-egressgateway ClusterIP 10.110.3.125 <none> 80/TCP,443/TCP 2m48s
service/istio-ingressgateway LoadBalancer 10.102.164.239 <pending> 15021:30274/TCP,80:31177/TCP,443:32476/TCP,31400:31969/TCP,15443:31709/TCP 2m48s
service/istiod ClusterIP 10.100.210.177 <none> 15010/TCP,15012/TCP,443/TCP,15014/TCP 3m13s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/istio-egressgateway 1/1 1 1 2m49s
deployment.apps/istio-ingressgateway 1/1 1 1 2m49s
deployment.apps/istiod 1/1 1 1 3m13s
NAME DESIRED CURRENT READY AGE
replicaset.apps/istio-egressgateway-df8657bd7 1 1 1 2m49s
replicaset.apps/istio-ingressgateway-7cdbd79c7f 1 1 1 2m49s
replicaset.apps/istiod-9497b5dff 1 1 1 3m13s
[root@masternode bin]
TYPE LoadBalancerのIstio Ingress Gatewayが作成されていることを確認してください。
[root@masternode ~]# kubectl get svc -n istio-system istio-ingressgateway
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 10.105.18.184 <pending> 15021:31474/TCP,80:31338/TCP,443:32177/TCP,31400:31085/TCP,15443:31576/TCP 3d21h
[root@masternode ~]#
Istio Ingress Gatewayを作成していきます。下記を参考にマニフェストを作成してください。HTTPSで通信を受け付ける設定としております。
[root@masternode manifest]# vi quizapp-gateway.yaml
[root@masternode manifest]# cat quizapp-gateway.yaml
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
name: quizapp-gateway
namespace: quizapp
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: istio-ingressgateway-certs
hosts:
- "*"
[root@masternode manifest]#
マニフェストを適用し、gatewayリソースが作成されたことを確認してください。
[root@masternode manifest]# kubectl apply -f quizapp-gateway.yaml
gateway.networking.istio.io/quizapp-gateway created
[root@masternode manifest]# kubectl get gateway -n quizapp
NAME AGE
quizapp-gateway 3m15s
[root@masternode manifest]#
続いてvirtual serviceリソースを作成します。virtual serviceとは、Istioサービスメッシュ内でトラフィックを制御するためのリソースとなります。gateway経由のリクエストをAP podにルーティングする設定を記載しています。
[root@masternode manifest]# vi quizapp-virtualservice.yaml
[root@masternode manifest]# cat quizapp-virtualservice.yaml
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: quizapp-virtualservice
namespace: quizapp
spec:
hosts:
- "*"
gateways:
- quizapp-gateway
http:
- match:
- uri:
prefix: /
route:
- destination:
host: quizapp
port:
number: 80
[root@masternode manifest]#
マニフェストを適用し、virtual serviceのリソースが作成されていることを確認してください。
[root@masternode manifest]# kubectl apply -f quizapp-virtualservice.yaml
virtualservice.networking.istio.io/quizapp-virtualservice created
[root@masternode manifest]#
[root@masternode manifest]# kubectl get VirtualService -n quizapp
NAME GATEWAYS HOSTS AGE
quizapp-virtualservice ["quizapp-gateway"] ["*"] 17s
[root@masternode manifest]#
4.2 MetalLBインストール
MetalLBのマニフェストをkuberctl applyコマンドで適用します。
[root@masternode ~]# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.10/config/manifests/metallb-native.yaml
namespace/metallb-system created
customresourcedefinition.apiextensions.k8s.io/addresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bfdprofiles.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgpadvertisements.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgppeers.metallb.io created
~~Omission~~
secret/webhook-server-cert created
service/webhook-service created
deployment.apps/controller created
daemonset.apps/speaker created
validatingwebhookconfiguration.admissionregistration.k8s.io/metallb-webhook-configuration created
[root@masternode ~]#
MetalLBにて割り当てるIPアドレスを指定します。下記の通りIPアドレスプールに関するマニフェストを適用してください。
[root@masternode ~]# vi ipadress-pool.yaml
[root@masternode ~]# cat ipadress-pool.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: istio-ingress
namespace: metallb-system
spec:
addresses:
- 192.168.100.200-192.168.100.210
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: example
namespace: metallb-system
[root@masternode ~]#
[root@masternode ~]# kubectl apply -f ipadress-pool.yaml
ipaddresspool.metallb.io/istio-ingress created
l2advertisement.metallb.io/example created
[root@masternode ~]#
再度、Istio Ingress Gatewayに関する情報を確認してください。EXTERNAL-IPにIPアドレスプールで指定したレンジのIPアドレスが割り当てられていることが確認できるはずです。
[root@masternode ~]# kubectl get svc -n istio-system istio-ingressgateway
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 10.105.18.184 192.168.100.201 15021:31474/TCP,80:31338/TCP,443:32177/TCP,31400:31085/TCP,15443:31576/TCP 3d21h
[root@masternode ~]#
4.3 Envoy(Istio Proxy)の導入
続いて、EnvoyをAP Podに導入していきましょう。まずはEnvoy導入に必要なカーネルモジュールを読み込んでいきます。下記の通り/etc/mdprobe.d配下にistio.confファイルを新規作成して、必要なモジュールに関する情報を追記します。
必要なモジュールに関する要件は下記を参考にしてください。
https://istio.io/latest/docs/ops/deployment/platform-requirements/
ただし環境によってはロードできないモジュールがあり、systemd-modules-loadを再起動した際にエラーが発生することがあります。その場合はエラーとなったモジュールを除外して下さい。参考までにCentOS8.5において必要なモジュールを記載します。
[root@masternode ~]# cd /etc/modprobe.d
[root@masternode modprobe.d]#
[root@masternode modprobe.d]# vi istio.conf
[root@masternode modprobe.d]# cat istio.conf
br_netfilter
ip6table_mangle
ip6table_nat
ip6table_raw
iptable_mangle
iptable_nat
iptable_raw
xt_REDIRECT
xt_connmark
xt_conntrack
xt_mark
xt_owner
xt_tcpudp
bridge
ip6_tables
ip_tables
nf_conntrack
nf_conntrack_ipv4
nf_conntrack_ipv6
nf_nat
nf_nat_ipv4
nf_nat_ipv6
nf_nat_redirect
x_tables
[root@masternode modprobe.d]#
istio.confファイルを作成したら、下記の通りsystemd-modules-loadサービスを再起動します。下記の通りActiveステータスがactive (exited)となっていれば正常にモジュールがロードされているはずです。
[root@masternode modules-load.d]# systemctl restart systemd-modules-load.service
[root@masternode modules-load.d]# systemctl status systemd-modules-load.service
● systemd-modules-load.service - Load Kernel Modules
Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static; vendor preset: disabled)
Active: active (exited) since Sun 2025-02-23 06:22:45 JST; 1h 12min ago
Docs: man:systemd-modules-load.service(8)
man:modules-load.d(5)
Process: 720 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=0/SUCCESS)
Main PID: 720 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 36456)
Memory: 0B
CGroup: /system.slice/systemd-modules-load.service
Feb 23 06:22:45 masternode systemd-modules-load[720]: Inserted module 'iptable_nat'
Feb 23 06:22:45 masternode systemd-modules-load[720]: Inserted module 'iptable_raw'
Feb 23 06:22:45 masternode systemd-modules-load[720]: Inserted module 'xt_REDIRECT'
Feb 23 06:22:45 masternode systemd-modules-load[720]: Inserted module 'xt_connmark'
Feb 23 06:22:45 masternode systemd-modules-load[720]: Inserted module 'xt_conntrack'
Feb 23 06:22:45 masternode systemd-modules-load[720]: Inserted module 'xt_mark'
Feb 23 06:22:45 masternode systemd-modules-load[720]: Inserted module 'xt_owner'
Feb 23 06:22:45 masternode systemd-modules-load[720]: Module 'xt_tcpudp' is builtin
Feb 23 06:22:45 masternode systemd-modules-load[720]: Module 'x_tables' is builtin
Feb 23 06:22:45 masternode systemd[1]: Started Load Kernel Modules.
[root@masternode ~]#
下記コマンドを実行し、quizappに対してistio-injectionを有効にします。istio-injectionを有効にすることで、pod作成時にenvoy(istio-proxy)が自動的に作成されます。
[root@masternode manifest]# kubectl label namespace quizapp istio-injection=enabled
namespace/quizapp labeled
[root@masternode manifest]#
下記コマンドを実行し、istio-injectionが有効になっていることを確認してください。
[root@masternode ~]# kubectl get namespace -L istio-injection
NAME STATUS AGE ISTIO-INJECTION
calico-apiserver Active 46d
calico-system Active 46d
default Active 46d enabled
istio-system Active 34h
kube-node-lease Active 46d
kube-public Active 46d
kube-system Active 46d
metallb-system Active 26h
postgres Active 39d
tigera-operator Active 46d
[root@masternode ~]#
続いて、AP podを再作成してください。
[root@masternode manifest]# kubectl delete -f quizapp-deployment.yaml
deployment.apps "quizapp" deleted
[root@masternode manifest]#
[root@masternode manifest]# kubectl apply -f quizapp-deployment.yaml
deployment.apps/quizapp created
[root@masternode manifest]#
podの状態を確認します。下記の通りquizappのpodのREADYが1/1から2/2に代わっていれば成功です。Envoyがquizapp podの上で動いているはずです。
[root@masternode manifest]# kubectl get pod -n quizapp
NAME READY STATUS RESTARTS AGE
postgres-58c98dcd44-5hf7z 1/1 Running 2 (5m43s ago) 2d12h
postgres-58c98dcd44-cbspd 1/1 Running 2 (5m40s ago) 2d12h
postgres-58c98dcd44-rq9d9 1/1 Running 2 (5m41s ago) 2d12h
quizapp-9446b7c78-5fwxz 2/2 Running 0 24s
quizapp-9446b7c78-b8jch 2/2 Running 0 24s
quizapp-9446b7c78-h8cbs 2/2 Running 0 24s
[root@masternode manifest]#
以上でIngress関連の設定は完了です。Ingress経由の接続を試す前にistioctl analyzeコマンドを実行し、設定の問題有無を確認してください。No vlidation issuesが表示されていれば成功です。もしエラーが出ているようであれば、エラー内容に従ってマニフェストを修正してください。
[root@masternode manifest]# istioctl analyze -n quizapp
✔ No validation issues found when analyzing namespace: quizapp.
[root@masternode manifest]#
下記の通りcurlコマンドを実行してアプリケーションにアクセスできることを確認してください。
[root@masternode manifest]# curl http://192.168.100.201/quiz/public
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ITエンジニア育成クイズ</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h3>ITエンジニア育成クイズ</h3>
<a href= "/login" >ユーザ登録/ログイン</a>
<H6>ユーザ登録してログインすることで、クイズの学習ステータスを管理することができます。ぜひ登録して使ってみてください。</H6>
~~Omission~~
念のためIngress Gatewayにおけるアクセスログを確認してみましょう。下記の通りステータスコード200が返っていれば成功です。もしcurlコマンドでアクセスできないようでしたら、下記のログを参照して原因を特定して下さい。
[root@masternode manifest]# kubectl logs -l istio=ingressgateway -n istio-system
2025-02-25T11:16:38.185304Z info cache generated new workload certificate resourceName=default latency=6.533350011s ttl=23h59m59.814702156s
2025-02-25T11:16:38.185480Z info cache Root cert has changed, start rotating root cert
2025-02-25T11:16:38.194760Z info cache returned workload trust anchor from cache ttl=23h59m59.805249899s
2025-02-25T11:16:39.111465Z info ads ADS: new connection for node:1
2025-02-25T11:16:39.111710Z info cache returned workload certificate from cache ttl=23h59m58.888295643s
2025-02-25T11:16:39.117882Z info ads ADS: new connection for node:2
2025-02-25T11:16:39.118086Z info cache returned workload trust anchor from cache ttl=23h59m58.881916989s
2025-02-25T11:16:40.521521Z info Readiness succeeded in 56.375417178s
2025-02-25T11:16:40.521966Z info Envoy proxy is ready
[2025-02-25T11:24:21.860Z] "GET /quiz/public HTTP/2" 200 - via_upstream - "-" 0 1944 3146 3096 "10.0.2.101" "curl/7.61.1" "4ae12e50-bce0-93e5-8d44-829ea9a4bb3d" "192.168.100.201" "192.168.100.45:8080" outbound|80||quizapp.quizapp.svc.cluster.local 192.168.100.48:54272 192.168.100.48:8443 10.0.2.101:1618 - -
[root@masternode manifest]#
4.4 HTTPS接続設定
HTTP接続を実現するための設定を追加していきましょう。試験環境なのでオレオレ証明書を用いて設定を追加していきます。TLS鍵、TLS証明書を作成します。
[root@masternode ~]# openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=eeengineer.com/O=eeengineer"
Generating a RSA private key
.............................................................................................................+++++
.............+++++
writing new private key to 'tls.key'
-----
[root@masternode ~]#
[root@masternode ~]# ll tls.key
-rw------- 1 root root 1704 Feb 21 22:27 tls.key
[root@masternode ~]#
kubernetesにsecretリソースとして作成します。
[root@masternode ~]# kubectl create secret tls istio-ingressgateway-certs --cert=tls.crt --key=tls.key -n istio-system
secret/istio-ingressgateway-certs created
[root@masternode ~]#
[root@masternode ~]# kubectl get secret -n istio-system
NAME TYPE DATA AGE
istio-ca-secret istio.io/ca-root 5 5d
istio-ingressgateway-certs kubernetes.io/tls 2 48s
[root@masternode ~]#
gatewayのマニフェストにtlsの設定を追加します。先ほど作成したsecretリソース、istio-ingressgateway-certsを追加してリソースを再作成してください。
[root@masternode ~]# vi quizapp-gateway.yaml
[root@masternode ~]# cat quizapp-gateway.yaml
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
name: quizapp-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: istio-ingressgateway-certs
hosts:
- "*"
[root@masternode ~]#
[root@masternode ~]# kubectl apply -f quizapp-gateway.yaml
gateway.networking.istio.io/quizapp-gateway configured
[root@masternode ~]#
curlコマンドで接続確認してください。オプションkをつけることでサーバ証明書の検証をスキップしています。
[root@masternode ~]# curl -k https://192.168.100.201/quiz/public
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ITエンジニア育成クイズ</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h3>ITエンジニア育成クイズ</h3>
<a href= "/login" >ユーザ登録/ログイン</a>
<H6>ユーザ登録してログインすることで、クイズの学習ステータスを管理することができます。ぜひ登録して使ってみてください。</H6>
<table class="table table-bordered table-striped">
<thead class="table-dark">
<tr>
<th>カテゴリ</th>
<th>クイズ</th>
<th>リンク</th>
</tr>
</thead>
<tbody>
<tr>
<td >Linux</td>
<td>Linuxのシステムに関する一般的なログファイル名は?</td>
<td>
<a href="/quiz/public/1">クイズへ</a>
</td>
</tr>
<tr>
<td >Linux</td>
<td>ファイルの末尾から100行を表示させるコマンドは?</td>
<td>
<a href="/quiz/public/2">クイズへ</a>
</td>
</tr>
<tr>
<td >Linux</td>
<td>新規作成するファイルのパーミッションが全て644になるようにする方法は?</td>
<td>
<a href="/quiz/public/3">クイズへ</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>[root@masternode ~]#
ブラウザからアクセスできることを確認してみてください。下記にFireFfoxでアクセスした際のサンプル画像を記載します。
端末にルート証明書をインストールしていないため下記のような警告画面が出力されますが、無視して進めます。「詳細情報」をクリックしてください。

「危険を承知で続行」をクリックしてください。

下記のとおりhttpsでアクセスできていれば成功です。

(参考) kiali設定
kialiとはIstioサービスメッシュを監視・可視化するためのツールとなります。今回構築したのはシンプルな構成であるため構成図がすぐにイメージできるかもしれませんが、複雑になってくるとどのリソースがどのように通信しているのかを把握するのが難しくなってきますので、kialiのようなツールを用いて全体像を把握できるようにすることをお勧めします。
Kialiが動作する流れは下記となりますので、ここではkialiとPrometheusを導入します。
1. Istio Proxyがサービス間の通信データを収集
2. Istio ProxyがPrometheusにデータを保存
3. KialiがPrometheusに対してクエリを発行
まずはkiali導入のマニフェストを適用してください。
[root@masternode ~]# kubectl apply -f /opt/istio-1.24.3/samples/addons/kiali.yaml
serviceaccount/kiali created
configmap/kiali created
clusterrole.rbac.authorization.k8s.io/kiali created
clusterrolebinding.rbac.authorization.k8s.io/kiali created
service/kiali created
deployment.apps/kiali created
[root@masternode ~]#
kialiのリソースが正常に作成されていることを確認してください。
[root@masternode ~]# kubectl get all --namespace istio-system
NAME READY STATUS RESTARTS AGE
pod/istio-egressgateway-5c97bc8798-vtvgn 1/1 Running 15 (3m36s ago) 2d21h
pod/istio-ingressgateway-6449587b86-tpzq9 1/1 Running 15 (3m37s ago) 2d21h
pod/istiod-9497b5dff-grv89 1/1 Running 15 (3m37s ago) 2d21h
pod/kiali-7d57f454c-grvlq 1/1 Running 0 117s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/istio-egressgateway ClusterIP 10.103.67.88 <none> 80/TCP,443/TCP 2d21h
service/istio-ingressgateway LoadBalancer 10.105.18.184 192.168.100.201 15021:31474/TCP,80:31338/TCP,443:32177/TCP,31400:31085/TCP,15443:31576/TCP 2d21h
service/istiod ClusterIP 10.106.208.153 <none> 15010/TCP,15012/TCP,443/TCP,15014/TCP 2d21h
service/kiali ClusterIP 10.103.124.26 <none> 20001/TCP,9090/TCP 117s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/istio-egressgateway 1/1 1 1 2d21h
deployment.apps/istio-ingressgateway 1/1 1 1 2d21h
deployment.apps/istiod 1/1 1 1 2d21h
deployment.apps/kiali 1/1 1 1 117s
NAME DESIRED CURRENT READY AGE
replicaset.apps/istio-egressgateway-5c97bc8798 1 1 1 2d21h
replicaset.apps/istio-ingressgateway-6449587b86 1 1 1 2d21h
replicaset.apps/istiod-9497b5dff 1 1 1 2d21h
replicaset.apps/kiali-7d57f454c 1 1 1 117s
[root@masternode ~]#
kialiのnodeportを開放します。
[root@masternode ~]# kubectl expose pod kiali-7d57f454c-grvlq --type=NodePort --name=kiali-nodeport --namespace=istio-system --target-port=20001
service/kiali-nodeport exposed
[root@masternode ~]#
kialiにnodeportが割り当てられていることを確認します。
[root@masternode ~]# kubectl get svc --namespace istio-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-egressgateway ClusterIP 10.103.67.88 <none> 80/TCP,443/TCP 2d21h
istio-ingressgateway LoadBalancer 10.105.18.184 192.168.100.201 15021:31474/TCP,80:31338/TCP,443:32177/TCP,31400:31085/TCP,15443:31576/TCP 2d21h
istiod ClusterIP 10.106.208.153 <none> 15010/TCP,15012/TCP,443/TCP,15014/TCP 2d21h
kiali ClusterIP 10.103.124.26 <none> 20001/TCP,9090/TCP 5m44s
kiali-nodeport NodePort 10.98.164.135 <none> 20001:31809/TCP,9090:32601/TCP 30s
[root@masternode ~]#
kiali-nodeportの詳細を確認します。Nodeportが2つ割り当てされていることが確認できるかと思います。
[root@masternode ~]# kubectl describe svc kiali-nodeport --namespace istio-system
Name: kiali-nodeport
Namespace: istio-system
Labels: app=kiali
app.kubernetes.io/instance=kiali
app.kubernetes.io/managed-by=Helm
app.kubernetes.io/name=kiali
app.kubernetes.io/part-of=kiali
app.kubernetes.io/version=v2.0.0
helm.sh/chart=kiali-server-2.0.0
pod-template-hash=7d57f454c
sidecar.istio.io/inject=false
version=v2.0.0
Annotations: <none>
Selector: app.kubernetes.io/instance=kiali,app.kubernetes.io/managed-by=Helm,app.kubernetes.io/name=kiali,app.kubernetes.io/part-of=kiali,app.kubernetes.io/version=v2.0.0,app=kiali,helm.sh/chart=kiali-server-2.0.0,pod-template-hash=7d57f454c,sidecar.istio.io/inject=false,version=v2.0.0
Type: NodePort
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.98.164.135
IPs: 10.98.164.135
Port: port-1 20001/TCP
TargetPort: 20001/TCP
NodePort: port-1 31809/TCP
Endpoints: 192.168.100.60:20001
Port: port-2 9090/TCP
TargetPort: 20001/TCP
NodePort: port-2 32601/TCP
Endpoints: 192.168.100.60:20001
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
[root@masternode ~]#
続いてPrometheusをインストールします。
[root@masternode ~]# kubectl apply -f /opt/istio-1.24.3/samples/addons/prometheus.yaml
serviceaccount/prometheus created
configmap/prometheus created
clusterrole.rbac.authorization.k8s.io/prometheus created
clusterrolebinding.rbac.authorization.k8s.io/prometheus created
service/prometheus created
deployment.apps/prometheus created
[root@masternode ~]# kubectl apply -f /opt/istio-1.24.3/samples/addons/grafana.yaml
serviceaccount/grafana created
configmap/grafana created
service/grafana created
deployment.apps/grafana created
configmap/istio-grafana-dashboards created
configmap/istio-services-grafana-dashboards created
[root@masternode ~]# kubectl apply -f /opt/istio-1.24.3/samples/addons/jaeger.yaml
deployment.apps/jaeger created
service/tracing created
service/zipkin created
service/jaeger-collector created
[root@masternode ~]#
以上でkialiの導入は完了です。ブラウザからkialiにアクセスしてみましょう。
Nodeportに対してアクセスします。先ほどkialiの詳細確認の中に記載されていたポート番号31809か32601にアクセスします。
http://192.168.56.101:32601 ※IPアドレスは仮想サーバのIPを指定しています。
下記の通りダッシュボードが表示されるかと思います。「Traffic Graph」を選択して下さい。

確認したい対象のNamespaceを選択してください。

下記の通り構築したリソースが視覚的に見えるかと思います。本ツールを用いることでトラブルシューティングがやりやすくなるなどのメリットがありますので、ぜひ使ってみて下さい。

5. まとめ
オンプレ環境のkubernetesにIstio Ingressを導入する方法、およびSpring Bootをkubernetesにデプロイする方法のご紹介は以上となります。クラウドでサービス化されているkuberenesに対する導入に比べると少し手間がかかるところもありますが、あきらめずに最後まで実施してもらえると良いかと思います。
コメント