本文へジャンプします。

【重要なお知らせ】サービス統合に基づくサービス名称の読み替えのお願い(2024年4月1日)

2024年4月1日をもって、「ニフクラ」は、「FJcloud-V」に統合し、名称を変更しました。
当サイトのアドレス(ドメイン名)に含まれる「nifcloud.com」は現時点では変更はございませんが、
各ページに記載の「ニフクラ」「NIFCLOUD」「nifcloud」は、「FJcloud-V」に読み替えていただきますようお願いいたします。

ニフクラ ユーザーガイド

クラウド トップ>Catalog>ユーザーガイド>Anthos(GKE Enterprise) Anthos Service Meshを利用する

Anthos(GKE Enterprise):Anthos Service Meshを利用する

Anthos Service Meshを利用する手順を説明します。

ステップ1:Anthos Service Meshを有効にしてクラスターを作成

本手順では、管理クラスターでAnthos Service Meshを利用する方法を説明します。ユーザークラスターでも同様の手順で利用できます。

  1. コントロールパネルにログインし、Catalogのダッシュボードへ移動します。

  2. リソースグループを作成します。 リソースグループの作成方法は以下を確認してください。
    Anthos(GKE Enterprise):クイックスタート ステップ4:リソースグループ作成

  3. 作成したリソースグループに対してAnthos Service Meshを有効にし、Anthos Service Meshバージョンを指定して、クラスターの初期設定を行います。

    初期設定

  4. 設定完了までしばらく待ちます。

ステップ2:Namespaceの作成

  1. 管理ワークステーションにSSHログインします。

  2. アプリケーション用Namespaceのyaml作成します。

    下記のような namespace.yaml を作成します。

    apiVersion: v1
    kind: Namespace
    metadata:
      name: sample
  3. Namespaceのyamlを適用します。

    作成した namespace.yaml をクラスターに適用します。

    $ kubectl apply -f namespace.yaml

ステップ3:自動サイドカーインジェクションの有効化

自動サイドカーインジェクションを有効にします。詳細は、Google Cloud: 自動サイドカー インジェクションを有効にする を参考にしてください。

  1. クラスターで利用中のAnthos Service Meshバージョンに対応する istiod のリビジョンラベルを出力します。

    $ kubectl get deploy -n istio-system -l app=istiod -o \
      jsonpath={.items[*].metadata.labels.'istio\.io\/rev'}'{"\n"}'
  2. アプリケーションの名前空間にリビジョンラベルを適用します。REVISION には前の手順で出力した istiod のリビジョンラベルの値を指定します。

    $ kubectl label namespace sample istio.io/rev=<REVISION> --overwrite

ステップ4:Deploymentの作成

  1. アプリケーション用Deploymentのyaml作成します。

    下記のような deployment.yaml を作成します。下記の例は「Hello Kubernetes!」を返却するだけのシンプルなアプリケーションです。

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: hello
      namespace: sample
    spec:
      selector:
        matchLabels:
          run: hello
      replicas: 3
      template:
        metadata:
          labels:
            run: hello
        spec:
          containers:
          - name: hello
            image: gcr.io/google-samples/node-hello:1.0
            ports:
            - containerPort: 8080
  2. Deploymentのyamlを適用します。

    作成した deployment.yaml をクラスターに適用します。

    $ kubectl apply -f deployment.yaml
  3. Podの動作を確認します。

    下記で適用したアプリケーションのPodのSTATUSが、Runningになることを確認します。

    $ kubectl get pod -n sample
    NAME                     READY   STATUS    RESTARTS   AGE
    hello-5c74f54cf7-4769h   2/2     Running   0          14s
    hello-5c74f54cf7-fjhzz   2/2     Running   0          14s
    hello-5c74f54cf7-n2xsd   2/2     Running   0          14s

ステップ5:Serviceの作成

  1. type: ClusterIP のServiceのyamlを作成します。

    アプリケーションへのアクセスを管理するために、下記のような service.yaml を作成します。

    apiVersion: v1
    kind: Service
    metadata:
      name: hello
      namespace: sample
    spec:
      type: ClusterIP
      selector:
        run: hello
      ports:
      - name: http
        port: 80
        targetPort: 8080
  2. Serviceのyamlを適用します。

    作成した service.yaml を適用します。

    $ kubectl apply -f service.yaml
  3. Serviceを確認します。

    下記で作成したServiceの情報が確認できます。

    $ kubectl get service -n sample
    NAME    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
    hello   ClusterIP   172.16.130.202   <none>        80/TCP    20s

ステップ6:Serviceにアクセス

  1. アプリケーションの動作を確認します。

    $ kubectl run curl --image=curlimages/curl -it --rm -- sh
    $ curl hello.sample.svc
    Hello Kubernetes!


アンケート
アンケートにご協力を
  • ※本ページ記載の金額は、すべて税抜表示です。
  • ※本ページ記載の他社製品名および会社名などは、各社の商標または登録商標です。
  • ※本ページの内容は、2024年8月29日時点の情報です。

推奨画面サイズ 1024×768 以上