From 3e2d1e65778ec05cfad4d49a6e7b4302033bac8a Mon Sep 17 00:00:00 2001 From: Valentin Fedoskin Date: Thu, 30 Dec 2021 22:24:36 +0100 Subject: [PATCH] pass config.yaml to gradle cache --- charts/gradle-cache/Chart.yaml | 4 +- charts/gradle-cache/README.md | 9 +++-- charts/gradle-cache/templates/_helpers.tpl | 11 ++++++ charts/gradle-cache/templates/deployment.yaml | 25 +++++++++--- charts/gradle-cache/templates/secret.yaml | 10 +++++ charts/gradle-cache/values.yaml | 39 ++++++++++++++----- 6 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 charts/gradle-cache/templates/secret.yaml diff --git a/charts/gradle-cache/Chart.yaml b/charts/gradle-cache/Chart.yaml index cb67b61..2300e13 100644 --- a/charts/gradle-cache/Chart.yaml +++ b/charts/gradle-cache/Chart.yaml @@ -3,8 +3,8 @@ name: gradle-cache description: |- Helm chart to deploy [gradle-cache](https://docs.gradle.com/build-cache-node/). type: application -version: 0.0.15 -appVersion: "10.3" +version: 0.1.0 +appVersion: "11.0" home: https://github.com/slamdev/helm-charts/tree/master/charts/gradle-cache icon: https://gradle.org/icon/favicon-32x32.png maintainers: diff --git a/charts/gradle-cache/README.md b/charts/gradle-cache/README.md index 98b4387..81087f6 100644 --- a/charts/gradle-cache/README.md +++ b/charts/gradle-cache/README.md @@ -1,6 +1,6 @@ # gradle-cache -![Version: 0.0.15](https://img.shields.io/badge/Version-0.0.15-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 10.3](https://img.shields.io/badge/AppVersion-10.3-informational?style=flat-square) +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 11.0](https://img.shields.io/badge/AppVersion-11.0-informational?style=flat-square) Helm chart to deploy [gradle-cache](https://docs.gradle.com/build-cache-node/). @@ -17,6 +17,10 @@ Helm chart to deploy [gradle-cache](https://docs.gradle.com/build-cache-node/). | Key | Type | Default | Description | |-----|------|---------|-------------| | affinity | object | `{}` | affinity for scheduler pod assignment | +| args | list | `["start","--no-warn-anon-cache-write","--no-warn-anon-ui-access"]` | args to pass to the container | +| configSecret.content | string | `"version: 4\ncache:\n accessControl:\n anonymousLevel: readwrite\n maxEntryAgeInHours: null\n freeSpaceBufferSize: 1024\n maxArtifactSize: 100\n targetSize:\n type: fixed\n size: 10000\nuiAccess:\n type: open"` | | +| configSecret.create | bool | `true` | specifies whether a secret should be created | +| configSecret.name | string | `nil` | the name of the secret to use; if not set and create is true, a name is generated using the fullname template | | env | list | `[]` | additional environment variables for the deployment | | fullnameOverride | string | `""` | full name of the chart. | | image.pullPolicy | string | `"IfNotPresent"` | image pull policy | @@ -43,5 +47,4 @@ Helm chart to deploy [gradle-cache](https://docs.gradle.com/build-cache-node/). | serviceAccount.create | bool | `false` | specifies whether a service account should be created | | serviceAccount.name | string | `nil` | the name of the service account to use; if not set and create is true, a name is generated using the fullname template | | tolerations | list | `[]` | tolerations for scheduler pod assignment | -| volumeMounts | list | `[]` | additional volume mounts | -| volumes | list | `[]` | additional volumes | +| volumes | list | `[{"emptyDir":{},"name":"cache"}]` | volumes | diff --git a/charts/gradle-cache/templates/_helpers.tpl b/charts/gradle-cache/templates/_helpers.tpl index ff23a3a..b73c95b 100644 --- a/charts/gradle-cache/templates/_helpers.tpl +++ b/charts/gradle-cache/templates/_helpers.tpl @@ -62,6 +62,17 @@ Create the name of the service account to use {{- end -}} {{- end -}} +{{/* +Create the name of the config secret to use +*/}} +{{- define "gradle-cache.configSecretName" -}} +{{- if .Values.configSecret.create -}} + {{ default (include "gradle-cache.fullname" .) .Values.configSecret.name }} +{{- else -}} + {{ default "default" .Values.configSecret.name }} +{{- end -}} +{{- end -}} + {{/* Create the tag for the docker image to use */}} diff --git a/charts/gradle-cache/templates/deployment.yaml b/charts/gradle-cache/templates/deployment.yaml index a6963bb..a28094a 100644 --- a/charts/gradle-cache/templates/deployment.yaml +++ b/charts/gradle-cache/templates/deployment.yaml @@ -22,11 +22,24 @@ spec: serviceAccountName: {{ include "gradle-cache.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: config-mounter + image: busybox:1.33.0 + command: + - sh + - -ce + - cp /tmp/config.yaml /data/conf/config.yaml + volumeMounts: + - name: tmp-build-cache-config-file + mountPath: /tmp + - name: cache + mountPath: /data containers: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ include "gradle-cache.tag" . }}" + args: {{ .Values.args | toYaml | nindent 12 }} imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http @@ -42,14 +55,14 @@ spec: env: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.volumeMounts }} volumeMounts: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.volumes }} + - name: cache + mountPath: /data volumes: - {{- toYaml . | nindent 8 }} - {{- end }} + - name: tmp-build-cache-config-file + secret: + secretName: {{ include "gradle-cache.configSecretName" . }} + {{- .Values.volumes | toYaml | nindent 8 }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/gradle-cache/templates/secret.yaml b/charts/gradle-cache/templates/secret.yaml new file mode 100644 index 0000000..806dcb8 --- /dev/null +++ b/charts/gradle-cache/templates/secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "gradle-cache.configSecretName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "gradle-cache.labels" . | nindent 4 }} +data: + config.yaml: |- + {{ .Values.configSecret.content | nindent 4 }} diff --git a/charts/gradle-cache/values.yaml b/charts/gradle-cache/values.yaml index bd06af4..61f573d 100644 --- a/charts/gradle-cache/values.yaml +++ b/charts/gradle-cache/values.yaml @@ -13,6 +13,32 @@ nameOverride: "" # fullnameOverride -- full name of the chart. fullnameOverride: "" +configSecret: + # configSecret.create -- specifies whether a secret should be created + create: true + # configSecret.name -- the name of the secret to use; if not set and create is true, a name is generated using the fullname template + name: + # configSecret.content - content of 'config.yaml' + content: |- + version: 4 + cache: + accessControl: + anonymousLevel: readwrite + maxEntryAgeInHours: null + freeSpaceBufferSize: 1024 + maxArtifactSize: 100 + targetSize: + type: fixed + size: 10000 + uiAccess: + type: open + +# args -- args to pass to the container +args: + - start + - --no-warn-anon-cache-write + - --no-warn-anon-ui-access + serviceAccount: # serviceAccount.create -- specifies whether a service account should be created create: false @@ -79,15 +105,10 @@ tolerations: [] # affinity -- affinity for scheduler pod assignment affinity: {} -# volumeMounts -- additional volume mounts -volumeMounts: [] - # - name: cache - # mountPath: /data - -# volumes -- additional volumes -volumes: [] - # - name: cache - # emptyDir: {} +# volumes -- volumes +volumes: + - name: cache + emptyDir: {} livenessProbe: httpGet: