Well, as you mentioned in comments the Kubernetes cluster located under Azure (AKS), therefore you can use the following steps which I find easier to maintain and more straight forward :
First of all, Get credentials from AKS using Azure CLI using az aks get-credentials.
This command gets access credentials for a managed Kubernetes cluster and allows you to run kubectl
commands from the agent:
steps:
- task: AzureCLI@1
displayName: 'Azure CLI - get credentials from aks'
inputs:
azureSubscription: '$(azure_subscription)'
scriptLocation: inlineScript
inlineScript: 'az aks get-credentials --resource-group $(resource_group_name) --name $(cluster_name)'
Now, you can run any kubectl
command using a bash script.
For instance :
bash: |
kubectl apply -f manifest.yml
displayName: 'Kubectl apply my manifest.yaml'
In my opinion, it's better using bash scripts instead of depending on extensions. And, if you want to migrate your Yaml to another resource such as Jenkins you can do it easily.
Kubectl commands.