このガイドでは、サービスメッシュ内のクライアントが、osm-edge のエグレス機能を使用してメッシュ外部の宛先にアクセスし、エグレスポリシーなしでトラフィックを未知の宛先にパススルーする方法を示す。
前提条件
- Kubernetesv1.19.0あるいはそれ以上を実行している Kubernetesクラスター。
- osm-edgeがインストールされている。
- APIサーバーとやり取りするためのkubectlは使用可能。
- サービスメッシュを管理するための「osm」CLIは使用可能。
HTTP(S) メッシュ全体のエグレスパススルーのデモ
-
有効になっていない場合は、グローバルエグレスパススルーを有効にする。
export osm_namespace=osm-system # Replace osm-system with the namespace where osm-edge is installed kubectl patch meshconfig osm-mesh-config -n "$osm_namespace" -p '{"spec":{"traffic":{"enableEgress":true}}}' --type=merge
-
その名前空間をメッシュに登録した後、
curl
クライアントをcurl
名前空間にデプロイする。# Create the curl namespace kubectl create namespace curl # Add the namespace to the mesh osm namespace add curl # Deploy curl client in the curl namespace kubectl apply -f https://raw.githubusercontent.com/flomesh-io/osm-edge-docs/release-v1.1/manifests/samples/curl/curl.yaml -n curl
curl
クライアントポッドが稼働中であることを確認する。$ kubectl get pods -n curl NAME READY STATUS RESTARTS AGE curl-54ccc6954c-9rlvp 2/2 Running 0 20s
-
curl クライアントがポート 443 で httpbin.org Web サイトへの HTTPS リクエストを正常に実行できることを確認する。
$ kubectl exec -n curl -ti "$(kubectl get pod -n curl -l app=curl -o jsonpath='{.items[0].metadata.name}')" -c curl -- curl -I https://httpbin.org:443 HTTP/2 200 date: Tue, 16 Mar 2021 22:19:00 GMT content-type: text/html; charset=utf-8 content-length: 9593 server: gunicorn/19.9.0 access-control-allow-origin: * access-control-allow-credentials: true
200 OK 応答は、curl クライアントから httpbin.org Web サイトへの HTTPS リクエストが成功したことを示す。
-
メッシュ全体のエグレスが無効になっている場合、HTTPS リクエストが失敗することを確認する。
kubectl patch meshconfig osm-mesh-config -n "$osm_namespace" -p '{"spec":{"traffic":{"enableEgress":false}}}' --type=merge
$ kubectl exec -n curl -ti "$(kubectl get pod -n curl -l app=curl -o jsonpath='{.items[0].metadata.name}')" -c curl -- curl -I https://httpbin.org:443 curl: (7) Failed to connect to httpbin.org port 443 after 3 ms: Connection refused command terminated with exit code 7
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.