Share via


クイックスタート: Azure Operator Service Manager にコンテナー化ネットワーク機能をデプロイするための前提条件を満たす

このクイックスタートでは、Azure Operator Service Manager (AOSM) を使用する前に必要なタスクを完了します。

前提条件

Microsoft アカウント チームに問い合わせて、Azure Operator Service Manager (AOSM) にアクセスするための Azure サブスクリプションを登録するか、パートナー登録フォームを通じて関心を表明してください。

Azure CLI のダウンロードとインストール

Azure Cloud Shell で Bash 環境を使用します。 詳細については、「Cloud Shell を開始する」を参照して Azure Cloud Shell で Bash 環境を使用してください。

CLI リファレンス コマンドをローカルで実行したい場合は、「Azure CLI をインストールする方法」を参照してください。

Windows または macOS で実行している場合は、Docker コンテナーで Azure CLI を実行することを検討してください。 詳細については、「Docker コンテナーで Azure CLI を実行する方法」を参照してください。

ローカル インストールを使用している場合は、az login コマンドを使用して Azure CLI にサインインし、ターミナルに表示されるプロンプトを完了して認証を完了します。 その他のサインイン オプションについては、「Azure CLI を使用してサインインする」を参照してください。

Azure Operator Service Manager (AOSM) CLI 拡張機能をインストールする

次のコマンドを使用して Azure Operator Service Manager (AOSM) CLI 拡張機能をインストールします。

az extension add --name aosm
  1. az version を実行し、インストールされているバージョンおよび依存ライブラリを表示します。
  2. az upgrade を実行し、Azure CLI の現在のバージョンにアップグレードします。

必要なリソース プロバイダーを登録するして検証する

Azure Operator Service Manager の使用を開始する前に、次のコマンドを実行して、必要なリソース プロバイダーを登録します。 登録プロセスには最大 5 分かかる場合があります。

# Register Resource Provider
az provider register --namespace Microsoft.HybridNetwork
az provider register --namespace Microsoft.ContainerRegistry

リソース プロバイダーの登録状態を検証します。 次のコマンドを実行します。

# Query the Resource Provider
az provider show -n Microsoft.HybridNetwork --query "{RegistrationState: registrationState, ProviderName: namespace}"
az provider show -n Microsoft.ContainerRegistry --query "{RegistrationState: registrationState, ProviderName: namespace}"

Note

リソース プロバイダーの登録が完了するまでに数分かかる場合があります。 登録が成功したら、Azure Operator Service Manager (AOSM) の使用を進めることができます。

コンテナー化されたネットワーク機能 (CNF) の要件

コンテナー化されたネットワーク機能を利用する場合は、CLI を実行しているコンピューターに次のパッケージがインストールされていることを確認する必要があります。

コンテナー化されたネットワーク機能 (CNF) のデプロイを構成する

コンテナー化されたネットワーク機能 (CMF) のデプロイでは、CLI を実行するコンピューターに以下を格納することが重要です。

  • Helm パッケージとスキーマ - これらのパッケージがローカル ストレージに存在し、input.json 構成ファイル内で参照されている必要があります。 このクイック スタートに従うときは、必要な helm パッケージをダウンロードしてください。

  • サンプル構成ファイルの作成 - CNF デプロイを定義するためのサンプル構成ファイルを生成します。 このコマンドを発行して、特定の構成を設定する必要がある input.json ファイルを生成します。

    az aosm nfd generate-config --definition-type cnf
    
  • CNF のイメージ - オプションを次に示します。

    • CNF のイメージを含む既存の Azure Container Registry への参照。 現在、CNF ごとにサポートされる ACR と名前空間は 1 つだけです。 この ACR からコピーされるイメージは、helm パッケージのスキーマに基づいて自動的に設定されます。 この ACR に対する閲覧者/AcrPull アクセス許可が必要です。 このオプションを使用するには、source_registry を入力し、必要に応じて input.json ファイルに source_registry_namespace を設定します。
    • ローカル コンピューターからのソース docker イメージのイメージ名。 このイメージ名は、CNF がローカル docker リポジトリに存在する単一の docker イメージのみを必要とする限られたユース ケースが対象となります。 このオプションを使用するには、input.json ファイルに source_local_docker_image を入力します。 docker をインストールする必要があります。 このクイックスタートでは、このオプションに使用する nginx docker イメージをダウンロードする手順について説明します。
  • 省略可能: マッピング ファイル (path_to_mappings): 必要に応じて、path_to_mappings という名前のファイル (ディスク上) を指定できます。 このファイルは、values.yaml をミラーリングし、選択した値をデプロイ パラメーターに置き換える必要があります。 これにより、パラメーターとして CNF に公開されます。 または、input.json でこれを空白のままにすると、CLI によってファイルが生成されます。 この場合、既定では、values.yaml 内のすべての値がデプロイ パラメーターとして公開されます。 または、--interactive CLI 引数を使用して対話形式で選択します。 このクイックスタートでは、このファイルの作成について説明します。

input.json ファイルを構成するときは、デプロイする順序で Helm パッケージをリストするようにしてください。 たとえば、パッケージ "B" の前にパッケージ "A" をデプロイする必要がある場合、input.json は次のような構造になります。

"helm_packages": [
    {
        "name": "A",
        "path_to_chart": "Path to package A",
        "path_to_mappings": "Path to package A mappings",
        "depends_on": [
            "Names of the Helm packages this package depends on"
        ]
    },
    {
        "name": "B",
        "path_to_chart": "Path to package B",
        "path_to_mappings": "Path to package B mappings",
        "depends_on": [
            "Names of the Helm packages this package depends on"
        ]
    }
]

これらのガイドラインに従うと、Helm パッケージと関連する構成を使用してコンテナー化ネットワーク機能 (CNF) をデプロイするための、適切に整理され、構造化されたアプローチを実現できます。

nginx イメージをローカル docker リポジトリにダウンロードする

このクイックスタートでは、nginx docker イメージをローカル リポジトリにダウンロードします。 Azure Operator Service Manager (AOSM) Azure CLI 拡張機能は、そこから Azure Operator Service Manager (AOSM) 成果物ストア ACR にイメージをプッシュします。 CLI 拡張機能では、既存の ACR からのイメージのコピーもサポートされています。 イメージをコピーすることが想定される既定のユース ケースですが、クイック スタートでコピー元の ACR を作成すると時間がかかるため、この方法はここでは使用しません。

次のコマンドを実行します。docker pull nginx:stable

サンプル Helm chart をダウンロードする

このクイック スタートで使用するサンプル Helm chart をここ (サンプル Helm chart) からダウンロードします。

Helm chart に関する詳細

このセクションでは、nginx を設定し、指定されたポートでリッスンするように構成する基本的な Helm chart について説明します。 このセクションで提供されている Helm chart には、既に values.schema.json ファイルが組み込まれています。

values.schema.json ファイルのサンプル

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "additionalProperties": true,
    "properties": {
        "affinity": {
            "additionalProperties": false,
            "properties": {},
            "type": "object"
        },
        "fullnameOverride": {
            "type": "string"
        },
        "image": {
            "additionalProperties": false,
            "properties": {
                "pullPolicy": {
                    "type": "string"
                },
                "repository": {
                    "type": "string"
                },
                "tag": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "imagePullSecrets": {
            "items": {
                "anyOf": []
            },
            "type": "array"
        },
        "ingress": {
            "additionalProperties": false,
            "properties": {
                "annotations": {
                    "additionalProperties": false,
                    "properties": {},
                    "type": "object"
                },
                "enabled": {
                    "type": "boolean"
                },
                "hosts": {
                    "items": {
                        "anyOf": [
                            {
                                "additionalProperties": false,
                                "properties": {
                                    "host": {
                                        "type": "string"
                                    },
                                    "paths": {
                                        "items": {
                                            "anyOf": []
                                        },
                                        "type": "array"
                                    }
                                },
                                "type": "object"
                            }
                        ]
                    },
                    "type": "array"
                },
                "tls": {
                    "items": {
                        "anyOf": []
                    },
                    "type": "array"
                }
            },
            "type": "object"
        },
        "nameOverride": {
            "type": "string"
        },
        "nodeSelector": {
            "additionalProperties": false,
            "properties": {},
            "type": "object"
        },
        "podSecurityContext": {
            "additionalProperties": false,
            "properties": {},
            "type": "object"
        },
        "replicaCount": {
            "type": "integer"
        },
        "resources": {
            "additionalProperties": false,
            "properties": {},
            "type": "object"
        },
        "securityContext": {
            "additionalProperties": false,
            "properties": {},
            "type": "object"
        },
        "service": {
            "additionalProperties": false,
            "properties": {
                "port": {
                    "type": "integer"
                },
                "type": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "serviceAccount": {
            "additionalProperties": false,
            "properties": {
                "create": {
                    "type": "boolean"
                },
                "name": {
                    "type": "null"
                }
            },
            "type": "object"
        },
        "tolerations": {
            "items": {
                "anyOf": []
            },
            "type": "array"
        }
    },
    "type": "object"
}

この記事では Helm の複雑さを掘り下げて説明しませんが、注目すべきいくつかの要素を次に示します。

  • サービス ポートの構成:values.yaml には、サービス ポート 80 が事前設定されています。

values.yaml ファイルのサンプル

# Default values for nginxdemo. 
# This is a YAML-formatted file. 
# Declare variables to be passed into your templates. 

 
replicaCount: 1 
 

image: 

  # Repository gets overwritten by AOSM to the Artifact Store ACR, however we've hard-coded the image name and tag in deployment.yaml 

  repository: overwriteme 
  tag: stable 
  pullPolicy: IfNotPresent 


imagePullSecrets: [] 
nameOverride: "" 
fullnameOverride: "" 

 
serviceAccount: 

  # Specifies whether a service account should be created 

  create: false 

  # The name of the service account to use. 
  # If not set and create is true, a name is generated using the fullname template 

  name: 
 

podSecurityContext: 

  {} 

  # fsGroup: 2000 

 
securityContext: 

  {} 
  # capabilities: 
  #   drop: 
  #   - ALL 
  # readOnlyRootFilesystem: true 
  # runAsNonRoot: true 
  # runAsUser: 1000 

 
service: 

  type: ClusterIP 
  port: 80 

  
ingress: 

  enabled: false 
  annotations: 

    {} 

    # kubernetes.io/ingress.class: nginx 
    # kubernetes.io/tls-acme: "true" 

  hosts: 

    - host: chart-example.local 
      paths: [] 

  
  tls: [] 

  #  - secretName: chart-example-tls 
  #    hosts: 
  #      - chart-example.local 

 
resources: 

  {} 

  # We usually recommend not to specify default resources and to leave this as a conscious 
  # choice for the user. This also increases chances charts run on environments with little 
  # resources, such as Minikube. If you do want to specify resources, uncomment the following 
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'. 
  # limits: 
  #   cpu: 100m 
  #   memory: 128Mi 
  # requests: 
  #   cpu: 100m 
  #   memory: 128Mi 
 

nodeSelector: {} 

 
tolerations: [] 

 
affinity: {}
  • ポート参照: このポートは、複数の場所で使用されます。

    • service.yaml 内で {{ Values.service.port }} として

service.yaml ファイルのサンプル

apiVersion: v1 
kind: Service 

metadata: 
  name: {{ include "nginxdemo.fullname" . }} 
  labels: 

{{ include "nginxdemo.labels" . | indent 4 }} 

spec: 
  type: {{ .Values.service.type }} 
  ports: 
    - port: {{ .Values.service.port }} 
      targetPort: http 
      protocol: TCP 
      name: http 

  selector: 
    app.kubernetes.io/name: {{ include "nginxdemo.name" . }} 
    app.kubernetes.io/instance: {{ .Release.Name }}
  • nginx_config_map.yaml{{ Values.service.port }} として表現されます。 このファイルは /etc/nginx/conf.d/default.conf に対応し、deployment.yaml の構成マップを使用してマッピングが確立されます。

nginx_config_map.yaml ファイルのサンプル

apiVersion: v1 
kind: ConfigMap 
metadata: 
  name: nginx-config 
# This writes the nginx config file to the ConfigMap and deployment.yaml mounts it as a volume  
# to the right place. 

data: 
  default.conf: | 
    log_format client '$remote_addr - $remote_user $request_time $upstream_response_time ' 
                    '[$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" ' 
                    '"$http_user_agent" "$http_x_forwarded_for"'; 

    server { 
        listen       80; 
        listen       {{ .Values.service.port }}; 
        listen  [::]:80; 
        server_name  localhost; 

        access_log  /var/log/nginx/host.access.log  client; 

        location / { 
            root   /usr/share/nginx/html; 
            index  index.html index.htm; 
            error_page 405 =200 $uri; 
        } 


        #error_page  404              /404.html; 
        # redirect server error pages to the static page /50x.html 
        # 
        error_page   500 502 503 504  /50x.html; 
        location = /50x.html { 
            root   /usr/share/nginx/html; 
        } 


        location = /cnf/test {   
            error_page 405 =200 $uri; 
        } 
   

        location = /post_thing { 
            # turn off logging here to avoid double logging 
            access_log off; 
            error_page 405 =200 $uri; 
        } 
    }

デプロイの構成:deployment.yaml ファイルには、imagePullSecretsimage に関連する特定の行が示されます。 デプロイ時に Azure Operator Service Manager (AOSM) がこれらのフィールドに必要な値を提供するため、その構造化された形式を確認してください。 詳細については、「Helm パッケージの要件」を参照してください。

deployment.yaml ファイルのサンプル

apiVersion: apps/v1 
kind: Deployment 
metadata: 
  name: {{ include "nginxdemo.fullname" . }} 
  labels: 
{{ include "nginxdemo.labels" . | indent 4 }} 

spec: 
  replicas: {{ .Values.replicaCount }} 
  selector: 
    matchLabels: 
      app.kubernetes.io/name: {{ include "nginxdemo.name" . }} 
      app.kubernetes.io/instance: {{ .Release.Name }} 

  template: 
    metadata: 
      labels: 
        app.kubernetes.io/name: {{ include "nginxdemo.name" . }} 
        app.kubernetes.io/instance: {{ .Release.Name }} 

    spec: 
      # Copied from sas 
      imagePullSecrets: {{ mustToPrettyJson (ternary (list ) .Values.imagePullSecrets (kindIs "invalid" .Values.imagePullSecrets)) }} 
      serviceAccountName: {{ template "nginxdemo.serviceAccountName" . }} 
      securityContext: 
        {{- toYaml .Values.podSecurityContext | nindent 8 }} 
      containers: 
        - name: {{ .Chart.Name }} 
          securityContext: 
            {{- toYaml .Values.securityContext | nindent 12 }} 
          # Want this to evaluate to acr-name.azurecr.io/nginx:stable (or specific version) 
          # docker tag nginx:stable acr-name.azurecr.io/nginx:stable 
          # docker push acr-name.azurecr.io/nginx:stable 
          # Image hard coded to that put in the Artifact Store ACR for this CNF POC 
          image: "{{ .Values.image.repository }}/nginx:stable" 
          imagePullPolicy: {{ .Values.image.pullPolicy }} 
          ports: 
            - name: http 
              containerPort: 80 
              protocol: TCP 
          livenessProbe: 
            httpGet: 
              path: / 
              port: http 
          readinessProbe: 
            httpGet: 
              path: / 
              port: http 
          resources: 
            {{- toYaml .Values.resources | nindent 12 }} 
          # Gets the nginx config from the configMap - see nginx_config_map.yaml 
          volumeMounts: 
            - name: nginx-config-volume 
              mountPath: /etc/nginx/conf.d/default.conf 
              subPath: default.conf 
      volumes: 
        - name: nginx-config-volume 
          configMap: 
            name: nginx-config 
      {{- with .Values.nodeSelector }} 
      nodeSelector: 
        {{- toYaml . | nindent 8 }} 
      {{- end }} 
    {{- with .Values.affinity }} 
      affinity: 
        {{- toYaml . | nindent 8 }} 
    {{- end }} 
    {{- with .Values.tolerations }} 
      tolerations: 
        {{- toYaml . | nindent 8 }} 
    {{- end }}

次のステップ