Skip to content

Instantly share code, notes, and snippets.

@MattMencel
Created January 7, 2019 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattMencel/501edc68a5cd1ff02f886a5ce2d18cb3 to your computer and use it in GitHub Desktop.
Save MattMencel/501edc68a5cd1ff02f886a5ce2d18cb3 to your computer and use it in GitHub Desktop.
Deploy VSTS Agent to AKS Cluster with Helm
resources:
- repo: self
clean: true
queue:
name: Hosted Ubuntu 1604
trigger:
batch: true
branches:
include:
- master
paths:
include:
- 'Terraform/AKS/azure-deploy-vsts.yml'
variables:
- name: AGENT_COUNT
value: '2'
- name: VSTS_ACCOUNT
value: 'foo'
- name: VSTS_POOL
value: 'Terraform Agents'
- group: 'VSTS-Agent-PAT'
steps:
- task: HelmInstaller@0
displayName: 'Install Helm'
inputs:
kubectlVersion: 1.10.3
checkLatestKubectl: true
- script: |
docker pull quay.io/10thmagnitude/aks-vsts-agent:latest
docker tag quay.io/10thmagnitude/aks-vsts-agent $(ACR_SHORTNAME).azurecr.io/aks-vsts-agent
displayName: 'Pull and Tag'
- task: Docker@1
displayName: 'Push to ACR'
inputs:
azureSubscriptionEndpoint: 'MySub'
azureContainerRegistry: $(ACR_SHORTNAME).azurecr.io
command: 'Push an image'
imageName: 'aks-vsts-agent'
- task: Kubernetes@1
displayName: 'kubectl get namespace tiller'
inputs:
azureSubscriptionEndpoint: 'MySub'
azureResourceGroup: AKS_RG
kubernetesCluster: AKS-CLUS01
command: get
arguments: 'namespace tiller'
continueOnError: true
- task: Kubernetes@1
displayName: 'kubectl create namespace tiller if previous step fails'
inputs:
azureSubscriptionEndpoint: 'MySub'
azureResourceGroup: AKS_RG
kubernetesCluster: AKS_CLUS01
command: create
arguments: 'namespace tiller'
condition: failed()
- task: HelmDeploy@0
displayName: 'helm init'
inputs:
azureSubscription: 'MySub'
azureResourceGroup: AKS_RG
kubernetesCluster: AKS_CLUS01
command: init
tillerNamespace: tiller
- script: |
if [ -d "Docker/VSTS_AGENT/vsts-agent" ]; then
cd Docker/VSTS_AGENT/vsts-agent
git pull
else
git clone https://github.com/Azure/helm-vsts-agent Docker/VSTS_AGENT/vsts-agent
fi
displayName: 'Clone Helm Chart github.com/Azure/helm-vsts-agent'
- task: HelmDeploy@0
displayName: 'helm install/upgrade'
inputs:
azureSubscription: 'MySub'
azureResourceGroup: AKS_RG
kubernetesCluster: AKS_CLUS01
namespace: 'vsts-agent'
command: upgrade
chartType: FilePath
chartPath: 'Docker/VSTS_AGENT/vsts-agent/charts/vsts-agent'
releaseName: 'vsts-agent'
overrideValues: 'image.repository=$(ACR_SHORTNAME).azurecr.io/aks-vsts-agent,vstsToken=$(VSTS_AGENT_PAT_BASE64),vstsAccount=$(VSTS_ACCOUNT),vstsPool="$(VSTS_POOL)",resources.requests.cpu=.5,resources.requests.memory=1Gi,resources.limits.cpu=1,resources.limits.memory=2Gi,replicas=$(AGENT_COUNT)'
valueFile: 'Docker/VSTS_AGENT/vsts-agent/charts/vsts-agent/values.yaml'
recreate: true
resetValues: true
tillerNamespace: tiller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment