Skip to content

Commit

Permalink
[stable/mcrouter] create a template for api version (helm#22638)
Browse files Browse the repository at this point in the history
Signed-off-by: lwsanty <[email protected]>
  • Loading branch information
lwsanty authored and includerandom committed Jul 19, 2020
1 parent f984925 commit 3e117e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion stable/mcrouter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: mcrouter
home: https://github.com/facebook/mcrouter
version: 1.0.2
version: 1.0.3
appVersion: 0.36.0
description: Mcrouter is a memcached protocol router for scaling memcached deployments.
sources:
Expand Down
22 changes: 22 additions & 0 deletions stable/mcrouter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,25 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for daemonset.
*/}}
{{- define "daemonset.apiVersion" -}}
{{- if semverCompare "<1.9-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "^1.9-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for statefulset.
*/}}
{{- define "statefulset.apiVersion" -}}
{{- if semverCompare "<1.9-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "^1.9-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}
5 changes: 4 additions & 1 deletion stable/mcrouter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if eq .Values.controller "daemonset" }}
apiVersion: extensions/v1beta1
apiVersion: {{ template "daemonset.apiVersion" . }}
kind: DaemonSet
metadata:
name: {{ template "fullname" . }}
Expand All @@ -10,6 +10,9 @@ metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
selector:
matchLabels:
app: {{ template "fullname" . }}
template:
metadata:
labels:
Expand Down
2 changes: 1 addition & 1 deletion stable/mcrouter/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if eq .Values.controller "statefulset" }}
apiVersion: apps/v1beta1
apiVersion: {{ template "statefulset.apiVersion" . }}
kind: StatefulSet
metadata:
name: {{ template "fullname" . }}
Expand Down

0 comments on commit 3e117e5

Please sign in to comment.