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 Manager
、Kubernetes Service Connection
、None
。 既定値: 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 Manager
、Kubernetes Service Connection
、None
。 既定値: Azure Resource Manager
.
サービス接続の種類を指定します。他のクラスターに対して Azure Kubernetes Service または Kubernetes Service Connection を使用する場合は Azure Resource Manager です。
Kubernetes サービス接続の kubernetesServiceEndpoint
-
string
.
connectionType = Kubernetes Service Connection && command != logout
する場合に必要です。
Kubernetes サービス接続を選択します。
Azure サブスクリプションを azureSubscriptionEndpoint
- する
string
.
connectionType = Azure Resource Manager && command != logout
する場合に必要です。
Azure Container Registry を含む Azure Resource Manager サブスクリプションを指定します。
手記
新しいサービス接続を構成するには、一覧から Azure サブスクリプションを指定し、[Authorize
] をクリックします。 サブスクリプションが一覧にない場合、または既存のサービス プリンシパルを使用する場合は、Add
または Manage
ボタンを使用して Azure サービス接続を設定できます。
azureResourceGroup
-
リソース グループの
string
.
connectionType = Azure Resource Manager && command != logout
する場合に必要です。
Azure リソース グループを選択します。
Kubernetes クラスターの kubernetesCluster
-
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
、create
、delete
、exec
、expose
、get
、login
、logout
、logs
、run
、set
、top
。
実行する kubectl コマンドを選択または指定します。 使用可能な値の一覧には、タスク アシスタントを使用するときの選択を容易にするための一般的な選択肢がいくつかありますが、scale
など、他の kubectl コマンド 指定できます。
arguments
入力を使用して、指定した kubectl
コマンドに追加のパラメーターを指定します。
command
-
コマンド
string
. 必須。 使用できる値: apply
、create
、delete
、exec
、expose
、get
、login
、logout
、logs
、run
、set
、top
。 既定値: apply
.
実行する kubectl コマンドを選択または指定します。
useConfigurationFile
-
構成 を使用する
boolean
. 随意。
command != login && command != logout
するときに使用します。 既定値: false
.
kubectl
コマンドで使用する Kubernetes 構成を指定します。 Kubernetes 構成ファイルへのインライン スクリプト、ファイル名、ディレクトリ、または URL を指定できます。
useConfigurationFile
-
構成ファイルを使用する
boolean
. 随意。
command != login && command != logout
するときに使用します。 既定値: false
.
kubectl
コマンドで使用する Kubernetes 構成を指定します。 Kubernetes 構成ファイルへのインライン スクリプト、ファイル名、ディレクトリ、または URL を指定できます。
configurationType
-
構成の種類
string
. 随意。
useConfigurationFile = true
するときに使用します。 使用できる値: configuration
(ファイル パス)、inline
(インライン構成)。 既定値: configuration
.
kubectl
コマンドの Kubernetes 構成の種類を指定します。 ファイル パスまたはインライン スクリプトを指定できます。
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
する場合に必要です。 使用できる値: dockerRegistry
、generic
。 既定値: 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 Registry
、Container Registry
。 既定値: Azure Container Registry
.
コンテナー レジストリの種類を選択します。 このタスクでは、Azure サブスクリプションの詳細を使用して、Azure Container Registry を操作できます。 その他の標準コンテナー レジストリもサポートされています。
Docker レジストリ サービス接続を dockerRegistryEndpoint
- する
string
. 随意。
secretType = dockerRegistry && containerRegistryType = Container Registry && command != login && command != logout
するときに使用します。
Docker レジストリ サービス接続を選択します。 レジストリで認証する必要があるコマンドに必要です。
Azure サブスクリプションを azureSubscriptionEndpointForSecrets
- する
string
. 随意。
secretType = dockerRegistry && containerRegistryType = Azure Container Registry && command != login && command != logout
するときに使用します。
Azure Container Registry を含む Azure Resource Manager サブスクリプションを指定します。
手記
新しいサービス接続を構成するには、一覧から Azure サブスクリプションを選択し、[Authorize
] をクリックします。 サブスクリプションが一覧にない場合、または既存のサービス プリンシパルを使用する場合は、Add
または Manage
ボタンを使用して Azure サービス接続を設定できます。
Azure コンテナー レジストリの azureContainerRegistry
-
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
.
シークレットが存在する場合は削除し、更新された値を持つ新しいシークレットを作成します。
ConfigMap 名を configMapName
- する
string
. 随意。
command != login && command != logout
するときに使用します。
ConfigMap を使用すると、構成成果物をイメージ コンテンツから切り離して、コンテナー化されたアプリケーションを移植可能な状態に保つことができます。
forceUpdateConfigMap
-
configmap を強制的に更新する
boolean
. 随意。
command != login && command != logout
するときに使用します。 既定値: false
.
configmap が存在する場合は削除し、更新された値を持つ新しい configmap を作成します。
useConfigMapFile
-
ファイル を使用する
boolean
. 随意。
command != login && command != logout
するときに使用します。 既定値: false
.
ディレクトリを指定して、個々のファイルまたは複数のファイルから ConfigMap
を作成します。
ConfigMap ファイルを configMapFile
- する
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"
などです。
Kubectlを versionOrLocation
- する
string
. 使用できる値: version
、location
(場所の指定)。 既定値: version
.
kubectl は、Kubernetes クラスターに対してコマンドを実行するためのコマンド ライン インターフェイスです。
Kubectlを versionOrLocation
- する
string
. 随意。
command != login && command != logout
するときに使用します。 使用できる値: version
、location
(場所の指定)。 既定値: version
.
kubectl は、Kubernetes クラスターに対してコマンドを実行するためのコマンド ライン インターフェイスです。
versionSpec
-
バージョン 仕様の
string
. 随意。
versionOrLocation = version
するときに使用します。 既定値: 1.13.2
.
取得するバージョンのバージョン スペックを指定します。 例: 1.7.0
、1.x.0
、4.x.0
、6.10.0
、>=6.10.0
。
versionSpec
-
バージョン 仕様の
string
. 随意。
versionOrLocation = version && command != login && command != logout
するときに使用します。 既定値: 1.7.0
.
-18-2 取得するバージョンのバージョン スペックを指定します。 例: 1.7.0
、1.x.0
、4.x.0
、6.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
-
作業ディレクトリの
入力エイリアス: cwd
。
string
. 既定値: $(System.DefaultWorkingDirectory)
.
Kubectl コマンドの作業ディレクトリ。
workingDirectory
-
作業ディレクトリの
入力エイリアス: cwd
。
string
. 随意。
command != login && command != logout
するときに使用します。 既定値: $(System.DefaultWorkingDirectory)
.
Kubectl コマンドの作業ディレクトリ。
outputFormat
-
出力形式の
string
. 使用できる値: json
、yaml
、none
。 既定値: json
.
出力形式。 使用可能な値の一覧には、タスク アシスタントを使用する際の選択を容易にするための一般的な選択肢がいくつかありますが、jsonpath={.items[*].spec['initContainers', 'containers'][*].image}
などの他の 出力オプション 指定できます。
outputFormat
-
出力形式の
string
. 使用できる値: json
、yaml
。 既定値: json
.
出力形式。 使用可能な値の一覧には、タスク アシスタントを使用する際の選択を容易にするための一般的な選択肢がいくつかありますが、jsonpath={.items[*].spec['initContainers', 'containers'][*].image}
などの他の 出力オプション 指定できます。
outputFormat
-
出力形式の
string
. 随意。
command != login && command != logout
するときに使用します。 使用できる値: json
、yaml
。 既定値: json
.
出力形式。 使用可能な値の一覧には、タスク アシスタントを使用する際の選択を容易にするための一般的な選択肢がいくつかありますが、jsonpath={.items[*].spec['initContainers', 'containers'][*].image}
などの他の 出力オプション 指定できます。
タスク コントロールのオプション
すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「コントロール オプションと一般的なタスク プロパティを参照してください。
出力変数
このタスクでは、次の 出力変数を定義します。この変数は、ダウンストリームのステップ、ジョブ、およびステージで使用できます。
KubectlOutput
kubectl
コマンドの出力を格納します。
備考
バージョン 1.0 の新機能。
- Azure AKS クラスターを簡単に選択できるように、新しいサービス接続の種類の入力を追加しました。
- 出力変数の入力を、すべてのタスクで追加した出力変数セクションに置き換えました。
このタスクを使用して、kubectl コマンドを実行して Kubernetes クラスターをデプロイ、構成、または更新します。
サービス接続
このタスクは、Azure Resource Manager と Kubernetes Service Connection という 2 種類のサービス接続で動作します。以下で説明します。
Azure Resource Manager
connectionType
を Azure Resource Manager
に設定し、Azure Resource Manager サービス接続を使用する azureSubscriptionEndpoint
を指定します。
この YAML の例は、Azure Resource Manager を使用して Kubernetes クラスターを参照する方法を示しています。 これは、いずれかの kubectl コマンドと、コマンドに必要な適切な値で使用されます。
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 サービス接続
connectionType
を Kubernetes Service Connection
に設定し、Kubernetes サービス接続を使用する kubernetesServiceEndpoint
を指定します。
この YAML の例は、Kubernetes サービス接続を使用して Kubernetes クラスターを参照する方法を示しています。 これは、いずれかの kubectl コマンドと、コマンドに必要な適切な値で使用されます。
- task: Kubernetes@1
displayName: kubectl apply
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: Contoso
AKS にアクセスするときの Kubernetes サービス接続に関する考慮事項
次のいずれかのオプションを使用して、Kubernetes サービス接続を作成できます。
- KubeConfig
- サービス アカウント
- Azure サブスクリプション
Azure サブスクリプション オプションを選択する場合、サービス接続構成時に Azure DevOps から Kubernetes にアクセスできる必要があります。 サービス接続を作成できない理由はさまざまです。たとえば、プライベート クラスター を作成 場合や、クラスター ローカル アカウントが無効になっている場合などです。 このような場合、Azure DevOps はサービス接続の構成時にクラスターに接続できないため、名前空間の読み込み 画面が表示されます。
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 の例では、スケール コマンドを使用して、デプロイ内のレプリカの数を 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
ConfigMap を使用すると、構成成果物をイメージ コンテンツから切り離して、コンテナー化されたアプリケーションの移植性を維持できます。
この 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 範囲 を参照してください。