Skip to content

Commit

Permalink
Merge pull request #226 from devtron-labs/helm-tls-certs
Browse files Browse the repository at this point in the history
feat: Added helm-tls-certs
  • Loading branch information
prakarsh-dt authored Jun 6, 2024
2 parents 5d64e01 + 3eeeb21 commit 803e027
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions charts/helm-tls-certs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: helm-tls-certs
description: A Helm chart for generating TLS secrets
type: application
version: 0.1.0
appVersion: 0.1.0
10 changes: 10 additions & 0 deletions charts/helm-tls-certs/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{/*
Generate a certificate pair
*/}}
{{- define "devtron.gen-certs" -}}
{{- $ca := genCA "devtron-ca" (int .Values.certDays) -}}
{{- $cn := .Values.commonName | default (printf "%s.%s" .Release.Name .Release.Namespace) -}}
{{- $cert := genSignedCert $cn nil nil (int .Values.certDays) $ca -}}
tls.crt: {{ $cert.Cert | b64enc }}
tls.key: {{ $cert.Key | b64enc }}
{{- end -}}
17 changes: 17 additions & 0 deletions charts/helm-tls-certs/templates/tls-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
name: {{ .Values.secretName }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
annotations:
"helm.sh/hook": "pre-install"
"helm.sh/hook-delete-policy": "before-hook-creation"
data:
{{ (include "devtron.gen-certs" . ) | indent 2 }}
9 changes: 9 additions & 0 deletions charts/helm-tls-certs/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Name of the secret to be created
secretName: tls-secret

# Number of days for the certificate validity
certDays: 2555

# Common Name for the certificate (optional)
# If not set, it will use <release-name>.<release-namespace>
commonName: ""

0 comments on commit 803e027

Please sign in to comment.