Azure-pipelines-tasks: ROI: Execute bash script in kubernetes task

Created on 20 Jan 2019  路  11Comments  路  Source: microsoft/azure-pipelines-tasks

Use Case Description

I wonder whether the kubernetes task can be extended to allow users running a bash script instead of a single kubernetes command.

In my case, I have a simple script to implement a blue/green deployment on k8s (20 lines of bash code) that could be use easily in my deployment pipeline. That would be very easy, require no additional packages (say helM) and I could run the same script on my laptop if I want to develop locally (say against minikube).

Release enhancement

Most helpful comment

This is possible even today. For example, you can use the Kubernetes task to login (get the context) and then run a cli task for running the script.
image
Let me know if you face any issue.
We are also working on some Kuberntes features around Deployment, Deployment Stratgy...... Let me know if you want to give us some early feedback.

All 11 comments

This is possible even today. For example, you can use the Kubernetes task to login (get the context) and then run a cli task for running the script.
image
Let me know if you face any issue.
We are also working on some Kuberntes features around Deployment, Deployment Stratgy...... Let me know if you want to give us some early feedback.

@azooinmyluggage looks nice! I missed it (honestly I thought that the kubernetes task only executes kubectl-like commands...) and I will give it a try.

I still think it would be easier to have a dedicated task that

  • logs in
  • executes a script
  • logs out

As for deployment, my feeling is that Deployment is very much a process very project/developer dependent. Not sure you can capture enough use cases to build a sufficiently flexible task. I would rather use a bash script if I can, as I can also run on my laptop.

@azooinmyluggage Just tried to use the kubernetes task to execute login, then a bash task calling kubectl get all: kubectl expect me to log in using a browser! I would have expected a SP to be available. Any clue?

Investigating. Will revert.

Thanks. Just to mention: I find very simple and clean the following approach
https://github.com/MicrosoftDocs/vsts-docs/blob/master/docs/pipelines/tasks/deploy/azure-cli.md

Any further thoughts?

Give me a day!! Sorry for the delay.

@andreacassioli After digging a bit deeper, Here is a link to the issue you are facing:
https://feedback.azure.com/forums/914020-azure-kubernetes-service-aks/suggestions/35146387-support-non-interactive-login-for-aad-integrated-c

Can you please confirm if you have AAD integration?

I am thinking about couple of options to make this easy.

  1. Accept this PR: https://github.com/Microsoft/azure-pipelines-tasks/pull/9125/files
  2. We have a new feature rolling out where you can use Azure DevOps to create a Service account scoped to a namespace
    Let me know if you are open for a quick call to discuss this.

@azooinmyluggage I do have AAD integration.

An approach similar to Azure CLI would be nice. I guess it is what you mentioned as point 2. I am not in a position to follow the PR you point me to. Indeed there is not even a brief summary (not a very good practice....).

@andreacassioli The PR is an external contribution. Thanks for the feedback. I will revert early next week.

Somehow I managed to miss this issue. We have made the change
image
This is available for both Kubectl and Helm task.

Was this page helpful?
0 / 5 - 0 ratings