Setup description
I have the following scenario: Created a Build Pipeline in Azure DevOps and after setting up my Kubernetes cluster I want to get a specific pod name using kubectl. I am doing this via the "Deploy to Kubernetes" task V1, which looks like this:
steps:
- task: Kubernetes@1
displayName: 'Get pod name'
inputs:
azureSubscriptionEndpoint: 'Azure Pay-as-you-Go (anonymized)'
azureResourceGroup: MyK8sDEV
kubernetesCluster: myCluster
command: get
arguments: 'pods -l "app=hlf-ca,release=ca" -o jsonpath="{.items[0].metadata.name}"'
So the task is running successfully and I want to get the output string of the above command. In the Pipeline visual designer it shows me an output variable of undefined.KubectlOutput that is being written to.
Problem statement
I have created a subsequent Bash script task directly after the above kubectl task. If I read the variable $KUBECTLOUTPUT or $UNDEFINED_KUBECTLOUTPUT it just returns an empty string. What am I doing wrong? I just need the output from the previous command as a variable.
My goal with the action
I am trying to make sure that the application I deployed with a helm chart in the previous step is up and running. In the next step I need to run some scripts inside the application pods (using kubectl exec) so I want to make sure that at least 1 pod hosting the app is up and running so that I can execute commands against it. In the meantime I realized that I can skip the checking step if I use the --wait flag when deploying the helm chart, but I still have issues using kubectl from within the bash script.