12.3.2. 必要なサービスメッシュリソースの作成
手順
トラフィックを受け入れる Istio ゲートウェイを作成します。
YAML ファイルを作成し、以下の YAML をこれにコピーします。
apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: default-gateway spec: selector: istio: ingressgateway servers: - port: number: 80 name: http protocol: HTTP hosts: - "*"
YAML ファイルを適用します。
$ oc apply -f <filename>
Istio
VirtualService
オブジェクトを作成し、ホストヘッダーを再作成します。YAML ファイルを作成し、以下の YAML をこれにコピーします。
apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: hello spec: hosts: - custom-ksvc-domain.example.com gateways: - default-gateway http: - rewrite: authority: hello.default.svc 1 route: - destination: host: hello.default.svc 2 port: number: 80
YAML ファイルを適用します。
$ oc apply -f <filename>
Istio
ServiceEntry
オブジェクトを作成します。これは、Kourier がサービスメッシュ外にあるため、OpenShift Serverless に必要です。YAML ファイルを作成し、以下の YAML をこれにコピーします。
apiVersion: networking.istio.io/v1alpha3 kind: ServiceEntry metadata: name: hello.default.svc spec: hosts: - hello.default.svc 1 location: MESH_EXTERNAL endpoints: - address: kourier-internal.knative-serving-ingress.svc ports: - number: 80 name: http protocol: HTTP resolution: DNS
- 1
- Knative サービスは、
<service_name>.<namespace>.svc
形式の Knative サービスです。
YAML ファイルを適用します。
$ oc apply -f <filename>
VirtualService
オブジェクトを参照する OpenShift Container Platform ルートを作成します。YAML ファイルを作成し、以下の YAML をこれにコピーします。
apiVersion: route.openshift.io/v1 kind: Route metadata: name: hello namespace: istio-system 1 spec: host: custom-ksvc-domain.example.com port: targetPort: 8080 to: kind: Service name: istio-ingressgateway
- 1
- OpenShift Container Platform ルートは ServiceMeshControlPlane と同じ namespace に作成される必要があります。この例では、ServiceMeshControlPlane は
istio-system
namespace にデプロイされます。YAML ファイルを適用します。
$ oc apply -f <filename>