Skip to content

Commit 909d52e

Browse files
committed
Init function chart
1 parent 7b2510e commit 909d52e

11 files changed

Lines changed: 718 additions & 0 deletions

File tree

charts/function/.helmignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
23+
# OWNERS file for Kubernetes
24+
OWNERS
25+
# example production yaml
26+
values-production.yaml
27+
# ci files
28+
ci/

charts/function/Chart.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies:
2+
- name: common
3+
repository: https://charts.bitnami.com/bitnami
4+
version: 1.11.1
5+
- name: redis
6+
repository: https://charts.bitnami.com/bitnami
7+
version: 16.4.0
8+
digest: sha256:18eac17e69c4871e29365d14fe5822d00dfeb97c5a2624407ad6c506b6542937
9+
generated: "2022-02-22T00:08:54.6743331+01:00"

charts/function/Chart.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: v2
2+
version: 0.0.1
3+
name: function
4+
description: Serverless Function
5+
appVersion: "1.0.0"
6+
type: application
7+
keywords:
8+
- shortener
9+
- url
10+
- bitly
11+
home: https://yourls.org
12+
icon: https://yourls.org/images/yourls-logo.png
13+
sources:
14+
- https://github.com/YOURLS/function
15+
- https://github.com/YOURLS/charts
16+
maintainers:
17+
- name: YOURLS
18+
19+
- name: LeoColomb
20+
21+
kubeVersion: ">=1.20.0-0"
22+
dependencies:
23+
- name: common
24+
repository: https://charts.bitnami.com/bitnami
25+
version: ^1.11.1
26+
tags:
27+
- bitnami-common
28+
- condition: redis.enabled
29+
name: redis
30+
repository: https://charts.bitnami.com/bitnami
31+
version: ^16.4.0
32+
tags:
33+
- function-database
34+
annotations:
35+
artifacthub.io/license: MIT
36+
artifacthub.io/links: |
37+
- name: Upstream Project
38+
url: https://github.com/YOURLS/function
39+
artifacthub.io/signKey: |
40+
fingerprint: 6FCD850E18E4A4FF76DD1184A3A42A61961E423F
41+
url: https://yourls.org/.well-known/openpgpkey/hu/6e4gbtp15q1znf3unweeducn7urty4mr
42+
artifacthub.io/changes: |
43+
- kind: added
44+
description: First version

charts/function/README.md

Whitespace-only changes.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Create a default fully qualified app name.
5+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
6+
*/}}
7+
{{- define "function.redis.fullname" -}}
8+
{{- include "common.names.dependency.fullname" (dict "chartName" "redis" "chartValues" .Values.redis "context" $) -}}
9+
{{- end -}}
10+
11+
{{/*
12+
Return the proper YOURLS image name
13+
*/}}
14+
{{- define "function.image" -}}
15+
{{- $imageRoot := .Values.image -}}
16+
{{- if not .Values.image.tag }}
17+
{{- $tag := (dict "tag" .Chart.AppVersion) -}}
18+
{{- $imageRoot := merge .Values.image $tag -}}
19+
{{- end -}}
20+
{{- include "common.images.image" (dict "imageRoot" $imageRoot "global" .Values.global) -}}
21+
{{- end -}}
22+
23+
{{/*
24+
Return the Function Secret Name
25+
*/}}
26+
{{- define "function.secretName" -}}
27+
{{- if .Values.function.existingSecret }}
28+
{{- printf "%s" .Values.function.existingSecret -}}
29+
{{- else -}}
30+
{{- printf "%s" (include "common.names.fullname" .) -}}
31+
{{- end -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Return the Redis™ hostname
36+
*/}}
37+
{{- define "function.redisHost" -}}
38+
{{- if .Values.redis.enabled }}
39+
{{- printf "%s-master" (include "function.redis.fullname" .) -}}
40+
{{- else -}}
41+
{{- printf "%s" .Values.externalDatabase.host -}}
42+
{{- end -}}
43+
{{- end -}}
44+
45+
{{/*
46+
Return the Redis™ port
47+
*/}}
48+
{{- define "function.redisPort" -}}
49+
{{- if .Values.redis.enabled }}
50+
{{- printf "6379" | quote -}}
51+
{{- else -}}
52+
{{- .Values.externalDatabase.port | quote -}}
53+
{{- end -}}
54+
{{- end -}}
55+
56+
{{/*
57+
Return true if a secret object for Redis™ should be created
58+
*/}}
59+
{{- define "function.redis.createSecret" -}}
60+
{{- if and (not .Values.redis.enabled) (not .Values.externalDatabase.existingSecret) .Values.externalDatabase.password }}
61+
{{- true -}}
62+
{{- end -}}
63+
{{- end -}}
64+
65+
{{/*
66+
Return the Redis™ secret name
67+
*/}}
68+
{{- define "function.redis.secretName" -}}
69+
{{- if .Values.redis.enabled }}
70+
{{- if .Values.redis.auth.existingSecret }}
71+
{{- printf "%s" .Values.redis.auth.existingSecret -}}
72+
{{- else -}}
73+
{{- printf "%s" (include "function.redis.fullname" .) -}}
74+
{{- end -}}
75+
{{- else if .Values.externalDatabase.existingSecret }}
76+
{{- printf "%s" .Values.externalDatabase.existingSecret -}}
77+
{{- else -}}
78+
{{- printf "%s-redis" (include "common.names.fullname" .) -}}
79+
{{- end -}}
80+
{{- end -}}
81+
82+
{{/*
83+
Return the Redis™ secret key
84+
*/}}
85+
{{- define "function.redis.secretPasswordKey" -}}
86+
{{- if and .Values.redis.enabled .Values.redis.auth.existingSecret }}
87+
{{- required "You need to provide existingSecretPasswordKey when an existingSecret is specified in redis" .Values.redis.auth.existingSecretPasswordKey | printf "%s" }}
88+
{{- else if and (not .Values.redis.enabled) .Values.externalDatabase.existingSecret }}
89+
{{- required "You need to provide existingSecretPasswordKey when an existingSecret is specified in redis" .Values.externalDatabase.existingSecretPasswordKey | printf "%s" }}
90+
{{- else -}}
91+
{{- printf "redis-password" -}}
92+
{{- end -}}
93+
{{- end -}}
94+
95+
{{/*
96+
Return whether Redis™ uses password authentication or not
97+
*/}}
98+
{{- define "function.redis.auth.enabled" -}}
99+
{{- if or (and .Values.redis.enabled .Values.redis.auth.enabled) (and (not .Values.redis.enabled) (or .Values.externalDatabase.password .Values.externalDatabase.existingSecret)) }}
100+
{{- true -}}
101+
{{- end -}}
102+
{{- end -}}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ template "common.names.fullname" . }}
5+
labels: {{- include "common.labels.standard" . | nindent 4 }}
6+
{{- if .Values.commonLabels }}
7+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
8+
{{- end }}
9+
{{- if .Values.commonAnnotations }}
10+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
data:
13+
REDIS_HOST: {{ template "function.redisHost" . }}
14+
REDIS_PORT_NUMBER: {{ template "function.redisPort" . }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if (include "function.redis.createSecret" .) }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}-redis
6+
labels: {{- include "common.labels.standard" . | nindent 4 }}
7+
{{- if .Values.commonLabels }}
8+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
9+
{{- end }}
10+
{{- if .Values.commonAnnotations }}
11+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
12+
{{- end }}
13+
type: Opaque
14+
data:
15+
redis-password: {{ .Values.externalDatabase.password | b64enc | quote }}
16+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if not .Values.function.existingSecret }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
{{- if .Values.commonLabels }}
9+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
10+
{{- end }}
11+
{{- if .Values.commonAnnotations }}
12+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
13+
{{- end }}
14+
type: Opaque
15+
data:
16+
endpoint: {{ .Values.function.endpoint | b64enc | quote }}
17+
token: {{ .Values.function.token | b64enc | quote }}
18+
{{- end }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: serving.knative.dev/v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "common.names.fullname" . }}
5+
namespace: {{ .Release.Namespace | quote }}
6+
labels: {{- include "common.labels.standard" . | nindent 4 }}
7+
{{- if .Values.commonLabels }}
8+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
9+
{{- end }}
10+
{{- if .Values.commonAnnotations }}
11+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
12+
{{- end }}
13+
spec:
14+
template:
15+
metadata:
16+
labels: {{- include "common.labels.standard" . | nindent 8 }}
17+
{{- if .Values.podLabels }}
18+
{{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
19+
{{- end }}
20+
{{- if or .Values.podAnnotations }}
21+
annotations:
22+
{{- if .Values.podAnnotations }}
23+
{{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
24+
{{- end }}
25+
{{- end }}
26+
spec:
27+
containers:
28+
- name: function
29+
image: {{ template "function.image" . }}
30+
env:
31+
{{- if (include "function.redis.auth.enabled" .) }}
32+
- name: REDIS_PASSWORD
33+
valueFrom:
34+
secretKeyRef:
35+
name: {{ include "function.redis.secretName" . }}
36+
key: {{ include "function.redis.secretPasswordKey" . }}
37+
{{- end }}
38+
- name: YOURLS_ENDPOINT
39+
valueFrom:
40+
secretKeyRef:
41+
name: {{ include "function.secretName" . }}
42+
key: endpoint
43+
- name: YOURLS_TOKEN
44+
valueFrom:
45+
secretKeyRef:
46+
name: {{ include "function.secretName" . }}
47+
key: token
48+
envFrom:
49+
- configMapRef:
50+
name: {{ include "common.names.fullname" . }}

0 commit comments

Comments
 (0)