Skip to content

Commit

Permalink
pass config.yaml to gradle cache
Browse files Browse the repository at this point in the history
  • Loading branch information
slamdev committed Dec 30, 2021
1 parent d5a8a97 commit 3e2d1e6
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 20 deletions.
4 changes: 2 additions & 2 deletions charts/gradle-cache/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions charts/gradle-cache/README.md
Original file line number Diff line number Diff line change
@@ -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/).

Expand All @@ -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 |
Expand All @@ -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 |
11 changes: 11 additions & 0 deletions charts/gradle-cache/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down
25 changes: 19 additions & 6 deletions charts/gradle-cache/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
10 changes: 10 additions & 0 deletions charts/gradle-cache/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
39 changes: 30 additions & 9 deletions charts/gradle-cache/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3e2d1e6

Please sign in to comment.