Enable us to use Kubernetes related product for VSTS. Also it enable us to kubernetes endpoint for kubectl. You can use kubectl, helm, and istioctl by this extension. This task aims for using Linux Hosted Agent(preview). GitHub repo is here.
NOTE: this task is NOT the official Kubernetes task created by Microsoft.
Currently you can use istio/helm feature from 3.0.0. or later.
Choose Kubernetes endpoint.
Kubernetes Connection pops up. Then fill the box.
- Connection name: Endpoint name (Anything is OK)
- Server URL : K8s Cluster URL for memo (Not used for the task until now)
- kubeconfig : Copy & paste your config file
You can get config file from your k8s master node .kube/config
.
See Microsoft Azure Container Service Engine - Kubernetes Walkthrough
Then copy the file content and paste on kubeconfig column.
NOTE:
If you copy config file into Kubeconfig, the build log of VSTS might show you the contents.
This happens when you copy multiline.
Kubernetes tasks support base64 encoding for Kubeconfig column. If you want to avoid this problem,
you can convert your config file into base64 string. You can find the tool for converting config file. tools/convert.ts
Usage
your config file should be LF
not CRLF
if you want to use on Linux hosted build.
tsc -p .
node tools/convert.js {filename}
You can find {filename}_new file which include base64 encoding string.
If you want to use kubectl/istioctl/helm binary, you need to use this task in advance. For the backword compatibility, I letf the old tasks like kubernetes apply task
and kubernetes general task
. However, I recommend to use the new task with downloader. It will be much more flexible and simple.
If you use this downlaoder, you can avoid to download the binary several times. This task download kubectl/istioctl/helm binary into ./.vstsbin
directory and add it to the PATH
environment variables. Also, it set KUBECONFIG
environment variables. If you use this downloader, the following task can use kubectl/istioctl/helm command without specifying the full-path binary file name.
- Display Name: Name of the task
- k8s endpoint: select the endpoint which you created at
1.1. Create an endpoint
- kubectl binary: Leave it blank. Don't use this.(depricated)
- kubectl download version:If you want to specify the version, fill this, e.g.
v1.5.2
. Blank means latest. - enable istioctl: Check it if you want to use istioctl
- istioctl download version: Specify the version. Blank doesn't mean the latest. not like the kubectl downloader. e.g.
0.1.5
- enable helm: Check it if you want to use helm
- helm download version: Specify the version. Blank doesn't mean the latest. not like the kubectl downloader. e.g.
2.4.1
You can execute kubectl using this task. If you want to use this task, you need to use downloader
task in advance. See 1.2. downloader
.
- Display name: Name of the task
- Sub Command: Specify kubectl sub command like apply, get, and so on. Refer the Overview of kubectl.
- Argument: You can use any options and arguments. You can specify these with a space or a new line. New line will be converted into a space.
You can execute istioctl using this task. If you want to use this task, you need to use downloader
task in advance. See 1.2. downloader
.
- Display name: Name of the task
- Sub Command: Specify istio sub command like replace, create, and so on. Refer the istioctl.
- Argument: You can use any options and arguments. You can specify these with a space or a new line. New line will be converted into a space.
You can execute helm using this task. If you want to use this task, you need to use downloader
task in advance. See 1.2. downloader
.
- Display name: Name of the task
- Sub Command: Specify helm sub command like create, verify, and so on. Refer the Using helm.
- Argument: You can use any options and arguments. You can specify these with a space or a new line. New line will be converted into a space.
NOTE: kubernetes apply/general task is for backward compatibility.
If you use ver 2.0, you don't need this operation. However, this operation could fasten your pipeline without downloading a kubectl binary.
Link your repo which has kubecntl command.
Please chmod +x kubectl
before adding kubectl to your repo.
Then you can use the endpoint, specify the kubectl command and YAML file
for deployment. Internally, it calls kubectl apply
command.
If you want to change the YAML file dynamically, you can use Replace tokens on the VSTS Marketplace.
You can see the downloadVersion
textbox. If you don't specify KubectlBinary
, this task automatically download the latest
kubebinary. If you want to specify the version, fill the downloadVersion
, e.g. v1.5.2
.
NOTE: kubernetes apply/general task is for backward compatibility.
You can use every kubectl command you want. Use kubectlgeneral task. You can specify a lot of arguments separated with space or new line.
You can see the downloadVersion
textbox. If you don't specify KubectlBinary
, this task automatically download the latest
kubebinary. If you want to specify the version, fill the downloadVersion
, e.g. v1.5.2
.
This is the guide for the contribution. Feel free to contribute for this task.
This project is started before the official kubernetes task for vsts. I develop this task with a vsts production team members. With some of the feed back the official task has been launched. However, the official task is tightly coupled with ACS (Azure Container Service). Some people use this task for GCP and OnPrem.
I'll add some new feature like istio/helm integration in advance as a incubetion project. I'll send the feedback to the production team.
You need typings / tsc / tfx commands.
Please refer these to install.
npm install
npm install [email protected] --global-style
npm install [email protected] --global-style
npm install [email protected] --global-style
FYI: typings tfx-cli typescript
I tested via windows environment.
npm test // Compile Typescript and Test these
npm run deploy // Deploy kubectl and node_modules into task directory
npm run build // Build *.vsix file
If you want to debug these. NOTE: I'm using GitBash for this developmnet. You can see the debug output.
export TASK_TEST_TRACE=1
Go to the Market place Market Place Manage Then upload and share with your VSTS account. Tsuyoshi Ushio's publisher site
Stable version is 1.0.0 or later. You can test it make it 0.x.x with preview tag.
Now I just start this project. Just initial commit. However, you can see the image of the endpoint and build task.
- Flexbile Command Excecution except for
kubectl apply
- Enable to select the version of kubectl and automatically installed.
We need to test this plugin in VSTS before rolling out. However, if we want to test this, we need to deploy to the Marketplace. If we create a new feature, the task version will be the next major version. However, we might upgrade vss-extension.json's version. I'm showing you an example.
Current task version: v1.0.0
Current vss-extension version: v1.0.0
If you want to develop a new feature, you can deploy to the Marketplace using these versions.
Task version: v2.0.0 (with preview tag)
Vss-extension version: v1.0.1
In this case, customer environment won't be influenced by this release. They keep on using v1.0.0 If I choose v2.0.0 Preview intendedly, we can change the version. Since this feature might be preview in VSTS, this spec might change in the future.