5.3. SCTP (Stream Control Transmission Protocol) が有効になっていることの確認

SCTP がクラスターで機能することを確認するには、SCTP トラフィックをリッスンするアプリケーションで Pod を作成し、これをサービスに関連付け、公開されたサービスに接続します。

前提条件

  • クラスターからインターネットにアクセスし、nc パッケージをインストールすること。
  • OpenShift CLI (oc) をインストールします。
  • cluster-admin ロールを持つユーザーとしてクラスターにアクセスできる。

手順

  1. SCTP リスナーを起動する Pod を作成します。

    1. 以下の YAML で Pod を定義する sctp-server.yaml という名前のファイルを作成します。

      apiVersion: v1
      kind: Pod
      metadata:
        name: sctpserver
        labels:
          app: sctpserver
      spec:
        containers:
          - name: sctpserver
            image: registry.access.redhat.com/ubi8/ubi
            command: ["/bin/sh", "-c"]
            args:
              ["dnf install -y nc && sleep inf"]
            ports:
              - containerPort: 30102
                name: sctpserver
                protocol: SCTP
    2. 以下のコマンドを入力して Pod を作成します。

      $ oc create -f sctp-server.yaml
  2. SCTP リスナー Pod のサービスを作成します。

    1. 以下の YAML でサービスを定義する sctp-service.yaml という名前のファイルを作成します。

      apiVersion: v1
      kind: Service
      metadata:
        name: sctpservice
        labels:
          app: sctpserver
      spec:
        type: NodePort
        selector:
          app: sctpserver
        ports:
          - name: sctpserver
            protocol: SCTP
            port: 30102
            targetPort: 30102
    2. サービスを作成するには、以下のコマンドを入力します。

      $ oc create -f sctp-service.yaml
  3. SCTP クライアントの Pod を作成します。

    1. 以下の YAML で sctp-client.yaml という名前のファイルを作成します。

      apiVersion: v1
      kind: Pod
      metadata:
        name: sctpclient
        labels:
          app: sctpclient
      spec:
        containers:
          - name: sctpclient
            image: registry.access.redhat.com/ubi8/ubi
            command: ["/bin/sh", "-c"]
            args:
              ["dnf install -y nc && sleep inf"]
    2. Pod オブジェクトを作成するには、以下のコマンドを入力します。

      $ oc apply -f sctp-client.yaml
  4. サーバーで SCTP リスナーを実行します。

    1. サーバー Pod に接続するには、以下のコマンドを入力します。

      $ oc rsh sctpserver
    2. SCTP リスナーを起動するには、以下のコマンドを入力します。

      $ nc -l 30102 --sctp
  5. サーバーの SCTP リスナーに接続します。

    1. ターミナルプログラムで新規のターミナルウィンドウまたはタブを開きます。
    2. sctpservice サービスの IP アドレスを取得します。以下のコマンドを入力します。

      $ oc get services sctpservice -o go-template='{{.spec.clusterIP}}{{"\n"}}'
    3. クライアント Pod に接続するには、以下のコマンドを入力します。

      $ oc rsh sctpclient
    4. SCTP クライアントを起動するには、以下のコマンドを入力します。<cluster_IP>sctpservice サービスのクラスター IP アドレスに置き換えます。

      # nc <cluster_IP> 30102 --sctp