From 56b971ca034f923ce4e36d3849841f40ce9ddfbb Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 11:11:20 +0100 Subject: [PATCH 1/9] Add support for additional env vars in agent --- README.md | 1 + templates/vsts-agent.yaml | 6 +++++- values.yaml | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d5c2d8b..9d74d49 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ The following tables lists the configurable parameters of the `vsts-agent` chart | `vstsPool` | VSTS agent pool name | `kubernetes-vsts-agents` | | `vstsAgentName` | VSTS agent name | `$HOSTNAME` | | `vstsWorkspace` | VSTS agent workspace | `/workspace` | +| `extraEnv` | Extra environment variables on the vsts-agent container | `nil` | ## Configure your VSTS instance diff --git a/templates/vsts-agent.yaml b/templates/vsts-agent.yaml index 902aef1..bd73901 100644 --- a/templates/vsts-agent.yaml +++ b/templates/vsts-agent.yaml @@ -36,7 +36,11 @@ spec: value: {{ .vstsAgentName | default "$HOSTNAME" }} - name: VSTS_WORK value: {{ .vstsWorkspace | default "/workspace" }} - {{- end }} + {{- end }} + {{- range $key, $value := .Values.extraEnv }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} volumeMounts: - name: docker-socket mountPath: /var/run/docker.sock diff --git a/values.yaml b/values.yaml index 090b55a..4090489 100644 --- a/values.yaml +++ b/values.yaml @@ -14,3 +14,5 @@ resources: memory: 8Gi disk: "50Gi" storageclass: "default" + +extraEnv: From 4dd7473eea570fb3a6719824eb46705da927061d Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 11:22:05 +0100 Subject: [PATCH 2/9] Add cleanRun variable to reset vsts-agent on build completion --- README.md | 1 + templates/vsts-agent.yaml | 10 ++++++++++ values.yaml | 2 ++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 9d74d49..1909528 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ The following tables lists the configurable parameters of the `vsts-agent` chart | `vstsAgentName` | VSTS agent name | `$HOSTNAME` | | `vstsWorkspace` | VSTS agent workspace | `/workspace` | | `extraEnv` | Extra environment variables on the vsts-agent container | `nil` | +| `cleanRun` | Kill and restart vsts-agent container on completion of a build (completely resets the environment) | `false` | ## Configure your VSTS instance diff --git a/templates/vsts-agent.yaml b/templates/vsts-agent.yaml index bd73901..4c74061 100644 --- a/templates/vsts-agent.yaml +++ b/templates/vsts-agent.yaml @@ -54,6 +54,16 @@ spec: requests: memory: {{ .Values.resources.requests.memory | quote }} cpu: {{ .Values.resources.requests.cpu | quote }} + {{ if .Values.cleanRun }} + livenessProbe: + exec: + command: + - /bin/sh + - -c + - "! ls /vsts/agent/_diag | grep Worker || pgrep Agent.Worker" + initialDelaySeconds: 120 + periodSeconds: 5 + {{ end }} volumes: - name: docker-socket hostPath: diff --git a/values.yaml b/values.yaml index 4090489..e6f4494 100644 --- a/values.yaml +++ b/values.yaml @@ -15,4 +15,6 @@ resources: disk: "50Gi" storageclass: "default" +cleanRun: false + extraEnv: From 8cbaa93aaa566e8e19bd30dcdb0c60e50b89ba2d Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 11:30:23 +0100 Subject: [PATCH 3/9] add volumes/volumeMounts variable This allows you to specify additional custom pod volumes and vsts-agent container volumeMounts in the deployment --- README.md | 2 ++ templates/vsts-agent.yaml | 8 ++------ values.yaml | 10 ++++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1909528..75cf2ac 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ The following tables lists the configurable parameters of the `vsts-agent` chart | `vstsWorkspace` | VSTS agent workspace | `/workspace` | | `extraEnv` | Extra environment variables on the vsts-agent container | `nil` | | `cleanRun` | Kill and restart vsts-agent container on completion of a build (completely resets the environment) | `false` | +| `volumes` | An array of custom volumes to attach to the vsts-agent pod | `docker-socket` to mount /var/run/docker.sock (if you still need this volume when defining addition ones, please ensure you reference it again in your list) | +| `volumeMounts` | volumeMounts to the vsts-agent container as referenced in `volumes` | A read-only `docker-socket` to mount as /var/run/docker.sock in vsts-agent container (as in `volumes` please reference this again if you still need it in your custom list) | ## Configure your VSTS instance diff --git a/templates/vsts-agent.yaml b/templates/vsts-agent.yaml index 4c74061..f40531f 100644 --- a/templates/vsts-agent.yaml +++ b/templates/vsts-agent.yaml @@ -42,11 +42,9 @@ spec: value: {{ $value | quote }} {{- end }} volumeMounts: - - name: docker-socket - mountPath: /var/run/docker.sock - readOnly: false - name: workspace mountPath: {{ .Values.vstsWorkspace | default "/workspace" }} +{{ toYaml .Values.volumeMounts | indent 10 }} resources: limits: memory: {{ .Values.resources.limits.memory | quote }} @@ -65,9 +63,7 @@ spec: periodSeconds: 5 {{ end }} volumes: - - name: docker-socket - hostPath: - path: /var/run/docker.sock +{{ toYaml .Values.volumes | indent 6 }} {{ if .Values.image.imagePullSecret }} imagePullSecrets: - name: {{ .Values.image.imagePullSecret }} diff --git a/values.yaml b/values.yaml index e6f4494..89fa121 100644 --- a/values.yaml +++ b/values.yaml @@ -17,4 +17,14 @@ resources: cleanRun: false +volumeMounts: +- name: docker-socket + mountPath: /var/run/docker.sock + readOnly: false + +volumes: +- name: docker-socket + hostPath: + path: /var/run/docker.sock + extraEnv: From a82994b4f18a53dd580abe13de0b132886963ad1 Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 11:32:53 +0100 Subject: [PATCH 4/9] Add extraContainers variable Allows you to sidecar additional containers in the vsts-agent pod --- README.md | 1 + templates/vsts-agent.yaml | 1 + values.yaml | 2 ++ 3 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 75cf2ac..d0f4331 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ The following tables lists the configurable parameters of the `vsts-agent` chart | `cleanRun` | Kill and restart vsts-agent container on completion of a build (completely resets the environment) | `false` | | `volumes` | An array of custom volumes to attach to the vsts-agent pod | `docker-socket` to mount /var/run/docker.sock (if you still need this volume when defining addition ones, please ensure you reference it again in your list) | | `volumeMounts` | volumeMounts to the vsts-agent container as referenced in `volumes` | A read-only `docker-socket` to mount as /var/run/docker.sock in vsts-agent container (as in `volumes` please reference this again if you still need it in your custom list) | +| `extraContainers` | Array of additional sidecar containers to add into the vsts-agent pod | `nil` | ## Configure your VSTS instance diff --git a/templates/vsts-agent.yaml b/templates/vsts-agent.yaml index f40531f..3bd7ac8 100644 --- a/templates/vsts-agent.yaml +++ b/templates/vsts-agent.yaml @@ -62,6 +62,7 @@ spec: initialDelaySeconds: 120 periodSeconds: 5 {{ end }} +{{ toYaml .Values.extra-containers | indent 6 }} volumes: {{ toYaml .Values.volumes | indent 6 }} {{ if .Values.image.imagePullSecret }} diff --git a/values.yaml b/values.yaml index 89fa121..861ec20 100644 --- a/values.yaml +++ b/values.yaml @@ -28,3 +28,5 @@ volumes: path: /var/run/docker.sock extraEnv: + +extraContainers: From deeadde03d81f2d8c6e196661b1760d67d225c66 Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 14:21:33 +0100 Subject: [PATCH 5/9] Move chart into its own dir and add package make task --- Makefile | 5 +++++ Chart.yaml => charts/vsts-agent/Chart.yaml | 0 .../vsts-agent/templates}/vsts-agent-secret.yaml | 0 .../vsts-agent/templates}/vsts-agent-svc.yaml | 0 {templates => charts/vsts-agent/templates}/vsts-agent.yaml | 0 values.yaml => charts/vsts-agent/values.yaml | 0 6 files changed, 5 insertions(+) create mode 100644 Makefile rename Chart.yaml => charts/vsts-agent/Chart.yaml (100%) rename {templates => charts/vsts-agent/templates}/vsts-agent-secret.yaml (100%) rename {templates => charts/vsts-agent/templates}/vsts-agent-svc.yaml (100%) rename {templates => charts/vsts-agent/templates}/vsts-agent.yaml (100%) rename values.yaml => charts/vsts-agent/values.yaml (100%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..966f70c --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +.PHONY: helm-package + +helm-package: + helm package charts/vsts-agent -d charts + helm repo index --merge charts/index.yaml charts diff --git a/Chart.yaml b/charts/vsts-agent/Chart.yaml similarity index 100% rename from Chart.yaml rename to charts/vsts-agent/Chart.yaml diff --git a/templates/vsts-agent-secret.yaml b/charts/vsts-agent/templates/vsts-agent-secret.yaml similarity index 100% rename from templates/vsts-agent-secret.yaml rename to charts/vsts-agent/templates/vsts-agent-secret.yaml diff --git a/templates/vsts-agent-svc.yaml b/charts/vsts-agent/templates/vsts-agent-svc.yaml similarity index 100% rename from templates/vsts-agent-svc.yaml rename to charts/vsts-agent/templates/vsts-agent-svc.yaml diff --git a/templates/vsts-agent.yaml b/charts/vsts-agent/templates/vsts-agent.yaml similarity index 100% rename from templates/vsts-agent.yaml rename to charts/vsts-agent/templates/vsts-agent.yaml diff --git a/values.yaml b/charts/vsts-agent/values.yaml similarity index 100% rename from values.yaml rename to charts/vsts-agent/values.yaml From c7efac7446375ad9fa5f71facc513b99593d0a11 Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 14:23:51 +0100 Subject: [PATCH 6/9] Rename chart to vsts-agent Don't really need helm- in the name? make helm-packge requires chart name to be same as chart dir name --- charts/vsts-agent/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/vsts-agent/Chart.yaml b/charts/vsts-agent/Chart.yaml index 2bcaa00..0b9b68f 100644 --- a/charts/vsts-agent/Chart.yaml +++ b/charts/vsts-agent/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -name: helm-vsts-agent +name: vsts-agent version: 1.0.0 description: Helm chart for Visual Studio Team Services agent pool maintainers: From 51ab07547092e6673eb018a0f894e170a0c9a1ae Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 16:01:13 +0100 Subject: [PATCH 7/9] Fix linting and indentation issues --- charts/vsts-agent/templates/vsts-agent.yaml | 14 +++++++++----- charts/vsts-agent/values.yaml | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/charts/vsts-agent/templates/vsts-agent.yaml b/charts/vsts-agent/templates/vsts-agent.yaml index 3bd7ac8..cd10b42 100644 --- a/charts/vsts-agent/templates/vsts-agent.yaml +++ b/charts/vsts-agent/templates/vsts-agent.yaml @@ -37,14 +37,16 @@ spec: - name: VSTS_WORK value: {{ .vstsWorkspace | default "/workspace" }} {{- end }} - {{- range $key, $value := .Values.extraEnv }} + {{- range $key, $value := .Values.extraEnv }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} volumeMounts: - name: workspace mountPath: {{ .Values.vstsWorkspace | default "/workspace" }} +{{- if .Values.volumeMounts }} {{ toYaml .Values.volumeMounts | indent 10 }} +{{ end }} resources: limits: memory: {{ .Values.resources.limits.memory | quote }} @@ -52,7 +54,7 @@ spec: requests: memory: {{ .Values.resources.requests.memory | quote }} cpu: {{ .Values.resources.requests.cpu | quote }} - {{ if .Values.cleanRun }} + {{- if .Values.cleanRun }} livenessProbe: exec: command: @@ -61,10 +63,12 @@ spec: - "! ls /vsts/agent/_diag | grep Worker || pgrep Agent.Worker" initialDelaySeconds: 120 periodSeconds: 5 - {{ end }} -{{ toYaml .Values.extra-containers | indent 6 }} + {{- end }} +{{ if .Values.extraContainers }} +{{ toYaml .Values.extraContainers | indent 6 }} +{{ end }} volumes: -{{ toYaml .Values.volumes | indent 6 }} +{{ toYaml .Values.volumes | indent 8 }} {{ if .Values.image.imagePullSecret }} imagePullSecrets: - name: {{ .Values.image.imagePullSecret }} diff --git a/charts/vsts-agent/values.yaml b/charts/vsts-agent/values.yaml index 861ec20..cb5bfa5 100644 --- a/charts/vsts-agent/values.yaml +++ b/charts/vsts-agent/values.yaml @@ -27,6 +27,6 @@ volumes: hostPath: path: /var/run/docker.sock -extraEnv: +extraEnv: {} -extraContainers: +extraContainers: [] From 9d5f6aa9bef54ef0d8fd7ec1ecddd64ef6b8b567 Mon Sep 17 00:00:00 2001 From: Ryan Grenz Date: Fri, 5 Oct 2018 16:06:15 +0100 Subject: [PATCH 8/9] Package vst-agent 1.0.0 --- charts/index.yaml | 15 +++++++++++++++ charts/vsts-agent-1.0.0.tgz | Bin 0 -> 1398 bytes 2 files changed, 15 insertions(+) create mode 100644 charts/index.yaml create mode 100644 charts/vsts-agent-1.0.0.tgz diff --git a/charts/index.yaml b/charts/index.yaml new file mode 100644 index 0000000..c12810e --- /dev/null +++ b/charts/index.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +entries: + vsts-agent: + - apiVersion: v1 + created: 2018-10-05T16:06:09.742522+01:00 + description: Helm chart for Visual Studio Team Services agent pool + digest: c13c24fad551693836f3f36188917230b861eb4ca10f4ba8aee38cf68d55151f + maintainers: + - email: msefoundations@microsoft.com + name: Microsoft Social Engagement + name: vsts-agent + urls: + - vsts-agent-1.0.0.tgz + version: 1.0.0 +generated: 2018-10-05T16:06:09.741511+01:00 diff --git a/charts/vsts-agent-1.0.0.tgz b/charts/vsts-agent-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a04aeecf8221d06e389d1b334c1bb0b17f05d028 GIT binary patch literal 1398 zcmV-+1&R6}iwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI-bZ`w!@&a?lDIn>7k39Pmwz0i74pi4PQBKSYcz=BUc0J$h>@2j=O)^7a+86gknbwj7{N!=XbzS$Y z-%oyB*RB4#y-w$()9dy7gR{ZeY4^nK^m^{;3Am5Uqt+sAh&pk9_+8b-y$~ZIyG5m$ z6do)(j*pru7MkSwE%E?p>=iJT3T~N>2#2wWd?sOnB!Drh1*51T@gNALt{-oEX&cQy6hRlAO_{2j~1NS!%~osAZ%m>KKu;fSKeU01YD# zPLsa@2FXiazhTL1zeK1H4)d9wd(h~+Z&<@|C`Tf0BH_W5aE*?$kUR?TN=CvY5h#ru zzNB+hO&$NljDxs;M9jSh?FCV76^V8_rWKD#*bsjx__6}L2lHO)6fz+lJ`C>QH>1d< zSa`77Y@aS<9ya0Qr>BZ%mi`R}Ve&z(58c#A75-pWa7h2%-k_rYvq86i)c;dh<@}#B z;d?MnKDra2AwDt0%Ma)s$JqAhkWlnswSv|SawHmC*I6@cHjY__=)o`~Um|oe$QW!Q z=P1&Nx9Rbdx5o3Hdw2f-c2NHd`okH);rzc>)qkgZJpZ4>9?*Z1*4G4pSg7eeG1hl1 z(eDcY0G!+*-=6Fw4C|nDh%_ERd87@hzeXNhOMwo6Mvl}-wRie+Z{>@$1NwiI+rR<+ z_uX#4qW?kfw0G41Q<$xP5{A0H=-iDR&k$$&Boj5He?2yO{0u6vaWPHGm873{eBdSVx0xy+wo-lc`|%= zd2Mw9B=v?rl?=R6bNnUZ)bbrJZ*W@e+n0%!ZH`N?$T5rV)v5_!nYqtaWG|q?`TXKy z`1kc>mvy=$G59&9@kMeE$Y?lxzYk#~C5JWmI3*D`(3nSes013+&0>+dv5)4P%L621 zh{Rc}_q=*L98a##uP*mNe;D4p+lTx?s(C7F3%UI@Yb`^^JCDNOX;VbZ5MIr3`769i zUI5;2xx-~w<$9K@RWh;MY17;SuHj204IbiCt{v>YE?-&cZB{Lza+CR<{fTL?X)(>B zkamNS|B!&!k5~f}J_-XJcRRYWq*56sGrJsu>m9{o4C?=R;g#Uq@EXPQt z@U;h>u4@emQ8DS~o&91jwobKL*}GDyTh)7Obx`iGgF1iBYitj>y#?@kmr;5;<>yyg z$SBY&9hSS Date: Fri, 5 Oct 2018 16:16:39 +0100 Subject: [PATCH 9/9] Fix .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba09d36..a36bcff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,5 @@ before_script: done script: -- helm lint . -- helm template . +- helm lint charts/vsts-agent +- helm template charts/vsts-agent