Deploy: Deploy to Kubernetes

Azure Pipelines

Deploy, configure, update your Kubernetes cluster in Azure Container Service by running kubectl commands.

YAML snippet

# Deploy to Kubernetes
# Deploy, configure, update your Kubernetes cluster in Azure Container Service by running kubectl commands.
- task: Kubernetes@1
  inputs:
    #connectionType: 'Azure Resource Manager' # Options: azure Resource Manager, kubernetes Service Connection
    #kubernetesServiceEndpoint: # Required when connectionType == Kubernetes Service Connection
    #azureSubscriptionEndpoint: # Required when connectionType == Azure Resource Manager
    #azureResourceGroup: # Required when connectionType == Azure Resource Manager
    #kubernetesCluster: # Required when connectionType == Azure Resource Manager
    #namespace: # Optional
    #command: 'apply' # Options: apply, create, delete, exec, expose, get, login, logout, logs, run, set, top
    #useConfigurationFile: false # Optional
    #configuration: # Required when useConfigurationFile == True
    #arguments: # Optional
    #secretType: 'dockerRegistry' # Options: dockerRegistry, generic
    #secretArguments: # Optional
    #containerRegistryType: 'Azure Container Registry' # Required when secretType == DockerRegistry# Options: azure Container Registry, container Registry
    #dockerRegistryEndpoint: # Optional
    #azureSubscriptionEndpointForSecrets: # Optional
    #azureContainerRegistry: # Optional
    #secretName: # Optional
    #forceUpdate: true # Optional
    #configMapName: # Optional
    #forceUpdateConfigMap: false # Optional
    #useConfigMapFile: false # Optional
    #configMapFile: # Required when useConfigMapFile == True
    #configMapArguments: # Optional
    #versionOrLocation: 'version' # Optional. Options: version, location
    #versionSpec: '1.7.0' # Optional
    #checkLatest: false # Optional
    #specifyLocation: # Required when versionOrLocation == Location
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # Optional
    #outputFormat: 'json' # Optional. Options: json, yaml

Arguments

ArgumentDescription
Kubernetes service connection(Optional) Select a Kubernetes service connection.
Namespace(Optional) Set the namespace for the kubectl command by using the –namespace flag. If the namespace is not provided, the commands will run in the default namespace.
Command(Required) Select or specify a kubectl command to run.
Use Configuration files(Optional) Use Kubernetes configuration file with the kubectl command. Filename, directory, or URL to Kubernetes configuration files can also be provided.
Configuration file(Required) Filename, directory, or URL to kubernetes configuration files that will be used with the commands.
Arguments(Optional) Arguments to the specified kubectl command.
Type of secret(Required) Create/update a generic or dockerimagepullsecret.
Arguments(Optional) Specify keys and literal values to insert in secret.For example, --from-literal=key1=value1 --from-literal=key2="top secret".
Container Registry type(Required) Select a Container registry type. The task can use Azure Subscription details to work with an Azure Container registry. Other standard Container registries are also supported.
Docker Registry connection(Optional) Select a Docker registry connection. Required for commands that need to authenticate with a registry.
Azure subscription(Optional) Select the Azure Resource Manager subscription, which contains Azure Container Registry. Note: To configure new service connection, select the Azure subscription from the list and click 'Authorize'. If your subscription is not listed or if you want to use an existing Service Principal, you can setup an Azure service connection using 'Add' or 'Manage' button.
Azure Container Registry(Optional) Select an Azure Container Registry which will be used for pulling container images and deploying applications to the Kubernetes cluster. Required for commands that need to authenticate with a registry.
Secret name(Optional) Name of the secret. You can use this secret name in the Kubernetes YAML configuration file.
Force update secret(Optional) Delete the secret if it exists and create a new one with updated values.
ConfigMap name(Optional) ConfigMaps allow you to decouple configuration artifacts from image content to keep containerized applications portable.
Force update configmap(Optional) Delete the configmap if it exists and create a new one with updated values.
Arguments(Optional) Specify keys and literal values to insert in configMap.For example, --from-literal=key1=value1 --from-literal=key2="top secret".
Kubectl(Optional) undefined
Version spec(Optional) Version Spec of version to get. Examples: 1.7.0, 1.x.0, 4.x.0, 6.10.0, >=6.10.0
Check for latest version(Optional) Always checks online for the latest available version (stable.txt) that satisfies the version spec. This is typically false unless you have a specific scenario to always get latest. This will cause it to incur download costs when potentially not necessary, especially with the hosted build pool.
Path to Kubectl(Required) Full path to the kubectl.exe
Working directory(Optional) Working directory for the Kubectl command.
Output format(Optional) Output format.
Output variable name(Optional) Name of the variable in which output of the command should be saved.
Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

Q & A