Kubernetes@1 - Kubectl v1 タスク

kubectl コマンドを実行して、Azure Container Service で Kubernetes クラスターをデプロイ、構成、更新します。

kubectl コマンドを実行して、Azure Container Service で Kubernetes クラスターをデプロイ、構成、更新します。

構文

# Kubectl v1
# Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands.
- task: Kubernetes@1
  inputs:
  # Kubernetes Cluster
    #connectionType: 'Kubernetes Service Connection' # 'Azure Resource Manager' | 'Kubernetes Service Connection' | 'None'. Required when command != logout. Service connection type. Default: Kubernetes Service Connection.
    #kubernetesServiceEndpoint: # string. Required when connectionType = Kubernetes Service Connection && command != logout. Kubernetes service connection. 
    #azureSubscriptionEndpoint: # string. Required when connectionType = Azure Resource Manager && command != logout. Azure subscription. 
    #azureResourceGroup: # string. Required when connectionType = Azure Resource Manager && command != logout. Resource group. 
    #kubernetesCluster: # string. Required when connectionType = Azure Resource Manager && command != logout. Kubernetes cluster. 
    #useClusterAdmin: false # boolean. Optional. Use when connectionType = Azure Resource Manager && command != logout. Use cluster admin credentials. Default: false.
    #namespace: # string. Optional. Use when command != logout. Namespace. 
  # Commands
    #command: # 'apply' | 'create' | 'delete' | 'exec' | 'expose' | 'get' | 'login' | 'logout' | 'logs' | 'run' | 'set' | 'top'. Command. 
    #useConfigurationFile: false # boolean. Optional. Use when command != login && command != logout. Use configuration. Default: false.
    #configurationType: 'configuration' # 'configuration' | 'inline'. Optional. Use when useConfigurationFile = true. Configuration type. Default: configuration.
    configuration: # string. Required when configurationType = configuration. File path. 
    #inline: # string. Required when configurationType = inline. Inline configuration. 
    #arguments: # string. Optional. Use when command != login && command != logout. Arguments. 
  # Secrets
    #secretType: 'dockerRegistry' # 'dockerRegistry' | 'generic'. Required when command != login && command != logout. Type of secret. Default: dockerRegistry.
    #secretArguments: # string. Optional. Use when secretType = generic && command != login && command != logout. Arguments. 
    #containerRegistryType: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when secretType = dockerRegistry && command != login && command != logout. Container registry type. Default: Azure Container Registry.
    #dockerRegistryEndpoint: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Container Registry && command != login && command != logout. Docker registry service connection. 
    #azureSubscriptionEndpointForSecrets: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure container registry. 
    #secretName: # string. Optional. Use when command != login && command != logout. Secret name. 
    #forceUpdate: true # boolean. Optional. Use when command != login && command != logout. Force update secret. Default: true.
  # ConfigMaps
    #configMapName: # string. Optional. Use when command != login && command != logout. ConfigMap name. 
    #forceUpdateConfigMap: false # boolean. Optional. Use when command != login && command != logout. Force update configmap. Default: false.
    #useConfigMapFile: false # boolean. Optional. Use when command != login && command != logout. Use file. Default: false.
    #configMapFile: # string. Required when useConfigMapFile = true && command != login && command != logout. ConfigMap file. 
    #configMapArguments: # string. Optional. Use when useConfigMapFile = false && command != login && command != logout. Arguments. 
  # Advanced
    #versionOrLocation: 'version' # 'version' | 'location'. Kubectl. Default: version.
    #versionSpec: '1.13.2' # string. Optional. Use when versionOrLocation = version. Version spec. Default: 1.13.2.
    #checkLatest: false # boolean. Optional. Use when versionOrLocation = version. Check for latest version. Default: false.
    #specifyLocation: # string. Required when versionOrLocation = location. Path to kubectl. 
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working directory. Default: $(System.DefaultWorkingDirectory).
    #outputFormat: 'json' # 'json' | 'yaml' | 'none'. Output format. Default: json.
# Kubectl v1
# Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands.
- task: Kubernetes@1
  inputs:
  # Kubernetes Cluster
    #connectionType: 'Kubernetes Service Connection' # 'Azure Resource Manager' | 'Kubernetes Service Connection' | 'None'. Required when command != logout. Service connection type. Default: Kubernetes Service Connection.
    #kubernetesServiceEndpoint: # string. Required when connectionType = Kubernetes Service Connection && command != logout. Kubernetes service connection. 
    #azureSubscriptionEndpoint: # string. Required when connectionType = Azure Resource Manager && command != logout. Azure subscription. 
    #azureResourceGroup: # string. Required when connectionType = Azure Resource Manager && command != logout. Resource group. 
    #kubernetesCluster: # string. Required when connectionType = Azure Resource Manager && command != logout. Kubernetes cluster. 
    #useClusterAdmin: false # boolean. Optional. Use when connectionType = Azure Resource Manager && command != logout. Use cluster admin credentials. Default: false.
    #namespace: # string. Optional. Use when command != logout. Namespace. 
  # Commands
    #command: # 'apply' | 'create' | 'delete' | 'exec' | 'expose' | 'get' | 'login' | 'logout' | 'logs' | 'run' | 'set' | 'top'. Command. 
    #useConfigurationFile: false # boolean. Optional. Use when command != login && command != logout. Use configuration. Default: false.
    #configurationType: 'configuration' # 'configuration' | 'inline'. Optional. Use when useConfigurationFile = true. Configuration type. Default: configuration.
    configuration: # string. Required when configurationType = configuration. File path. 
    #inline: # string. Required when configurationType = inline. Inline configuration. 
    #arguments: # string. Optional. Use when command != login && command != logout. Arguments. 
  # Secrets
    #secretType: 'dockerRegistry' # 'dockerRegistry' | 'generic'. Required when command != login && command != logout. Type of secret. Default: dockerRegistry.
    #secretArguments: # string. Optional. Use when secretType = generic && command != login && command != logout. Arguments. 
    #containerRegistryType: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when secretType = dockerRegistry && command != login && command != logout. Container registry type. Default: Azure Container Registry.
    #dockerRegistryEndpoint: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Container Registry && command != login && command != logout. Docker registry service connection. 
    #azureSubscriptionEndpointForSecrets: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure container registry. 
    #secretName: # string. Optional. Use when command != login && command != logout. Secret name. 
    #forceUpdate: true # boolean. Optional. Use when command != login && command != logout. Force update secret. Default: true.
  # ConfigMaps
    #configMapName: # string. Optional. Use when command != login && command != logout. ConfigMap name. 
    #forceUpdateConfigMap: false # boolean. Optional. Use when command != login && command != logout. Force update configmap. Default: false.
    #useConfigMapFile: false # boolean. Optional. Use when command != login && command != logout. Use file. Default: false.
    #configMapFile: # string. Required when useConfigMapFile = true && command != login && command != logout. ConfigMap file. 
    #configMapArguments: # string. Optional. Use when useConfigMapFile = false && command != login && command != logout. Arguments. 
  # Advanced
    #versionOrLocation: 'version' # 'version' | 'location'. Kubectl. Default: version.
    #versionSpec: '1.13.2' # string. Optional. Use when versionOrLocation = version. Version spec. Default: 1.13.2.
    #checkLatest: false # boolean. Optional. Use when versionOrLocation = version. Check for latest version. Default: false.
    #specifyLocation: # string. Required when versionOrLocation = location. Path to kubectl. 
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working directory. Default: $(System.DefaultWorkingDirectory).
    #outputFormat: 'json' # 'json' | 'yaml'. Output format. Default: json.
# Deploy to Kubernetes v1
# Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands.
- task: Kubernetes@1
  inputs:
  # Kubernetes Cluster
    #connectionType: 'Kubernetes Service Connection' # 'Azure Resource Manager' | 'Kubernetes Service Connection' | 'None'. Required when command != logout. Service connection type. Default: Kubernetes Service Connection.
    #kubernetesServiceEndpoint: # string. Required when connectionType = Kubernetes Service Connection && command != logout. Kubernetes service connection. 
    #azureSubscriptionEndpoint: # string. Required when connectionType = Azure Resource Manager && command != logout. Azure subscription. 
    #azureResourceGroup: # string. Required when connectionType = Azure Resource Manager && command != logout. Resource group. 
    #kubernetesCluster: # string. Required when connectionType = Azure Resource Manager && command != logout. Kubernetes cluster. 
    #useClusterAdmin: false # boolean. Optional. Use when connectionType = Azure Resource Manager && command != logout. Use cluster admin credentials. Default: false.
    #namespace: # string. Optional. Use when command != logout. Namespace. 
  # Commands
    #command: # 'apply' | 'create' | 'delete' | 'exec' | 'expose' | 'get' | 'login' | 'logout' | 'logs' | 'run' | 'set' | 'top'. Command. 
    #useConfigurationFile: false # boolean. Optional. Use when command != login && command != logout. Use configuration. Default: false.
    #configurationType: 'configuration' # 'configuration' | 'inline'. Optional. Use when useConfigurationFile = true. Configuration type. Default: configuration.
    configuration: # string. Required when configurationType = configuration. File path. 
    #inline: # string. Required when configurationType = inline. Inline configuration. 
    #arguments: # string. Optional. Use when command != login && command != logout. Arguments. 
  # Secrets
    #secretType: 'dockerRegistry' # 'dockerRegistry' | 'generic'. Required when command != login && command != logout. Type of secret. Default: dockerRegistry.
    #secretArguments: # string. Optional. Use when secretType = generic && command != login && command != logout. Arguments. 
    #containerRegistryType: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when secretType = dockerRegistry && command != login && command != logout. Container registry type. Default: Azure Container Registry.
    #dockerRegistryEndpoint: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Container Registry && command != login && command != logout. Docker registry service connection. 
    #azureSubscriptionEndpointForSecrets: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure container registry. 
    #secretName: # string. Optional. Use when command != login && command != logout. Secret name. 
    #forceUpdate: true # boolean. Optional. Use when command != login && command != logout. Force update secret. Default: true.
  # ConfigMaps
    #configMapName: # string. Optional. Use when command != login && command != logout. ConfigMap name. 
    #forceUpdateConfigMap: false # boolean. Optional. Use when command != login && command != logout. Force update configmap. Default: false.
    #useConfigMapFile: false # boolean. Optional. Use when command != login && command != logout. Use file. Default: false.
    #configMapFile: # string. Required when useConfigMapFile = true && command != login && command != logout. ConfigMap file. 
    #configMapArguments: # string. Optional. Use when useConfigMapFile = false && command != login && command != logout. Arguments. 
  # Advanced
    #versionOrLocation: 'version' # 'version' | 'location'. Kubectl. Default: version.
    #versionSpec: '1.13.2' # string. Optional. Use when versionOrLocation = version. Version spec. Default: 1.13.2.
    #checkLatest: false # boolean. Optional. Use when versionOrLocation = version. Check for latest version. Default: false.
    #specifyLocation: # string. Required when versionOrLocation = location. Path to kubectl. 
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working directory. Default: $(System.DefaultWorkingDirectory).
    #outputFormat: 'json' # 'json' | 'yaml'. Output format. Default: json.
# Deploy to Kubernetes v1
# Deploy, configure, update your Kubernetes cluster in Azure Container Service by running kubectl commands.
- task: Kubernetes@1
  inputs:
  # Kubernetes Cluster
    #connectionType: 'Azure Resource Manager' # 'Azure Resource Manager' | 'Kubernetes Service Connection' | 'None'. Required when command != logout. Service connection type. Default: Azure Resource Manager.
    #kubernetesServiceEndpoint: # string. Required when connectionType = Kubernetes Service Connection && command != logout. Kubernetes service connection. 
    #azureSubscriptionEndpoint: # string. Required when connectionType = Azure Resource Manager && command != logout. Azure subscription. 
    #azureResourceGroup: # string. Required when connectionType = Azure Resource Manager && command != logout. Resource group. 
    #kubernetesCluster: # string. Required when connectionType = Azure Resource Manager && command != logout. Kubernetes cluster. 
    #namespace: # string. Optional. Use when command != logout. Namespace. 
  # Commands
    command: 'apply' # 'apply' | 'create' | 'delete' | 'exec' | 'expose' | 'get' | 'login' | 'logout' | 'logs' | 'run' | 'set' | 'top'. Required. Command. Default: apply.
    #useConfigurationFile: false # boolean. Optional. Use when command != login && command != logout. Use configuration files. Default: false.
    #configuration: # string. Required when useConfigurationFile = true. Configuration file. 
    #arguments: # string. Optional. Use when command != login && command != logout. Arguments. 
  # Secrets
    #secretType: 'dockerRegistry' # 'dockerRegistry' | 'generic'. Required when command != login && command != logout. Type of secret. Default: dockerRegistry.
    #secretArguments: # string. Optional. Use when secretType = generic && command != login && command != logout. Arguments. 
    #containerRegistryType: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when secretType = dockerRegistry && command != login && command != logout. Container registry type. Default: Azure Container Registry.
    #dockerRegistryEndpoint: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Container Registry && command != login && command != logout. Docker registry service connection. 
    #azureSubscriptionEndpointForSecrets: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout. Azure container registry. 
    #secretName: # string. Optional. Use when command != login && command != logout. Secret name. 
    #forceUpdate: true # boolean. Optional. Use when command != login && command != logout. Force update secret. Default: true.
  # ConfigMaps
    #configMapName: # string. Optional. Use when command != login && command != logout. ConfigMap name. 
    #forceUpdateConfigMap: false # boolean. Optional. Use when command != login && command != logout. Force update configmap. Default: false.
    #useConfigMapFile: false # boolean. Optional. Use when command != login && command != logout. Use file. Default: false.
    #configMapFile: # string. Required when useConfigMapFile = true && command != login && command != logout. ConfigMap file. 
    #configMapArguments: # string. Optional. Use when useConfigMapFile = false && command != login && command != logout. Arguments. 
  # Advanced
    #versionOrLocation: 'version' # 'version' | 'location'. Optional. Use when command != login && command != logout. Kubectl. Default: version.
    #versionSpec: '1.7.0' # string. Optional. Use when versionOrLocation = version && command != login && command != logout. Version spec. Default: 1.7.0.
    #checkLatest: false # boolean. Optional. Use when versionOrLocation = version && command != login && command != logout. Check for latest version. Default: false.
    #specifyLocation: # string. Required when versionOrLocation = location && command != login && command != logout. Path to kubectl. 
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Optional. Use when command != login && command != logout. Working directory. Default: $(System.DefaultWorkingDirectory).
    #outputFormat: 'json' # 'json' | 'yaml'. Optional. Use when command != login && command != logout. Output format. Default: json.

入力

connectionType - サービス接続の種類
string. command != logout の場合に必要です。 許可値: Azure Resource ManagerKubernetes Service ConnectionNone。 既定値: Kubernetes Service Connection

サービス接続の種類を指定します。他のクラスターに対して Azure Kubernetes Service または Kubernetes Service Connection を使用する場合の Azure Resource Manager。

  • Kubernetes Service Connection - KubeConfig ファイルを指定したり、サービス アカウントを指定したり、 Azure サブスクリプション オプションを使用して AKS インスタンスをインポートしたりできます。 Azure サブスクリプション オプションを使用して AKS インスタンスをインポートするには、サービス接続構成時に Kubernetes クラスターへのアクセスが必要です。
  • Azure Resource Manager - AKS インスタンスを選択できます。 サービス接続の構成時に Kubernetes クラスターにアクセスしません。
  • None - ローカルに格納されている事前に作成された Kubernetes 構成を使用します。

詳細については、次の「解説」セクションの「サービス接続」を参照してください。


connectionType - サービス接続の種類
string. command != logout の場合に必要です。 許可値: Azure Resource ManagerKubernetes Service ConnectionNone。 既定値: Azure Resource Manager

サービス接続の種類を指定します。他のクラスターに対して Azure Kubernetes Service または Kubernetes Service Connection を使用する場合の Azure Resource Manager。


kubernetesServiceEndpoint - Kubernetes サービス接続
string. connectionType = Kubernetes Service Connection && command != logout の場合に必要です。

Kubernetes サービス接続を選択します。


azureSubscriptionEndpoint - Azure サブスクリプション
string. connectionType = Azure Resource Manager && command != logout の場合に必要です。

Azure Container Registryを含む Azure Resource Manager サブスクリプションを指定します。

注意

新しいサービス接続を構成するには、一覧から Azure サブスクリプションを指定し、 をクリックします Authorize。 サブスクリプションが一覧にない場合、または既存のサービス プリンシパルを使用する場合は、 または Manage ボタンを使用して Azure サービス接続をAdd設定できます。


azureResourceGroup - リソース グループ
string. connectionType = Azure Resource Manager && command != logout の場合に必要です。

Azure リソース グループを選択します。


kubernetesCluster - Kubernetes クラスター
string. connectionType = Azure Resource Manager && command != logout の場合に必要です。

Azure マネージド クラスターを選択します。


useClusterAdmin - クラスター管理者の資格情報を使用する
boolean. 省略可能。 の場合は connectionType = Azure Resource Manager && command != logoutを使用します。 既定値: false

既定のクラスター ユーザー資格情報ではなく、クラスター管理者の資格情報を使用します。


namespace - 名前 空間
string. 省略可能。 の場合は command != logoutを使用します。

–namespace フラグを使用して、kubectl コマンドの名前空間を設定します。 名前空間が指定されていない場合、コマンドは既定の名前空間で実行されます。


command - コマンド
string. 使用できる値: apply、、、delete、、exec、、exposegetloginsetruntoplogoutlogscreate

実行する kubectl コマンドを選択または指定します。 許可される値の一覧には、タスク アシスタントを使用する場合の選択を容易にするための一般的な選択肢がいくつかありますが、 などのscaleの kubectl コマンドを指定することもできます。 入力を使用して、 arguments 指定したコマンドに追加のパラメーターを指定 kubectl します。


command - コマンド
string. 必須です。 使用できる値: apply、、、delete、、exec、、exposegetloginsetruntoplogoutlogscreate 既定値: apply

実行する kubectl コマンドを選択または指定します。


useConfigurationFile - 構成を使用する
boolean. 省略可能。 の場合は command != login && command != logoutを使用します。 既定値: false

コマンドで使用する Kubernetes 構成を kubectl 指定します。 インライン スクリプト、ファイル名、ディレクトリ、または Kubernetes 構成ファイルの URL を指定できます。


useConfigurationFile - 構成ファイルを使用する
boolean. 省略可能。 の場合は command != login && command != logoutを使用します。 既定値: false

コマンドで使用する Kubernetes 構成を kubectl 指定します。 インライン スクリプト、ファイル名、ディレクトリ、または Kubernetes 構成ファイルの URL を指定できます。


configurationType - 構成の種類
string. 省略可能。 の場合は useConfigurationFile = trueを使用します。 使用できる値: configuration (ファイル パス)、 inline (インライン構成)。 既定値: configuration

コマンドの Kubernetes 構成の種類を kubectl 指定します。 ファイル パスまたはインライン スクリプトを指定できます。


configuration - ファイル パス
string. configurationType = configuration の場合に必要です。

コマンドで使用される kubernetes 構成ファイルのファイル名、ディレクトリ、または URL を指定します。


configuration - 構成ファイル
string. useConfigurationFile = true の場合に必要です。

コマンドで使用される kubernetes 構成ファイルのファイル名、ディレクトリ、または URL を指定します。


inline - インライン構成
string. configurationType = inline の場合に必要です。

コマンドのインライン 展開構成を kubectl 指定します。


arguments - 引数
string. 省略可能。 の場合は command != login && command != logoutを使用します。

指定した kubectl コマンドの引数。


secretType - シークレットの種類
string. command != login && command != logout の場合に必要です。 使用できる値: dockerRegistrygeneric。 既定値: dockerRegistry

汎用または docker imagepullsecret を作成または更新します。 dockerRegistry を選択して、選択したレジストリの imagepullsecret を作成または更新します。 imagePullSecret は、コンテナー レジストリ パスワードを含むシークレットを Kubelet に渡して、ポッドに代わってプライベート イメージをプルできるようにする方法です。


secretArguments - 引数
string. 省略可能。 の場合は secretType = generic && command != login && command != logoutを使用します。

シークレットに挿入するキーとリテラル値を指定します。 たとえば、 --from-literal=key1=value1--from-literal=key2="top secret"です。


containerRegistryType - コンテナー レジストリの種類
string. secretType = dockerRegistry && command != login && command != logout の場合に必要です。 使用できる値: Azure Container RegistryContainer Registry。 既定値: Azure Container Registry

コンテナー レジストリの種類を選択します。 このタスクでは、Azure サブスクリプションの詳細を使用して、Azure Container Registry を操作できます。 その他の標準コンテナー レジストリもサポートされています。


dockerRegistryEndpoint - Docker レジストリ サービス接続
string. 省略可能。 の場合は secretType = dockerRegistry && containerRegistryType = Container Registry && command != login && command != logoutを使用します。

Docker レジストリ サービス接続を選択します。 レジストリで認証する必要があるコマンドでは必須です。


azureSubscriptionEndpointForSecrets - Azure サブスクリプション
string. 省略可能。 の場合は secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logoutを使用します。

Azure Container Registryを含む Azure Resource Manager サブスクリプションを指定します。

注意

新しいサービス接続を構成するには、一覧から Azure サブスクリプションを選択し、 をクリックします Authorize。 サブスクリプションが一覧にない場合、または既存のサービス プリンシパルを使用する場合は、 または Manage ボタンを使用して Azure サービス接続をAdd設定できます。


azureContainerRegistry - Azure コンテナー レジストリ
string. 省略可能。 の場合は secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logoutを使用します。

コンテナー イメージをプルし、アプリケーションを Kubernetes クラスターにデプロイするために使用するAzure Container Registryを指定します。 レジストリで認証する必要があるコマンドでは必須です。


secretName - シークレット名
string. 省略可能。 の場合は command != login && command != logoutを使用します。

シークレットの名前。 このシークレット名は、Kubernetes YAML 構成ファイルで使用できます。


forceUpdate - シークレットを強制的に更新する
boolean. 省略可能。 の場合は command != login && command != logoutを使用します。 既定値: true

シークレットが存在する場合は削除し、更新された値を含む新しいシークレットを作成します。


configMapName - ConfigMap 名
string. 省略可能。 の場合は command != login && command != logoutを使用します。

ConfigMaps を使用すると、イメージ コンテンツから構成成果物を切り離して、コンテナー化されたアプリケーションを移植可能に保つことができます。


forceUpdateConfigMap - configmap を強制的に更新する
boolean. 省略可能。 の場合は command != login && command != logoutを使用します。 既定値: false

configmap が存在する場合は削除し、更新された値を含む新しい configmap を作成します。


useConfigMapFile - ファイルを使用する
boolean. 省略可能。 の場合は command != login && command != logoutを使用します。 既定値: false

ディレクトリを ConfigMap 指定して、個々のファイルまたは複数のファイルから を作成します。


configMapFile - ConfigMap ファイル
string. useConfigMapFile = true && command != login && command != logout の場合に必要です。

configMaps を含むファイルまたはディレクトリを指定します。


configMapArguments - 引数
string. 省略可能。 の場合は useConfigMapFile = false && command != login && command != logoutを使用します。

configMap挿入するキーとリテラル値を指定します。 たとえば、--from-literal=key1=value1 または --from-literal=key2="top secret" です。


versionOrLocation - Kubectl
string. 使用できる値: versionlocation (場所を指定します)。 既定値: version

kubectl は、Kubernetes クラスターに対してコマンドを実行するためのコマンド ライン インターフェイスです。


versionOrLocation - Kubectl
string. 省略可能。 の場合は command != login && command != logoutを使用します。 使用できる値: versionlocation (場所を指定します)。 既定値: version

kubectl は、Kubernetes クラスターに対してコマンドを実行するためのコマンド ライン インターフェイスです。


versionSpec - バージョン スペック
string. 省略可能。 の場合は versionOrLocation = versionを使用します。 既定値: 1.13.2

取得するバージョンのバージョン スペックを指定します。 例: 1.7.0、、1.x.04.x.06.10.0>=6.10.0


versionSpec - バージョン スペック
string. 省略可能。 の場合は versionOrLocation = version && command != login && command != logoutを使用します。 既定値: 1.7.0

-18-2 取得するバージョンのバージョン 仕様を指定します。 例: 1.7.0、、1.x.04.x.06.10.0>=6.10.0


checkLatest - 最新バージョンを確認する
boolean. 省略可能。 の場合は versionOrLocation = versionを使用します。 既定値: false

常にオンラインで、バージョン 仕様を満たす最新バージョン (stable.txt) を確認します。これは通常、常に最新のシナリオを取得する特定のシナリオがない限り、false です。 これにより、特にホストされたビルド プールでは、必要ない可能性がある場合にダウンロード コストが発生します。


checkLatest - 最新バージョンを確認する
boolean. 省略可能。 の場合は versionOrLocation = version && command != login && command != logoutを使用します。 既定値: false

常にオンラインで、バージョン 仕様を満たす最新バージョン (stable.txt) を確認します。これは通常、常に最新のシナリオを取得する特定のシナリオがない限り、false です。 これにより、特にホストされたビルド プールでは、必要ない可能性がある場合にダウンロード コストが発生します。


specifyLocation - kubectl へのパス
string. versionOrLocation = location の場合に必要です。

ファイルへの完全パスを kubectl.exe 指定します。


specifyLocation - kubectl へのパス
string. versionOrLocation = location && command != login && command != logout の場合に必要です。

ファイルへの完全パスを kubectl.exe 指定します。


workingDirectory - 作業ディレクトリ
入力エイリアス: cwdstring. 既定値: $(System.DefaultWorkingDirectory)

Kubectl コマンドの作業ディレクトリ。


workingDirectory - 作業ディレクトリ
入力エイリアス: cwdstring. 省略可能。 の場合は command != login && command != logoutを使用します。 既定値: $(System.DefaultWorkingDirectory)

Kubectl コマンドの作業ディレクトリ。


outputFormat - 出力形式
string. 許可値: jsonyamlnone。 既定値: json

出力形式。


outputFormat - 出力形式
string. 使用できる値: jsonyaml。 既定値: json

出力形式。


outputFormat - 出力形式
string. 省略可能。 の場合は command != login && command != logoutを使用します。 使用できる値: jsonyaml。 既定値: json

出力形式。


タスク制御オプション

すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「 コントロール オプションと一般的なタスク プロパティ」を参照してください。

出力変数

このタスクでは、ダウンストリームのステップ、ジョブ、およびステージで使用できる次の 出力変数を定義します。

KubectlOutput
コマンドの出力を kubectl 格納します。

注釈

バージョン 1.0 の新機能。

  • Azure AKS クラスターを簡単に選択できるように、新しいサービス接続の種類の入力を追加しました。
  • 出力変数の入力を、すべてのタスクで追加した出力変数セクションに置き換えました。

このタスクを使用して、kubectl コマンドを実行し、Kubernetes クラスターをデプロイ、構成、更新します。

サービス接続

このタスクは、次に説明する Azure Resource ManagerKubernetes サービス接続の 2 種類のサービス接続で動作します。

Azure Resource Manager

を にAzure Resource Manager設定connectionTypeし、 をazureSubscriptionEndpoint指定して Azure Resource Manager サービス接続を使用します。

次の YAML の例では、Azure Resource Manager を使用して Kubernetes クラスターを参照する方法を示します。 これは、kubectl コマンドの 1 つと、コマンドに必要な適切な値を指定して使用されます。

variables:
  azureSubscriptionEndpoint: Contoso
  azureContainerRegistry: contoso.azurecr.io
  azureResourceGroup: Contoso
  kubernetesCluster: Contoso
  useClusterAdmin: false

steps:
- task: Kubernetes@1
  displayName: kubectl apply
  inputs:
    connectionType: Azure Resource Manager
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureResourceGroup: $(azureResourceGroup)
    kubernetesCluster: $(kubernetesCluster)
    useClusterAdmin: $(useClusterAdmin)

Kubernetes サービス接続

を にKubernetes Service Connection設定connectionTypeし、 をkubernetesServiceEndpoint指定して Kubernetes サービス接続を使用します。

次の YAM L の例では、Kubernetes サービス接続を使用して Kubernetes クラスターを参照する方法を示します。 これは、kubectl コマンドの 1 つと、コマンドに必要な適切な値を指定して使用されます。

- task: Kubernetes@1
  displayName: kubectl apply
  inputs:
    connectionType: Kubernetes Service Connection
    kubernetesServiceEndpoint: Contoso

AKS にアクセスするときの Kubernetes サービス接続に関する考慮事項

次のいずれかのオプションを使用して、Kubernetes サービス接続を作成できます。

  • KubeConfig
  • サービス アカウント
  • Azure サブスクリプション

Kubernetes サービス接続認証方法の選択のスクリーンショット。

[Azure サブスクリプション] オプションを選択するときは、サービス接続の構成時に Azure DevOps から Kubernetes にアクセスできる必要があります。 プライベート クラスターを作成した場合や、クラスターにローカル アカウントが無効になっているなど、サービス接続を作成できない理由はさまざまです。 このような場合、Azure DevOps はサービス接続の構成時にクラスターに接続できないため、[ 名前空間の読み込み中] 画面が表示されます。

名前空間の読み込み中に Kubernetes サービス接続認証ダイアログがスタックしている選択のスクリーンショット。

Kubernetes 1.24 以降では、有効期間の長いトークンは 既定では作成されなくなりました。 Kubernetes では、有効期間の長いトークンを使用しないことをお勧めします。 その結果、 Azure サブスクリプション オプションで作成された Kubernetes サービス接続を使用するタスクは、認証に必要な永続的なトークンにアクセスできないため、Kubernetes クラスターにアクセスできません。 これにより、固定された [読み込み名前空間 ] ダイアログも表示されます。

Azure Resource Manager サービス接続を使用して AKS にアクセスする

AKS のお客様の場合、Azure Resource Manager サービス接続の種類は、プライベート クラスター、またはローカル アカウントが無効になっているクラスターに接続するための最適な方法を提供します。 この方法は、サービス接続の作成時にクラスター接続に依存しません。 AKS へのアクセスはパイプライン ランタイムに遅延されます。次の利点があります。

  • (プライベート) AKS クラスターへのアクセスは、セルフホステッド エージェントまたはスケール セット エージェントからクラスターにアクセスできます。
  • トークンは、Azure Resource Manager サービス接続を使用するすべてのタスクに対して作成されます。 これにより、有効期間の短いトークン ( Kubernetes の推奨事項) を使用して Kubernetes に接続できます。
  • ローカル アカウントが無効になっている場合でも、AKS にアクセスできます。

サービス接続に関する FAQ

次のエラー メッセージが表示されます。サービス アカウントに関連付けられているシークレットが見つかりませんでした。 状況

Azure サブスクリプションを使用して Kubernetes サービス接続を使用しています。 このメソッドを更新して、有効期間の長いトークンを作成しています。 これは 5 月中旬に利用可能になる予定です。 ただし、 Kubernetes のガイダンスに従って有効期間の長いトークンは使用せず、Azure サービス接続の種類の使用を開始することをお勧めします。

AKS を使用していて、何も変更したくない場合、Kubernetes サービス接続でタスクを引き続き使用できますか?

このメソッドを更新して、有効期間の長いトークンを作成しています。 これは 5 月中旬に利用可能になる予定です。 ただし、このアプローチは Kubernetes ガイダンスに反していることに注意してください。

Kubernetes タスクと Kubernetes サービス接続を使用していますが、AKS は使用していません。 私は心配する必要がありますか?

タスクは引き続き以前と同様に機能します。

Kubernetes サービスの接続の種類は削除されますか?

Kubernetes タスクは、実行されている場所に関係なく、任意の Kubernetes クラスターで動作します。 Kubernetes サービス接続は引き続き存在します。

私はAKSの顧客であり、すべてが正常に実行されている、私は行動する必要がありますか?

何も変更する必要はありません。 Kubernetes サービス接続を使用していて、作成時に [Azure サブスクリプション] を選択している場合は、有効期間の 長いトークンの使用に関する Kubernetes ガイダンスに注意する必要があります。

Kubernetes 環境を作成しており、サービス接続を使用するオプションはありません

環境の作成時に AKS にアクセスできない場合は、空の環境を使用し、入力を connectionType Azure Resource Manager サービス接続に設定できます。

Azure Active Directory RBAC で AKS が構成されていて、パイプラインが機能しません。 これらの更新プログラムによって解決されますか?

AAD RBAC が有効になっているときに Kubernetes にアクセスすることは、トークンの作成とは関係ありません。 対話型プロンプトを防ぐために、今後の更新で kubelogin をサポートします。

コマンド

コマンド入力は kubectl コマンドを受け入れます。

次の YAML の例は、apply コマンドを示しています。

- task: Kubernetes@1
  displayName: kubectl apply using arguments
  inputs:
    connectionType: Azure Resource Manager
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureResourceGroup: $(azureResourceGroup)
    kubernetesCluster: $(kubernetesCluster)
    command: apply
    arguments: -f mhc-aks.yaml

次の YAML の例では、apply コマンドで構成ファイルを使用する方法を示します。

- task: Kubernetes@1
  displayName: kubectl apply using configFile
  inputs:
    connectionType: Azure Resource Manager
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureResourceGroup: $(azureResourceGroup)
    kubernetesCluster: $(kubernetesCluster)
    command: apply
    useConfigurationFile: true
    configuration: mhc-aks.yaml

この YAML の例では、 scale コマンドを使用してデプロイ内のレプリカの数を 0 に減らす方法を示します。

- task: Kubernetes@1
      displayName: 'Scale down deployment $(k8sDeployment) to 0'
      inputs:
        connectionType: 'Kubernetes Service Connection'
        kubernetesServiceEndpoint: $(kubernetesServiceConnection)
        command: 'scale'
        arguments: 'deployment/$(k8sDeployment) --replicas=0'
        namespace: $(namespace)

シークレット

種類がシークレットの Kubernetes オブジェクトは、パスワード、OAuth トークン、ssh キーなどの機密情報を保持することを目的としています。 この情報をシークレットにすることは、ポッド定義や Docker イメージにそのまま記述するよりも安全で、柔軟性が高くなります。 Azure Pipelines を使用すると、次に説明するように、サービス アカウントへの の追加 ImagePullSecrets や、任意の汎用シークレットの設定が簡略化されます。

ImagePullSecret

次の YAML の例は、ImagePullSecrets の設定を示しています。

    - task: Kubernetes@1
      displayName: kubectl apply for secretType dockerRegistry
      inputs:
        azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
        azureResourceGroup: $(azureResourceGroup)
        kubernetesCluster: $(kubernetesCluster)
        command: apply
        arguments: -f mhc-aks.yaml
        secretType: dockerRegistry
        containerRegistryType: Azure Container Registry
        azureSubscriptionEndpointForSecrets: $(azureSubscriptionEndpoint)
        azureContainerRegistry: $(azureContainerRegistry)
        secretName: mysecretkey2
        forceUpdate: true

汎用シークレット

次の YAML の例では、secretArguments 入力に指定されたリテラル値から汎用シークレットを作成します。

    - task: Kubernetes@1
      displayName: secretType generic with literal values
      inputs:
        azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
        azureResourceGroup: $(azureResourceGroup)
        kubernetesCluster: $(kubernetesCluster)
        command: apply
        arguments: -f mhc-aks.yaml
        secretType: generic
        secretArguments: --from-literal=contoso=5678
        secretName: mysecretkey

パイプライン変数は、次に示すように、リテラル値を指定する引数を渡すために使用できます。

    - task: Kubernetes@1
      displayName: secretType generic with pipeline variables
      inputs:
        azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
        azureResourceGroup: $(azureResourceGroup)
        kubernetesCluster: $(kubernetesCluster)
        command: apply
        arguments: -f mhc-aks.yaml
        secretType: generic
        secretArguments: --from-literal=contoso=$(contosovalue)
        secretName: mysecretkey

ConfigMap

ConfigMaps を使用すると、構成成果物をイメージ コンテンツから分離して、コンテナー化されたアプリケーションの移植性を維持できます。

次の YAML の例では、ConfigMap ファイルを指定して、ConfigMap を作成します。

    - task: Kubernetes@1
      displayName: kubectl apply
      inputs:
        configMapName: myconfig
        useConfigMapFile: true
        configMapFile: src/configmap

次の YAML の例では、configMapArguments 入力としてリテラル値を直接指定し、forceUpdate を true に設定することで、ConfigMap を作成します。

    - task: Kubernetes@1
      displayName: configMap with literal values
      inputs:
        azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
        azureResourceGroup: $(azureResourceGroup)
        kubernetesCluster: $(kubernetesCluster)
        command: apply
        arguments: -f mhc-aks.yaml
        secretType: generic
        secretArguments: --from-literal=contoso=$(contosovalue)
        secretName: mysecretkey4
        configMapName: myconfig
        forceUpdateConfigMap: true
        configMapArguments: --from-literal=myname=contoso

次に示すように、パイプライン変数を使用して、ConfigMap の作成時にリテラル値を渡すことができます。

    - task: Kubernetes@1
      displayName: configMap with pipeline variables
      inputs:
        azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
        azureResourceGroup: $(azureResourceGroup)
        kubernetesCluster: $(kubernetesCluster)
        command: apply
        arguments: -f mhc-aks.yaml
        secretType: generic
        secretArguments: --from-literal=contoso=$(contosovalue)
        secretName: mysecretkey4
        configMapName: myconfig
        forceUpdateConfigMap: true
        configMapArguments: --from-literal=myname=$(contosovalue)

トラブルシューティング

Kubernetes クラスターはファイアウォールの内側にあり、ホステッド エージェントを使用しています。 このクラスターにデプロイするにはどうすればよいですか?

ホステッド エージェントに対する IP アドレスを許可することにより、ファイアウォール経由のホステッド エージェントへのアクセスを許可できます。 詳細については、エージェントの IP 範囲に関する記事を参照してください

要件

要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント、DeploymentGroup
確認要求 なし
Capabilities このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 Any
設定可能な変数 Any
エージェントのバージョン サポートされているすべてのエージェント バージョン。
タスクのカテゴリ 配置