Skip to content

Commit

Permalink
Merge pull request #1 from tomtom-international/feat/ado-agents-chart
Browse files Browse the repository at this point in the history
feat: azure-devops-agent chart added
  • Loading branch information
SajadOrouji-TomTom authored Aug 7, 2023
2 parents 910e2eb + adc4e6e commit 1809cdc
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/azure-devops-agents/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/azure-devops-agents/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: azure-devops-agents
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
62 changes: 62 additions & 0 deletions charts/azure-devops-agents/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "azure-devops-agents.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "azure-devops-agents.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "azure-devops-agents.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "azure-devops-agents.labels" -}}
helm.sh/chart: {{ include "azure-devops-agents.chart" . }}
{{ include "azure-devops-agents.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "azure-devops-agents.selectorLabels" -}}
app.kubernetes.io/name: {{ include "azure-devops-agents.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "azure-devops-agents.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "azure-devops-agents.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
52 changes: 52 additions & 0 deletions charts/azure-devops-agents/templates/scaledjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: {{ include "azure-devops-agents.fullname" . }}
spec:
jobTargetRef:
template:
spec:
restartPolicy: Never
containers:
- name: {{ include "azure-devops-agents.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
command: ["./start.sh"]
args: ["--once"]
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: AZP_URL
value: {{ .Values.agentPoolInfo.url }}
- name: AZP_POOL
value: {{ .Values.agentPoolInfo.poolname }}
- name: AZP_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "azure-devops-agents.fullname" . }}
key: AZP_TOKEN
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
securityContext:
privileged: {{ .Values.agentPoolInfo.privileged }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- toYaml .Values.volumeMounts | nindent 10 }}
volumes:
{{- toYaml .Values.volumes | nindent 8 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- toYaml .Values.autoscaling | nindent 2 }}
scalingStrategy:
strategy: "default"
triggers:
- type: azure-pipelines
metadata:
poolID: "{{ .Values.agentPoolInfo.poolID }}"
organizationURLFromEnv: "AZP_URL"
personalAccessTokenFromEnv: "AZP_TOKEN"
15 changes: 15 additions & 0 deletions charts/azure-devops-agents/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.secret.create -}}
apiVersion: v1
kind: Secret
type: "Opaque"
data:
AZP_TOKEN: {{ .Values.secret.token | b64enc | quote }}
metadata:
name: {{ include "azure-devops-agents.fullname" . }}
labels:
{{- include "azure-devops-agents.labels" . | nindent 4 }}
{{- with .Values.secret.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/azure-devops-agents/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "azure-devops-agents.fullname" . }}-test-connection"
labels:
{{- include "azure-devops-agents.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "azure-devops-agents.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
61 changes: 61 additions & 0 deletions charts/azure-devops-agents/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Default values for azure-devops-agents.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

image:
repository: mcr.microsoft.com/azure-pipelines/vsts-agent
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

service:
type: ClusterIP
port: 80

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

autoscaling:
# maxReplicaCount: 100
# minReplicaCount: 1 # cannot start from 0
# pollingInterval: 30
# successfulJobsHistoryLimit: 0
# failedJobsHistoryLimit: 5

nodeSelector:
agentpool: additionalpool

agentPoolInfo:
url: "https://dev.azure.com/myorg"
poolname: "keda self-hosted"
poolID: "2"

secret:
create: true
token: "mytoken"

volumeMounts:
- name: work-disk
mountPath: /mnt

volumes:
- name: work-disk
emptyDir: {}

readinessProbe:
initialDelaySeconds: 120
periodSeconds: 60
successThreshold: 1
failureThreshold: 5
timeoutSeconds: 10

0 comments on commit 1809cdc

Please sign in to comment.