Skip to content

Commit e30e6ca

Browse files
authored
Update db template to use deployments (#56)
1 parent 5c9155e commit e30e6ca

File tree

3 files changed

+37
-51
lines changed

3 files changed

+37
-51
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ container_tool ?= podman
2929
# when it is accessed from outside the cluster and when it is accessed from
3030
# inside the cluster. We need the external name to push the image, and the
3131
# internal name to pull it.
32-
external_image_registry:=default-route-openshift-image-registry.apps-crc.testing
33-
internal_image_registry:=image-registry.openshift-image-registry.svc:5000
32+
external_apps_domain?=apps-crc.testing
33+
external_image_registry?=default-route-openshift-image-registry.$(external_apps_domain)
34+
internal_image_registry?=image-registry.openshift-image-registry.svc:5000
3435

3536
# The name of the image repository needs to start with the name of an existing
3637
# namespace because when the image is pushed to the internal registry of a

templates/db-template.yml

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,19 @@
22
apiVersion: v1
33
kind: Template
44
metadata:
5+
name: trex-db
56
annotations:
6-
description: PostgreSQL database service for use with the rh-trex
7+
description: PostgreSQL database service for use with the RH Trex service
78
iconClass: icon-postgresql
8-
openshift.io/display-name: Example Service PostgreSQL Database
9+
openshift.io/display-name: RH Trex PostgreSQL Database
910
tags: database,postgresql
10-
name: trex-db
1111
parameters:
1212

13-
- name: POSTGRESQL_IMAGESTREAM_NAMESPACE
14-
description: The OpenShift Namespace where the ImageStream resides.
15-
displayName: Namespace
16-
value: openshift
17-
1813
- name: DATABASE_SERVICE_NAME
1914
description: The name of the OpenShift Service exposed for the database.
2015
displayName: Database Service Name
2116
required: true
22-
value: trex-db
17+
value: trex-db
2318

2419
- name: DATABASE_USER
2520
description: Username for PostgreSQL user that will be used for accessing the database.
@@ -49,7 +44,7 @@ parameters:
4944
description: Version of PostgreSQL image to be used (10 or latest).
5045
displayName: Version of PostgreSQL Image
5146
required: true
52-
value: "10"
47+
value: "16.2"
5348

5449
objects:
5550

@@ -72,6 +67,7 @@ objects:
7267
type: ClusterIP
7368
status:
7469
loadBalancer: {}
70+
7571
- apiVersion: v1
7672
kind: PersistentVolumeClaim
7773
metadata:
@@ -82,16 +78,18 @@ objects:
8278
resources:
8379
requests:
8480
storage: ${DATABASE_VOLUME_CAPACITY}
85-
- apiVersion: v1
86-
kind: DeploymentConfig
81+
82+
- apiVersion: apps/v1
83+
kind: Deployment
8784
metadata:
8885
annotations:
8986
template.alpha.openshift.io/wait-for-ready: true
9087
name: ${DATABASE_SERVICE_NAME}
9188
spec:
9289
replicas: 1
9390
selector:
94-
name: ${DATABASE_SERVICE_NAME}
91+
matchLabels:
92+
name: ${DATABASE_SERVICE_NAME}
9593
strategy:
9694
type: Recreate
9795
template:
@@ -102,28 +100,28 @@ objects:
102100
containers:
103101
- capabilities: {}
104102
env:
105-
- name: POSTGRESQL_USER
103+
- name: POSTGRES_USER
106104
valueFrom:
107105
secretKeyRef:
108-
key: database-user
106+
key: db.user
109107
name: ${DATABASE_SERVICE_NAME}
110-
- name: POSTGRESQL_PASSWORD
108+
- name: POSTGRES_PASSWORD
111109
valueFrom:
112110
secretKeyRef:
113-
key: database-password
111+
key: db.password
114112
name: ${DATABASE_SERVICE_NAME}
115-
- name: POSTGRESQL_DATABASE
113+
- name: POSTGRES_DB
116114
valueFrom:
117115
secretKeyRef:
118-
key: database-name
116+
key: db.name
119117
name: ${DATABASE_SERVICE_NAME}
120-
image: ""
118+
- name: PGDATA
119+
value: /var/lib/pgsql/data/pgdata
120+
image: docker.io/library/postgres:${POSTGRESQL_VERSION}
121121
imagePullPolicy: IfNotPresent
122122
livenessProbe:
123-
exec:
124-
command:
125-
- /usr/libexec/check-container
126-
- --live
123+
tcpSocket:
124+
port: 5432
127125
initialDelaySeconds: 120
128126
timeoutSeconds: 10
129127
name: postgresql
@@ -133,12 +131,11 @@ objects:
133131
readinessProbe:
134132
exec:
135133
command:
136-
- /usr/libexec/check-container
134+
- /bin/sh
135+
- -c
136+
- exec /usr/bin/pg_isready -U $POSTGRES_USER -d $POSTGRES_DB -h localhost -p 5432
137137
initialDelaySeconds: 5
138138
timeoutSeconds: 1
139-
securityContext:
140-
capabilities: {}
141-
privileged: false
142139
terminationMessagePath: /dev/termination-log
143140
volumeMounts:
144141
- mountPath: /var/lib/pgsql/data
@@ -147,31 +144,18 @@ objects:
147144
restartPolicy: Always
148145
volumes:
149146
- name: ${DATABASE_SERVICE_NAME}-data
147+
#emptyDir: {}
150148
persistentVolumeClaim:
151149
claimName: ${DATABASE_SERVICE_NAME}
152-
triggers:
153-
- type: ImageChange
154-
imageChangeParams:
155-
automatic: true
156-
containerNames:
157-
- postgresql
158-
from:
159-
kind: ImageStreamTag
160-
name: postgresql:${POSTGRESQL_VERSION}
161-
namespace: ${POSTGRESQL_IMAGESTREAM_NAMESPACE}
162-
- type: ConfigChange
163150
status: {}
164151

165152
- apiVersion: v1
166153
kind: Secret
167154
metadata:
168-
annotations:
169-
template.openshift.io/expose-database_name: "{.data['database-name']}"
170-
template.openshift.io/expose-password: "{.data['database-password']}"
171-
template.openshift.io/expose-username: "{.data['database-user']}"
172155
name: ${DATABASE_SERVICE_NAME}
173156
stringData:
174-
database-name: ${DATABASE_NAME}
175-
database-password: ${DATABASE_PASSWORD}
176-
database-user: ${DATABASE_USER}
177-
157+
db.host: ${DATABASE_SERVICE_NAME}
158+
db.name: ${DATABASE_NAME}
159+
db.password: ${DATABASE_PASSWORD}
160+
db.user: ${DATABASE_USER}
161+
db.port: "5432"

templates/route-template.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: v1
33
kind: Template
4-
name: uhc-acct-mangr-routes
4+
name: trex-routes
55
metadata:
66
name: route
77

@@ -14,7 +14,8 @@ objects:
1414
labels:
1515
app: trex
1616
spec:
17-
host: trex.apps-crc.testing
17+
# The cluster should assign a suitable host. If using CRC, it may be necessary to define one manually:
18+
# host: trex.apps-crc.testing
1819
to:
1920
kind: Service
2021
name: trex

0 commit comments

Comments
 (0)