Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
Issue #3, Software Template for Backstage
Browse files Browse the repository at this point in the history
  • Loading branch information
mlacourse committed Sep 28, 2022
1 parent 496d963 commit 23bf9c4
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 108 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ helm install my-gitops -f my-values.yaml charts/gitops-operator
For more info on each chart checkout these!
* [gitops-operator](/charts/gitops-operator)
* [pipelines-operator](/charts/pipelines-operator)
* [assemble-backsrage](/charts/assemble-backstage)
84 changes: 68 additions & 16 deletions charts/assemble-backstage/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# ⚓️ Openshift Pipelines Operator Helm Deploy
# ⚓️ Assemble Backstage Helm Deploy

The Openshift Pipelines Helm Chart customizes and deploys the [RedHat Openshift Pipelines Operator](https://docs.openshift.com/container-platform/4.10/cicd/pipelines/installing-pipelines.html) written by Red Hat.
The Assemble Backstage Helm Chart customizes and deploys the backstage backend application written by Red Hat.

## Installing the chart

To install the chart from source:
```bash
# within this directory
oc new-project assemble-pipelines
helm upgrade --install pipelines . -f values.yaml
oc new-project assemble
helm upgrade --install assemble-dev . -f values.yaml
```
To install using oc apply
```bash
# within this directory
helm template pipelines --set ignoreHelmHooks=true . | oc apply -f-
helm template assemble-dev . | oc apply -f-
```

## Configuration
Expand All @@ -22,28 +22,80 @@ The [values.yml](values.yaml) file contains instructions for common chart overri

The operator version can be configuring by modifying the operator configuration values. The startingCSV could be different based on the openshift cluster version. The channel can be latest, stable or a specific version.

### Postgres Database Configuration

A container version of postgresql will be deployed along with the assamble-backstage application when the external flag is 'false'. You can
suppply a database password or a random value can be used and stored in the postgres secret.

```yaml
# operator manages upgrades
operator:
channel: latest
installPlanApproval: Automatic
name: openshift-pipelines-operator-rh
sourceName: redhat-operators
sourceNamespace: openshift-marketplace
startingCSV: openshift-pipelines-operator-rh.v1.8.0
postgres:
external: false
database_user: postgres
## Password will be autogenerated if left empty
## If using extrnal instance supply the password
#database_password: "somepassword"
port: 5432
image: registry.redhat.io/rhel9/postgresql-13:1-73
resources:
limits:
cpu: 400m
memory: 596Mi
requests:
cpu: 100m
memory: 128Mi
```
### Backstage Configuration

There is a secret which containts the backstage app-config.yaml which can be modified using the following sample.

The 'catalog:' section will define the soures for configuring the catalog section of the app-config.yaml. This content will replace the yaml of that section of the configuraiton. Refer to [Backstage Catalog Configuration](https://backstage.io/docs/features/software-catalog/configuration) for more details.

---
**NOTE**
The baseUrl must match the exposed route to ensure communication betweeen the UI and backend services.
---

```yaml
# backstage configuration
backstage:
companyname: "My Company"
baseUrl: 'https://assemble-dev-assemble.apps-crc.testing'

## Override Catalog with here
catalog:
#import:
# entityFilename: /examples/catalog-info.yaml
# pullRequestBranchName: backstage-integration
rules:
- allow: [Component, System, API, Resource, Location]
locations:
# Local example data, file locations are relative to the backend process, typically `packages/backend`
#- type: file
# target: /examples/entities.yaml

# Local example template
#- type: file
# target: /examples/template/template.yaml
# rules:
# - allow: [Template]

# Local example organizational data
#- type: file
# target: /examples/org.yaml
# rules:
# - allow: [User, Group]
```


## Removing

To delete the chart:
```bash
helm uninstall pipelines --namespace assemble-pipelines
helm uninstall assemble-dev --namespace assemble
```

To delete when not using helm
```
helm template pipelines --set ignoreHelmHooks=true . | oc delete -f-
oc delete csv openshift-pipelines-operator-rh.v1.8.0 -n openshift-operators
helm template assemble-dev | oc delete -f-
```

6 changes: 3 additions & 3 deletions charts/assemble-backstage/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ Check for existing secret
{{- if .Values.postgres.database_password }}
databasePassword: {{ .Values.postgres.database_password | quote }}
{{- else -}}
{{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.postgres.name -}}
{{- $secret := lookup "v1" "Secret" .Release.Namespace (include "assemble-backstage.fullname" . ) -}}
{{- if $secret -}}
{{/*
Reusing existing secret data
databasePassword: {{ $secret.data.databasePassword | quote }}
databasePassword: {{ $secret.data.databasePassword | quote }}
*/}}
databasePassword: {{ $secret.data.databasePassword | b64dec | quote }}
{{- else -}}
{{/*
Generate new data
*/}}
databasePassword: {{ randAlphaNum 20 | quote }}
databasePassword: "{{ randAlphaNum 20 }}"
{{- end -}}
{{- end -}}
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ stringData:
database:
client: pg
connection:
host: "{{ .Values.postgres.name }}"
host: {{ include "assemble-backstage.fullname" . }}-postgres.{{ .Release.Namespace }}.svc
port: "{{ .Values.postgres.port }}"
user: "{{ .Values.postgres.database_user }}"
#password: "{{ .Values.postgres.database_password }}"
Expand Down
2 changes: 1 addition & 1 deletion charts/assemble-backstage/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
- name: POSTGRES_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ .Values.postgres.name }}"
name: {{ include "assemble-backstage.fullname" . }}-postgresql
key: databasePassword
ports:
- name: http
Expand Down
25 changes: 25 additions & 0 deletions charts/assemble-backstage/templates/postgres-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if not .Values.postgres.external }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "assemble-backstage.fullname" . }}-postgresql-config
labels:
{{- include "assemble-backstage.labels" . | nindent 4 }}
data:
postgresql.conf: |
# LOGGING
log_min_error_statement = fatal
# CONNECTION
listen_addresses = '*'
# MODULES
shared_preload_libraries = 'decoderbufs'
# REPLICATION
wal_level = logical # minimal, archive, hot_standby, or logical (change requires restart)
max_wal_senders = 1 # max number of walsender processes (change requires restart)
#wal_keep_segments = 4 # in logfile segments, 16MB each; 0 disables
#wal_sender_timeout = 60s # in milliseconds; 0 disables
max_replication_slots = 1 # max number of replication slots (change requires restart)
{{ end }}
55 changes: 0 additions & 55 deletions charts/assemble-backstage/templates/postgres-deploy.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions charts/assemble-backstage/templates/postgres-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.postgres.name }}-storage-claim
name: {{ include "assemble-backstage.fullname" . }}-postgres
labels:
paas.redhat.com/appcode: ""
paas.redhat.com/appcode: "ASBL-001"
annotations:
kubernetes.io/reclaimPolicy: Delete
spec:
Expand Down
4 changes: 2 additions & 2 deletions charts/assemble-backstage/templates/postgres-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ metadata:
template.openshift.io/expose-database_name: '{.data[''databaseName'']}'
template.openshift.io/expose-password: '{.data[''databasePassword'']}'
template.openshift.io/expose-username: '{.data[''databaseUser'']}'
name: "{{ .Values.postgres.name }}"
name: "{{ include "assemble-backstage.fullname" . }}-postgresql"
stringData:
databaseName: "{{ .Values.postgres.name }}"
databaseName: "postgres"
databaseUser: "{{ .Values.postgres.database_user }}"
{{- ( include "gen.postgres-password" . ) | indent 2 -}}
{{- end }}
52 changes: 52 additions & 0 deletions charts/assemble-backstage/templates/postgres-ss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- if not .Values.postgres.external }}
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: {{ include "assemble-backstage.fullname" . }}-postgresql
labels:
{{- include "assemble-backstage.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: postgresql
app.kubernetes.io/instance: backstage
app.kubernetes.io/name: {{ include "assemble-backstage.fullname" . }}-postgresql
template:
metadata:
name: {{ include "assemble-backstage.fullname" . }}-postgresql
creationTimestamp: null
labels:
app.kubernetes.io/component: postgresql
app.kubernetes.io/instance: backstage
app.kubernetes.io/name: {{ include "assemble-backstage.fullname" . }}-postgresql
spec:
containers:
- name: postgresql
env:
- name: POSTGRESQL_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ include "assemble-backstage.fullname" . }}-postgresql"
key: databasePassword
ports:
- name: tcp-postgresql
containerPort: 5432
protocol: TCP
volumeMounts:
{{- if .Values.postgres.persistent }}
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgresdb
{{- end }}
terminationMessagePolicy: File
image: "{{ .Values.postgres.image }}"
serviceAccount: {{ include "assemble-backstage.serviceAccountName" . }}
{{- if .Values.postgres.persistent }}
volumes:
- name: postgresdb
persistentVolumeClaim:
claimName: {{ include "assemble-backstage.fullname" . }}-postgresql
{{- end }}
serviceName: {{ include "assemble-backstage.fullname" . }}-postgresql
{{- end }}
11 changes: 6 additions & 5 deletions charts/assemble-backstage/templates/postgres-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
apiVersion: v1
kind: Service
metadata:
name: "{{ .Values.postgres.name }}"
name: {{ include "assemble-backstage.fullname" . }}-postgres
labels:
app.kubernetes.io/name: {{ .Values.postgres.name }}
app.kubernetes.io/name: {{ include "assemble-backstage.fullname" . }}-postgres
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
type: ClusterIP
clusterIP: None
ports:
- port: {{ .Values.postgres.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ .Values.postgres.name }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: postgresql
app.kubernetes.io/instance: backstage
app.kubernetes.io/name: {{ include "assemble-backstage.fullname" . }}-postgresql
{{- end }}
Loading

0 comments on commit 23bf9c4

Please sign in to comment.