Add a Kubernetes Helm chart

This commit is contained in:
David Dyball
2020-06-30 12:06:57 +01:00
parent 7cef0de42d
commit de9b1e3ee0
8 changed files with 492 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
+5
View File
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Spotify Backstage
name: backstage
version: 0.1.1-alpha.12
+51
View File
@@ -0,0 +1,51 @@
# Backstage Helm Chart
## App/Frontend Values
| Parameter | Description | Default |
| --------------------------- | --------------------------------------------------------- | ------------------- |
| app.enabled | Whether to render the frontend app config or not | `true` |
| app.nameOverride | Override the name given to the app/frontend | `""` |
| app.fullnameOverride | Override the full name of the app/frontend | `""` |
| app.replicaCount | The number of replicas for the app/frontend | `1` |
| app.image.repository | The image repository of the app/frontend container | `spotify/backstage` |
| app.image.tag | The app/frontend tag to pull | `latest` |
| app.image.pullPolicy | Image pull policy | `Always` |
| app.service.type | The service type for the app/frontend service | `ClusterIP` |
| app.service.port | The port for the app/frontend | `80` |
| app.ingress.enabled | Whether to create ingress or not | `false` |
| app.ingress.annotations | Annotations for the app/frontend ingress | `{}` |
| app.ingress.hosts[].host | Hostname for the app/frontend | `backstage.local` |
| app.ingress.hosts[].paths[] | Path name to serve the app/frontend on | `["/"]` |
| app.imagePullSecrets[] | Any image secrets you need to pull `app.image.repository` | `[]` |
| app.podSecurityContext | Security context for the app/frontend pods | `{}` |
| app.securityContext | Security context settings for the deployment | `{}` |
| app.resources | Kubernetes Pod resource requests/limits | `{}` |
| app.nodeSelector | Node selectors for scheduling app/frontend pods | `{}` |
| app.tolerations | Tolerations for scheduling app/frontend pods | `{}` |
| app.affinity | Affinity setttings for scheduling app/frontend pods | `{}` |
## Backend Values
| Parameter | Description | Default |
| ------------------------------- | ------------------------------------------------------------- | ------------------- |
| backend.enabled | Whether to render the backend config or not | `true` |
| backend.nameOverride | Override the name given to the backend | `""` |
| backend.fullnameOverride | Override the full name of the backend | `""` |
| backend.replicaCount | The number of replicas for the backend | `1` |
| backend.image.repository | The image repository of the backend container | `spotify/backstage` |
| backend.image.tag | The backend tag to pull | `latest` |
| backend.image.pullPolicy | Image pull policy | `Always` |
| backend.service.type | The service type for the backend service | `ClusterIP` |
| backend.service.port | The port for the backend | `80` |
| backend.ingress.enabled | Whether to create ingress or not | `false` |
| backend.ingress.annotations | Annotations for the backend ingress | `{}` |
| backend.ingress.hosts[].host | Hostname for the backend | `backstage.local` |
| backend.ingress.hosts[].paths[] | Path name to serve the backend on | `["/"]` |
| backend.imagePullSecrets[] | Any image secrets you need to pull `backend.image.repository` | `[]` |
| backend.podSecurityContext | Security context for the backend pods | `{}` |
| backend.securityContext | Security context settings for the deployment | `{}` |
| backend.resources | Kubernetes Pod resource requests/limits | `{}` |
| backend.nodeSelector | Node selectors for scheduling backend pods | `{}` |
| backend.tolerations | Tolerations for scheduling backend pods | `{}` |
| backend.affinity | Affinity setttings for scheduling backend pods | `{}` |
@@ -0,0 +1,80 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "backstage.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "backstage.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "backstage.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common App labels
*/}}
{{- define "backstage.app.labels" -}}
app.kubernetes.io/name: {{ include "backstage.name" . }}-app
helm.sh/chart: {{ include "backstage.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Common Backend labels
*/}}
{{- define "backstage.backend.labels" -}}
app.kubernetes.io/name: {{ include "backstage.name" . }}-backend
helm.sh/chart: {{ include "backstage.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Create the name of the service account to use for the app
*/}}
{{- define "backstage.app.serviceAccountName" -}}
{{- if .Values.app.serviceAccount.create -}}
{{ default "default" .Values.app.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.app.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use for the backend
*/}}
{{- define "backstage.backend.serviceAccountName" -}}
{{- if .Values.backend.serviceAccount.create -}}
{{ default default .Values.backend.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.backend.serviceAccount.name }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,119 @@
{{- if .Values.app.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "backstage.fullname" . }}-app
labels:
{{ include "backstage.app.labels" . | indent 4 }}
spec:
replicas: {{ .Values.app.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "backstage.name" . }}-app
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "backstage.name" . }}-app
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.app.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "backstage.app.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.app.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-app
securityContext:
{{- toYaml .Values.app.securityContext | nindent 12 }}
image: "{{ .Values.app.image.repository }}:{{ .Values.app.image.tag }}"
imagePullPolicy: {{ .Values.app.image.pullPolicy }}
ports:
- name: app
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.app.resources | nindent 12 }}
{{- with .Values.app.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.app.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.app.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.backend.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "backstage.fullname" . }}-backend
labels:
{{ include "backstage.backend.labels" . | indent 4 }}
spec:
replicas: {{ .Values.backend.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "backstage.name" . }}-backend
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "backstage.name" . }}-backend
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.backend.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "backstage.backend.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.backend.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-backend
securityContext:
{{- toYaml .Values.backend.securityContext | nindent 12 }}
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}"
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
ports:
- name: backend
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: backend
readinessProbe:
httpGet:
path: /
port: backend
resources:
{{- toYaml .Values.backend.resources | nindent 12 }}
{{- with .Values.backend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.backend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.backend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,83 @@
{{- if .Values.app.ingress.enabled -}}
{{- $fullName := include "backstage.fullname" . -}}
{{- $svcPort := .Values.app.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}-app
labels:
{{ include "backstage.app.labels" . | indent 4 }}
{{- with .Values.app.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.app.ingress.tls }}
tls:
{{- range .Values.app.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.app.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}-app
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{ end }}
{{- if .Values.backend.ingress.enabled }}
---
{{- $fullName := include "backstage.fullname" . -}}
{{- $svcPort := .Values.backend.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}-backend
labels:
{{ include "backstage.backend.labels" . | indent 4 }}
{{- with .Values.backend.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.backend.ingress.tls }}
tls:
{{- range .Values.backend.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.backend.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}-backend
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{ end }}
@@ -0,0 +1,37 @@
{{- if .Values.app.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "backstage.fullname" . }}-app
labels:
{{ include "backstage.app.labels" . | indent 4 }}
spec:
type: {{ .Values.app.service.type }}
ports:
- port: {{ .Values.app.service.port }}
targetPort: app
protocol: TCP
name: app
selector:
app.kubernetes.io/name: {{ include "backstage.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- if .Values.app.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "backstage.fullname" . }}-backend
labels:
{{ include "backstage.backend.labels" . | indent 4 }}
spec:
type: {{ .Values.backend.service.type }}
ports:
- port: {{ .Values.backend.service.port }}
targetPort: backend
protocol: TCP
name: backend
selector:
app.kubernetes.io/name: {{ include "backstage.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
+95
View File
@@ -0,0 +1,95 @@
app:
enabled: true
nameOverride: ""
fullnameOverride: ""
replicaCount: 1
serviceAccount:
create: false
Name: ""
image:
repository: spotify/backstage
tag: latest
pullPolicy: Always
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: "nginx"
hosts:
- host: backstage.local
paths:
- /
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
imagePullSecrets: []
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
backend:
enabled: false
nameOverride: ""
fullnameOverride: ""
replicaCount: 1
serviceAccount:
create: false
Name: ""
image:
repository: spotify/backstage-backend
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 7000
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: "nginx"
hosts:
- host: backstage.local
paths:
- /backend
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
imagePullSecrets: []
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}