Egress 制御
Egress 制御は mesh からの outbound traffic を管理し、セキュリティを強化する機能です。
目次
Egress の概要
この例では、アプリケーションからの HTTPS を sidecar と egress gateway 経由で routing します。api.external.com は、自分が管理し、名前解決可能な endpoint に置き換えてください。互換性のある Istio control plane をすでにインストールして使います。ServiceEntry は宛先を登録しますが、gateway 経由の traffic を強制するものでも、firewall として動作するものでもありません。egress の制限は、network control でも適用してください。
ServiceEntry の設定
外部 Service の登録
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: external-api
spec:
hosts:
- api.external.com
ports:
- number: 443
name: https
protocol: HTTPS
location: MESH_EXTERNAL
resolution: DNSHTTP 外部 Service
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: httpbin
spec:
hosts:
- httpbin.org
ports:
- number: 80
name: http
protocol: HTTP
location: MESH_EXTERNAL
resolution: DNSEgress Gateway
Egress Gateway のインストール
helm install istio-egressgateway istio/gateway \
-n istio-system \
--version 1.31.0 \
--set service.type=ClusterIP \
--set labels.app=istio-egressgateway \
--set labels.istio=egressgateway \
--waitEgress Gateway の設定
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
name: istio-egressgateway
namespace: istio-system
spec:
selector:
istio: egressgateway
servers:
- port:
number: 443
name: tls
protocol: TLS
hosts:
- api.external.com
tls:
mode: PASSTHROUGH
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: egressgateway-for-external
namespace: default
spec:
host: istio-egressgateway.istio-system.svc.cluster.local
subsets:
- name: external
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: direct-external-through-egress-gateway
namespace: default
spec:
hosts:
- api.external.com
gateways:
- mesh
- istio-system/istio-egressgateway
tls:
- match:
- gateways:
- mesh
port: 443
sniHosts:
- api.external.com
route:
- destination:
host: istio-egressgateway.istio-system.svc.cluster.local
subset: external
port:
number: 443
- match:
- gateways:
- istio-system/istio-egressgateway
port: 443
sniHosts:
- api.external.com
route:
- destination:
host: api.external.com
port:
number: 443TLS Origination
この例では、アプリケーションから外部 service への TLS 接続を維持し、egress gateway は SNI を使って routing します。一方、TLS origination では、アプリケーションが HTTP を送信した後、proxy で TLS を開始します。その場合は、HTTP の ServiceEntry の port/targetPort と DestinationRule の TLS policy を一致させる必要があります。TLS origination guide に従い、すでに暗号化されたアプリケーション接続に TLS layer を重ねて origination しないでください。
検証
インストールガイドに従って chart repository と version を設定してください。resource は指定された namespace に配置し、元の外部 ServiceEntry が default namespace にあるか、client namespace に export されていることを確認します。mesh client から SNI を指定し、両方の proxy route を調べ、egress gateway が接続を受信したことを検証してください。外部 endpoint に到達できただけでは、gateway を経由した証明にはなりません。
istioctl analyze -A
kubectl get pods -n istio-system -l istio=egressgateway
istioctl proxy-config listeners <egress-pod> -n istio-system
istioctl proxy-config clusters <client-pod> -n default