Enable Kubernetes extension for VSTS. Kubernetes endpoint for kubectl config and kubectl apply build task. Mainly aim for using Linux Hosted Agent(preview).
Currently, stable version tasks are version 0.x.x. or 1.x.x. 2.0.0 or later is preview.
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.
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 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
.
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
.
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.