LoginSignup
4
4

More than 1 year has passed since last update.

Oracle Cloud Infrastructure Service Mesh忘備録

Last updated at Posted at 2022-10-03

はじめに

本記事は2022年4月に正式リリースとなったOracle Cloud Infrastructure Service Meshの概要記事となります。

OCI Service Meshの仕組み

特定のCustom Resourceを適用するとアプリケーションコンテナのサイドカーとしてEnvoyが導入されるような仕組みになっています。サイドカーでEnvoyと聞くとIstioを思い浮かべる方が多いと思いますが、本製品はIstioの拡張というわけではなくOCI独自のServiceMeshです。

チュートリアル

OCI Service Mesh概要図

OCIのドキュメントから引用

OCI Service Mesh概要

各種Resource

Mesh

OCI Mesh Resourceはサービスメッシュの論理境界を表します。

VirtualService

OCI VirtualService ResourceはOCI Mesh 内の論理的な接続先を表します。
K8s Serviceに相当する概念と考えればよいです。

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: VirtualService
metadata:
  name: <vs-sample-page>
  namespace: <sample-namespace>
  labels:
    version: v1
spec:
  compartmentId: ocid1.compartment.oc1..aaa...
  name: <vs-sample>
  description: <description text here>
  mesh:
    ref:
      name: <sample-mesh>
  defaultRoutingPolicy:
    type: <routing-policy> [`ROUND ROBIN`, `DENY`]
  hosts:
    - <vs-sample-page>.example.com    # ★Mesh内で利用するhost名
  mtls:
    mode: <mtls-mode> [`DISABLED`, `PERMISSIVE`, `STRICT`] # ★mTLSの設定

VirtualDeployment

VirtualServiceの先にある論理的なグループを表します。アプリケーションの各バージョンを表すものだと考えればよいです。

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: VirtualDeployment
metadata:
  name: <vs-sample-page>-version1
  namespace: <sample-namespace>
spec:
  compartmentId: ocid1.compartment.oc1..aaa...
  name: <vs-sample>-v1 
  description: <description-text>
  virtualService:
    ref:
      name: <vs-sample-page> # ★対応するVirtualService名
  accessLogging:
    isEnabled: true
  serviceDiscovery:
    type: DNS
    hostname: <vs-sample-page>-version1.example.com
  listener:
    - port: 9080
      protocol: HTTP

VirtualServiceRouteTable

どのVirtualDeploymentにルーティングを行うかの設定を記載します。
まだ各ルートに対する重みづけくらいしか機能はないようです。

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: VirtualServiceRouteTable
metadata:
  name: <vs-sample-page>-rt
  namespace: <sample-namespace>
spec:
  compartmentId: ocid1.compartment.oc1..aaa...
  name: <vs-sample>-routes
  description: <description text here>
  virtualService:
    ref:
      name: <vs-sample-page>
  routeRules:
    - httpRoute:
        destinations:
          - virtualDeployment:
              ref:
                name: <vs-sample-page>-version1
            weight: 100 # ★ルートに対する重みを設定する
        isGrpc: <boolean-value> [true/false]
        path: /foo,
        pathType: PREFIX

VirtualDeploymentBinding

OCI Service MeshのVirtualDeploymentとKubernetesのServiceを紐づけます。

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: VirtualDeploymentBinding
metadata:
  name: <binding-name>
  namespace: <binding-namespace>
spec:
  podUpgradeEnabled: true
  virtualDeployment:
    ref:
      name: <vd-name> # VirtualDeployment名	
  target:
    service:
      ref:
        name: <kubernetes-service-name> # 紐づけたいK8s Service名
        namespace: <kubernetes-service-namespace> # 紐づけたいK8s ServiceがあるNamespace名
  resources: # Side-carのresource
    requests:
      memory: "64Mi"
      cpu: "250m"
    limits:
      memory: "128Mi"
      cpu: "500m"
  mountCertificateChainFromHost: true

AccessPolicy

Mesh Resource内の通信許可/拒否のルールを記載します。

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: AccessPolicy
metadata:
  name: <sample-access-policy>
  namespace: <sample-namespace>
spec:
  compartmentId: ocid1.compartment.oc1..aaa...
  name: sample-ap
  description: This Access Policy
  mesh:
    ref:
      name: <sample-mesh> # ★ポリシを適用するMesh Resource名
  rules:
    - action: ALLOW # ★拒否/許可のルールを記載する
      source:
        virtualService:
          ref:
            name: <sample-virtual-service>
      destination:
          allVirtualServices: {}

IngressGatewayDeployment

クラスタ外部からMesh内への通信を処理します。
type: LoadBalancerなK8s ServiceやK8s DeploymentResourceを生成します。Nginx Ingress Controllerのような、K8s Ingress Resourceの実装部分と考えればよいです。

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: IngressGatewayDeployment
metadata:
  name: <sample-ingress-gateway>-deployment
  namespace: <sample-namespace>
spec:
  ingressGateway:
    ref:
      name: <sample-ingress-gateway>
  deployment:
    autoscaling: # ★外部からの通信を処理するPodの個数設定
      minPods: 1
      maxPods: 1
    mountCertificateChainFromHost: true
  ports:
    - protocol: TCP
      port: 8080
      serviceport: 80
  service:
    type: LoadBalancer # ★OCI LBaaSと連携し、外部公開される
  secrets:
    - secretName: secret-tls-secret

K8s DeploymentやK8s Serviceは、OCI Service Operatorが上記YAMLをもとに作成します。作成部分の実装はこちら。

IngressGatewayRouteTable

クラスタ外部からMesh内に到達した通信のルーティングルールを作成します。
VirtualServiceRouteTableと同じく、RouteRule型のパラメータでルールを設定します。

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: IngressGatewayRouteTable
metadata:
  name: <sample-ingress-gateway>-route-table    # Name of Ingress Gateway Route Table
  namespace: <sample-namespace>
spec:
  compartmentId: ocid1.compartment.oc1..aaa...
  name: <sample-ig-rt>       # Ingress Gateway Route Table name inside the mesh
  description: This Ingress Gateway Route Table
  ingressGateway:
    ref:
      name: <sample-ingress-gateway>
  routeRules:
    - httpRoute:
        ingressGatewayHost:
          name: samplehost
        path: /foo
        pathType: PREFIX
        isGrpc: false
        destinations:
          - virtualService:
              ref:
                name: <vs-sample-page> # ★ルーティング先のVirtualServiceを指定

IngressGateway

クラスタ外部からMesh内への通信に関わる設定を行います。
K8s Ingressに相当するものと考えればよいです。

所感

各種機能は今後に期待

調べた範囲では大まかに

  • トラフィックの重みづけ
  • トラフィックの許可/拒否ルールの設定
  • mTLS
  • Telemetry(PrometheusやGrafanaと連携)

の機能のみが提供されています。リトライやタイムアウト、Fault Injectionなどの機能はまだ実装されていません。まだまだ発展途上という段階で、IstioのようなServiceMeshと比較すると機能不足な感じは否めないです。

Kubernetesクラスタのみならず、VMなどのプラットフォームにまたがったメッシュの構築なども今後のロードマップに含まれているようなので、今後の拡張に期待します。

OCI Serviceとの連携

証明書の発行(OCI Certificates)との連携など、いくつかの機能ではOCI Managed Serviceとの連携がされていますがダッシュボード機能などはまだまだといったところ。

余談

余談ですが、OCI VirtualDeploymentspec.serviceDiscovery.hostnameがあるのが不思議な感じがしました。Githubに下記のような記載があるので、そのままVirtualServiceVersionとかでも良かったのではと思っています。(個人の感想です)

A virtual deployment is a version of a virtual service in the mesh.

4
4
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
4
4