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.

k3sでistioを動作させる その2

Posted at

概要

k3sでistioのサンプル(Bookinfo)を動作させる。

環境

  • OS : osx multipass上で動作するUbuntu
  • k3s : 最新を取得(v1.22.5+k3s1)
  • Istio : 最新を取得(istio-1.12.2)

手順

  1. Bookinfoアプリケーションをデプロイ。
  • オートマチック・サイドカー・インジェクションによりenvoryを入れる。
$ kubectl label namespace default istio-injection=enabled
  • Bookinfoアプリケーションをデプロイする。
$ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
service/details unchanged
serviceaccount/bookinfo-details unchanged
deployment.apps/details-v1 unchanged
service/ratings unchanged
serviceaccount/bookinfo-ratings unchanged
deployment.apps/ratings-v1 unchanged
service/reviews unchanged
serviceaccount/bookinfo-reviews unchanged
deployment.apps/reviews-v1 unchanged
deployment.apps/reviews-v2 unchanged
deployment.apps/reviews-v3 unchanged
service/productpage unchanged
serviceaccount/bookinfo-productpage unchanged
deployment.apps/productpage-v1 unchanged
  • 作成されたサービスの確認。
$ kubectl get services
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
kubernetes    ClusterIP   10.43.0.1               443/TCP    6d18h
details       ClusterIP   10.43.250.211           9080/TCP   6d18h
ratings       ClusterIP   10.43.128.103           9080/TCP   6d18h
reviews       ClusterIP   10.43.252.163           9080/TCP   6d18h
productpage   ClusterIP   10.43.12.119            9080/TCP   6d18h
  • 作成されたPodの確認。
$ kubectl get po
NAME                              READY   STATUS    RESTARTS        AGE
ratings-v1-b6994bb9-tfcth         2/2     Running   4 (8m13s ago)   6d18h
reviews-v3-84779c7bbc-cjtcj       2/2     Running   4 (8m13s ago)   6d18h
reviews-v2-7bf8c9648f-z4sgl       2/2     Running   4 (8m13s ago)   6d18h
reviews-v1-545db77b95-f69kc       2/2     Running   4 (8m14s ago)   6d18h
details-v1-79f774bdb9-btrng       2/2     Running   4 (8m13s ago)   6d18h
productpage-v1-6b746f74dc-p76xs   2/2     Running   4 (8m13s ago)   6d18h
  1. Bookinfoアプリケーションに外部からアクセスできるように、サービス・メッシュのエッジ(境界)にIstio gatewayを作成。
  • Istio gatewayをデプロイ。
$ kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created
  • 設定が成功している確認。
$ istioctl analyze
✔ No validation issues found when analyzing namespace: default.
  • 作成したGatewayを確認。
$ kubectl get gateway
NAME               AGE
bookinfo-gateway   23m
  1. 外部アクセス用のIP、ポートの設定。
  • 現在動作しているクラスタのLoadBalancerの設定の確認。
$ kubectl get svc istio-ingressgateway -n istio-system
NAME                   TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)                                                                      AGE
istio-ingressgateway   LoadBalancer   10.43.54.163   192.168.64.8   15021:31355/TCP,80:30877/TCP,443:32355/TCP,31400:31017/TCP,15443:30817/TCP   6d19h
  • 環境変数を設定
$ export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
$ export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
$ export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
  • IPアドレスとポートの確認。
$ echo "$GATEWAY_URL"
192.168.64.8:80
  • 外部アクセス用のURL確認。
$ echo "http://$GATEWAY_URL/productpage"
http://192.168.64.8:80/productpage
  • アクセス確認。
$ curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage
200
  • ブラウザからアクセス。
    スクリーンショット 2022-01-23 15.12.13.png

参考

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?