I am trying to run multiple kubectl commands using Kubernetes@1 task in Azure Devops Pipeline, however I am not sure how to do this.
kubectl exec $(kubectl get pods -l app=deployment_label -o custom-columns=:metadata.name --namespace=some_name_space) --namespace=some_namespace -- some command
If what you want is input these multiple commands into Command
parameter of the task:
Unfortunately to say, No, the task script does not support this compiled method until now.
As the doc described:
The command input accept only one of these commands, which means you can only input one command in each Kubernetes@1
task.
Also, if you want to input instead of select one of commands from it, it could not exceed the range of commands allowed by this task and has restrict writing format like this:
For the commands you provided, if continue want to use Kubernetes@1
task, you'd better split these commands into the separate one with multiple tasks. You could check this blog for detailed usage.
As work around, if you still want to execute this multiple commands at same time, you can use Azure CLI task(if you are connecting Azure K8s), or use Command line task(if what you are connecting is the local k8s server).