Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cleanup, fix postgres connection #12

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
terminfinder-chart/Chart.lock
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ Complete Helm Chart repository for deploying the Terminfinder to any kubernetes

[SECURITY.md](./docs/SECURITY.md)

## Components
It's recommended to use a dedicated PostgreSQL instance for production usage.

* Frontend: `registry.opencode.de/ig-bvc/demo-apps/terminfinder-sh/terminfinder-sh-frontend:v2.2.0`
* Backend: `registry.opencode.de/ig-bvc/demo-apps/terminfinder-sh/terminfinder-sh-backend:V1.0.9`
* Postgres (part of Backend):
Using [this public Helm chart](https://github.com/bitnami/charts/tree/main/bitnami/postgresql/) as fundament, but can
be disabled through `values.yaml` of the backend file.
## Local development

Please modify the `values.yaml` files or use the CLI method for deployment and configuration. It's recommended to use a
dedicated PostgreSQL instance for production usage.
1. install and run minikube or other local K8s services https://kubernetes.io/docs/tasks/tools/
2. use scripts in installation below

## Installation

Expand All @@ -38,31 +34,48 @@ dedicated PostgreSQL instance for production usage.

### Installation steps

1. Prepare the value files for the backend and frontend each.
2. Install the helm charts with `helm install ...` CLI Command
1. Prepare the value files.
2. Install the helm charts with `helm install ...` CLI Command:

```bash
# Create a namespace (or use default), where to work in:
$ kubectl create ns terminfinder-demo
$ kubectl create namespace terminfinder-demo

# First installing the helm chart, to the name
$ helm install terminfinder-backend ./charts/terminfinder-backend -n terminfinder-demo -f demo-backend.values.yaml

# Second installing the helm chart of the frontend
$ helm install terminfinder-frontend ./charts/terminfinder-frontend -n terminfinder-demo -f demo-frontend.values.yaml
$ helm install terminfinder-demo terminfinder-chart -n terminfinder-demo

# Verify installation of helm charts:
$ helm list -n terminfinder-demo
$ kubectl get deploy -n terminfinder-demo
```

### Upgrade release

To upgrade the helm chart, use the `helm upgrade ...` command:

# Go to your configured ingress host domain (e.g. terminfinder.open-code.local) and test it out!
# The URL of the ingresses you can get here:
$ kubectl get ingress -n terminfinder-demo
```bash
# Upgrade HelmChart
$ helm upgrade terminfinder-demo terminfinder-chart -n terminfinder-demo
```

Your can upgrade the helm chart as usually with `helm upgrade ...` command.
### Delete Release

To delete the helm chart (release), use the `helm uninstall...` command.

Note that the persistent volume may be available even if the helm release is uninstalled.

```bash
# Delete release
$ helm uninstall terminfinder-demo -n terminfinder-demo
```

```bash
# Delete PVCs and namespace
$ kubectl delete pvc --all -n terminfinder-demo
$ kubectl delete namespace terminfinder-demo
```

### Using an own PostgreSQL DB instance
## Using an own PostgreSQL DB instance

The helm chart deployment of the `terminfinder-frontend` will be kept untouched.

Expand Down
58 changes: 0 additions & 58 deletions demo-backend.values.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions demo-frontend.values.yaml

This file was deleted.

Binary file not shown.
9 changes: 0 additions & 9 deletions terminfinder-chart/charts/frontend/templates/configMap.yml

This file was deleted.

11 changes: 0 additions & 11 deletions terminfinder-chart/charts/resources/templates/postgresql.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions terminfinder-chart/charts/resources/values.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dependencies:
version: 12.1.2
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.2.4
digest: sha256:55f16e9b5bade9e719e7e6673b24d182e9316e8669820cdc68b4c37f518c3e5b
generated: "2023-03-23T11:14:06.498295+01:00"
version: 2.20.3
digest: sha256:8fccf7c770b0e1a7a1f64fcd77a3afede13a967fe7c182ebbfe2d21f9cfed0b7
generated: "2024-07-01T16:33:04.750757+02:00"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $svc := .Values.global.postgresql.service.name | default (printf "%s-postgresql-hl" (include "terminfinder-backend.fullname" .)) }}
{{- $svc := .Values.global.postgresql.service.name | default (printf "%s-postgresql" (include "common.names.namespace" .)) }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -41,7 +41,7 @@ spec:
- name: DB_PORT
value: {{ .Values.global.postgresql.service.ports.postgresql | quote }}
- name: DB_ADDRESS
value: {{ printf "%s.%s.svc" $svc .Release.Namespace }}
value: {{ printf "%s" $svc }}
- name: DB_USERNAME
value: {{ .Values.global.postgresql.auth.username }}
- name: ASPNETCORE_URLS
Expand All @@ -50,7 +50,7 @@ spec:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.global.postgresql.auth.existingSecret | default (printf "%s-postgresql" (include "common.names.fullname" .)) }}
name: {{ .Values.global.postgresql.auth.existingSecret | default (printf "%s-postgresql" (include "common.names.namespace" .)) }}
key: {{ .Values.global.postgresql.auth.secretKeys.userPasswordKey | default "password" }}
# Patches
- name: Terminfinder__UseHttps
Expand All @@ -60,12 +60,19 @@ spec:
- name: Terminfinder__Log4NetConfigFilename
value: log4net.Console.debug.config
- name: ConnectionStrings__TerminfinderConnection
value: "Server=$(DB_ADDRESS);Port=$(DB_PORT);Database=$(DB_DATABASE);User ID=$(DB_USERNAME);password=$(DB_PASSWORD);"
value: "Server=$(DB_ADDRESS),$(DB_PORT);Database=$(DB_DATABASE);User ID=$(DB_USERNAME);password=$(DB_PASSWORD);"
ports:
- name: http
containerPort: 8080
protocol: TCP
startupProbe:
failureThreshold: 3
periodSeconds: 10
httpGet:
path: /app
port: http
livenessProbe:
initialDelaySeconds: 10
httpGet:
path: /app
port: http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ global:
database: terminfinder
existingSecret: "" # if not set, default: "{{ Release.Name }}-postgres"
secretKeys:
userPasswordKey: "terminfinder"

userPasswordKey: "password"
service:
name: "" # if not set, default: "{{ Release.Name }}-postgres"
ports:
Expand Down Expand Up @@ -100,22 +99,13 @@ affinity: { }
postgresql:
enabled: true

#architecture: standalone

serviceAccount:
create: true

image:
registry: docker.io # Notice, may this is not allowed
repository: mxzinke/postgresql-rootless # This is an special image, which is based on bitnami/postgresql
tag: 15
pullPolicy: IfNotPresent
pullSecrets: [ ]

## Set permissions for the data volume
## Only needed when volume has not correct permissions
volumePermissions:
enabled: false
enabled: true

image:
registry: docker.io # Notice, may this is not allowed
Expand All @@ -124,58 +114,6 @@ postgresql:
# pullPolicy: Always
# pullSecrets: []

resources:
requests:
memory: 64Mi
cpu: 250m
limits:
memory: 64Mi
cpu: 250m

containerSecurityContext:
enabled: true
runAsUser: 1001
runAsGroup: 1001
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities:
drop:
- ALL

primary:
## Enable security context with non-root user
podSecurityContext:
enabled: true
runAsUser: 1001
runAsGroup: 1001
fsGroup: 1001
containerSecurityContext:
enabled: true
runAsUser: 1001
runAsGroup: 1001
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities:
drop:
- ALL

## Enable persistence using Persistent Volume Claims
## For BSI compliance, we need to use non-root user
persistence:
enabled: true
accessModes:
- ReadWriteOnce
size: 8Gi

# Resources (minimal)
resources:
requests:
memory: 256Mi
cpu: 250m
limits:
memory: 256Mi
cpu: 250m

initdb:
# Enabling the UUID-OSSP
scripts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,13 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: ADDRESSING
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}-customer-config
key: Anrede
value: {{ .Values.customerConfig.ADDRESSING }}
- name: LOCALE
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}-customer-config
key: Sprache
value: {{ .Values.customerConfig.LOCALE }}
- name: TITLE
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}-customer-config
key: Titel
value: {{ .Values.customerConfig.TITLE }}
- name: EMAIL
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}-customer-config
key: email
value: {{ .Values.customerConfig.EMAIL }}
- name: API_URL
value: {{ .Values.app.backend_url }}
ports:
Expand Down
Loading
Loading