Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #39 from bradmccoydev/feat/add-ghcr-to-helm
Browse files Browse the repository at this point in the history
Enable ingress on helm chart
  • Loading branch information
bradmccoydev authored Nov 9, 2022
2 parents 902db11 + 051f0e5 commit 4b47224
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 12 deletions.
4 changes: 2 additions & 2 deletions chart/backstage/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for the Ortelius Backstage Instance

type: application

version: 0.0.1
appVersion: "0.0.1"
version: 0.0.2
appVersion: "0.0.2"

home: "https://ortelius.io"
icon: https://backstage.io/img/twitter-summary.png
Expand Down
6 changes: 6 additions & 0 deletions chart/backstage/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ data:
GITHUB_TOKEN:
```
To Create the secret for ghcr
```bash
kubectl create secret docker-registry ghcr --docker-server=ghcr.io --docker-username=bradmccoydev --docker-password=<enter-here> [email protected] -n backstage
```

### 2. Add Helm Repo

```bash
Expand Down
90 changes: 90 additions & 0 deletions chart/backstage/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{{/*
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 labels
*/}}
{{- define "backstage.labels" -}}
helm.sh/chart: {{ include "backstage.chart" . }}
{{ include "backstage.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "backstage.selectorLabels" -}}
app.kubernetes.io/name: {{ include "backstage.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/* Get Ingress API Version */}}
{{- define "backstage.ingress.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}}
{{- print "networking.k8s.io/v1" -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/* Check Ingress stability */}}
{{- define "backstage.ingress.isStable" -}}
{{- eq (include "backstage.ingress.apiVersion" .) "networking.k8s.io/v1" -}}
{{- end -}}

{{/* Check Ingress supports pathType */}}
{{/* pathType was added to networking.k8s.io/v1beta1 in Kubernetes 1.18 */}}
{{- define "backstage.ingress.supportsPathType" -}}
{{- or (eq (include "backstage.ingress.isStable" .) "true") (and (eq (include "backstage.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}}

{{/* Get PodDisruptionBudget API Version */}}
{{- define "backstage.pdb.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}}
{{- print "policy/v1" -}}
{{- else -}}
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified app name for the postgres requirement.
*/}}
{{- define "backstage.postgresql.fullname" -}}
{{- $postgresContext := dict "Values" .Values.postgresql "Release" .Release "Chart" (dict "Name" "postgresql") -}}
{{ template "postgresql.primary.fullname" $postgresContext }}
{{- end -}}
22 changes: 12 additions & 10 deletions chart/backstage/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ fullnameOverride: ""
app:
image:
# -- App image repository.
repository: ghcr.io/mcwarman/backstage-sample-app/app
repository: ghcr.io/ortelius/backstage/app
# -- App image tag @default -- `{{ .Chart.AppVersion }}`
tag: ""
tag: "0.0.1"
# -- App image pull policy.
pullPolicy: IfNotPresent
# -- App image pull secrets.
pullSecrets: []
pullSecrets:
- name: ghcr

serviceAccount:
# -- App if `true`, create a new service account.
Expand Down Expand Up @@ -82,7 +83,7 @@ app:

ingress:
# -- App if `true`, create an ingress object.
enabled: false
enabled: true
# -- App ingress annotations.
annotations:
kubernetes.io/ingress.class: nginx
Expand Down Expand Up @@ -127,14 +128,14 @@ app:
backend:
image:
# -- Backend image repository.
repository: ghcr.io/mcwarman/backstage-sample-app/backend
repository: ghcr.io/ortelius/backstage/backend
# -- Backend image tag @default -- `{{ .Chart.AppVersion }}`
tag: ""
tag: "0.0.1"
# -- Backend image pull policy.
pullPolicy: IfNotPresent
# -- Backend image pull secrets.
pullSecrets: []

pullSecrets:
- name: ghcr

serviceAccount:
# -- Backend if `true`, create a new service account.
Expand Down Expand Up @@ -169,7 +170,8 @@ backend:
podAnnotations: {}

# -- Backend labels to add to the pod.
podLabels: {}
podLabels:
app.kubernetes.io/component: backend

# -- Backend security context for the container.
securityContext: {}
Expand Down Expand Up @@ -259,7 +261,7 @@ postgresql:
# @default -- see values.yaml
appConfig:
app:
title: Scaffoled Backstage App
title: Ortelius Backstage
baseUrl: http://localhost:8080
organization: {}
backend:
Expand Down

0 comments on commit 4b47224

Please sign in to comment.