Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Apr 15, 2023
2 parents a961e97 + 91ef556 commit 78efd67
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
26 changes: 19 additions & 7 deletions src/helm/azure-pipelines-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Expand the name of the chart.

{{/*
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.
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 "this.fullname" -}}
{{- if .Values.fullnameOverride }}
Expand All @@ -31,7 +31,7 @@ Create chart name and version as used by the chart label.
{{- end }}

{{/*
Common labels
Common labels.
*/}}
{{- define "this.labels" -}}
helm.sh/chart: {{ include "this.chart" . }}
Expand All @@ -43,15 +43,15 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

{{/*
Create the name of the service account to use
Create the name of the service account to use.
*/}}
{{- define "this.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
Expand All @@ -61,6 +61,17 @@ Create the name of the service account to use
{{- end }}
{{- end }}

{{/*
Common definition for Pod object.
Usage example:
{{- $data := dict
"restartPolicy" "Always"
"azpAgentName" (dict "value" (printf "%s-%s" (include "this.fullname" .) "template"))
}}
{{- include "this.podSharedTemplate" (merge (dict "Args" $data) . ) | nindent 6 }}
*/}}
{{- define "this.podSharedTemplate" -}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -76,6 +87,7 @@ initContainers:
{{- toYaml . | nindent 2 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.pipelines.timeout | int | required "A value for .Values.pipelines.timeout is required" }}
restartPolicy: {{ .Args.restartPolicy }}
containers:
- name: azp-agent
securityContext:
Expand All @@ -88,12 +100,12 @@ containers:
lifecycle:
preStop:
exec:
command: [bash, -c, "bash ${AZP_HOME}/config.sh remove --auth PAT --token $AZP_TOKEN"]
command: [bash, -c, "bash ${AZP_HOME}/config.sh remove --auth PAT --token ${AZP_TOKEN}"]
env:
- name: VSO_AGENT_IGNORE
value: AZP_TOKEN
- name: AZP_AGENT_NAME
value: {{ include "this.fullname" . }}-template
{{- toYaml .Args.azpAgentName | nindent 8 }}
- name: AZP_URL
valueFrom:
secretKeyRef:
Expand Down
15 changes: 11 additions & 4 deletions src/helm/azure-pipelines-agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "this.fullname" . }}-{{ .Release.Revision }}
name: {{ include "this.fullname" . }}
labels:
{{- include "this.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "this.selectorLabels" . | nindent 6 }}
replicas: {{ .Values.replicaCount | int | required "A value for .Values.replicaCount is required" }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 50%
maxUnavailable: 0
template:
metadata:
labels:
Expand All @@ -21,7 +26,9 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
# The pod will shut down at each run, we need to restart it
restartPolicy: Always
{{- include "this.podSharedTemplate" . | nindent 6 }}
{{- $data := dict
"restartPolicy" "Always"
"azpAgentName" (dict "valueFrom" (dict "fieldRef" (dict "apiVersion" "v1" "fieldPath" "metadata.name" )))
}}
{{- include "this.podSharedTemplate" (merge (dict "Args" $data) . ) | nindent 6 }}
{{- end }}
8 changes: 5 additions & 3 deletions src/helm/azure-pipelines-agent/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ spec:
{{- toYaml . | nindent 10 }}
{{- end }}
spec:
# The job cannot crash, this is not functionally intended; a shutdown is functionally a pipeline end
restartPolicy: Never
{{- include "this.podSharedTemplate" . | nindent 8 }}
{{- $data := dict
"restartPolicy" "Never"
"azpAgentName" (dict "valueFrom" (dict "fieldRef" (dict "apiVersion" "v1" "fieldPath" "metadata.name" )))
}}
{{- include "this.podSharedTemplate" (merge (dict "Args" $data) . ) | nindent 8 }}
maxReplicaCount: {{ .Values.autoscaling.maxReplicas | int | required "A value for .Values.autoscaling.maxReplicas is required" }}
minReplicaCount: 0
pollingInterval: 15
Expand Down
8 changes: 5 additions & 3 deletions src/helm/azure-pipelines-agent/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
# This agent is a template, we privilegiate Jobs instead of it, but we need to run it first
restartPolicy: Never
{{- include "this.podSharedTemplate" . | nindent 2 }}
{{- $data := dict
"restartPolicy" "Never"
"azpAgentName" (dict "value" (printf "%s-%s" (include "this.fullname" .) "template"))
}}
{{- include "this.podSharedTemplate" (merge (dict "Args" $data) . ) | nindent 2 }}
{{- end }}

0 comments on commit 78efd67

Please sign in to comment.