2
2
apiVersion : v1
3
3
kind : Template
4
4
metadata :
5
+ name : trex-db
5
6
annotations :
6
- description : PostgreSQL database service for use with the rh-trex
7
+ description : PostgreSQL database service for use with the RH Trex service
7
8
iconClass : icon-postgresql
8
- openshift.io/display-name : Example Service PostgreSQL Database
9
+ openshift.io/display-name : RH Trex PostgreSQL Database
9
10
tags : database,postgresql
10
- name : trex-db
11
11
parameters :
12
12
13
- - name : POSTGRESQL_IMAGESTREAM_NAMESPACE
14
- description : The OpenShift Namespace where the ImageStream resides.
15
- displayName : Namespace
16
- value : openshift
17
-
18
13
- name : DATABASE_SERVICE_NAME
19
14
description : The name of the OpenShift Service exposed for the database.
20
15
displayName : Database Service Name
21
16
required : true
22
- value : trex-db
17
+ value : trex-db
23
18
24
19
- name : DATABASE_USER
25
20
description : Username for PostgreSQL user that will be used for accessing the database.
@@ -49,7 +44,7 @@ parameters:
49
44
description : Version of PostgreSQL image to be used (10 or latest).
50
45
displayName : Version of PostgreSQL Image
51
46
required : true
52
- value : " 10 "
47
+ value : " 16.2 "
53
48
54
49
objects :
55
50
@@ -72,6 +67,7 @@ objects:
72
67
type : ClusterIP
73
68
status :
74
69
loadBalancer : {}
70
+
75
71
- apiVersion : v1
76
72
kind : PersistentVolumeClaim
77
73
metadata :
@@ -82,16 +78,18 @@ objects:
82
78
resources :
83
79
requests :
84
80
storage : ${DATABASE_VOLUME_CAPACITY}
85
- - apiVersion : v1
86
- kind : DeploymentConfig
81
+
82
+ - apiVersion : apps/v1
83
+ kind : Deployment
87
84
metadata :
88
85
annotations :
89
86
template.alpha.openshift.io/wait-for-ready : true
90
87
name : ${DATABASE_SERVICE_NAME}
91
88
spec :
92
89
replicas : 1
93
90
selector :
94
- name : ${DATABASE_SERVICE_NAME}
91
+ matchLabels :
92
+ name : ${DATABASE_SERVICE_NAME}
95
93
strategy :
96
94
type : Recreate
97
95
template :
@@ -102,28 +100,28 @@ objects:
102
100
containers :
103
101
- capabilities : {}
104
102
env :
105
- - name : POSTGRESQL_USER
103
+ - name : POSTGRES_USER
106
104
valueFrom :
107
105
secretKeyRef :
108
- key : database- user
106
+ key : db. user
109
107
name : ${DATABASE_SERVICE_NAME}
110
- - name : POSTGRESQL_PASSWORD
108
+ - name : POSTGRES_PASSWORD
111
109
valueFrom :
112
110
secretKeyRef :
113
- key : database- password
111
+ key : db. password
114
112
name : ${DATABASE_SERVICE_NAME}
115
- - name : POSTGRESQL_DATABASE
113
+ - name : POSTGRES_DB
116
114
valueFrom :
117
115
secretKeyRef :
118
- key : database- name
116
+ key : db. name
119
117
name : ${DATABASE_SERVICE_NAME}
120
- image : " "
118
+ - name : PGDATA
119
+ value : /var/lib/pgsql/data/pgdata
120
+ image : docker.io/library/postgres:${POSTGRESQL_VERSION}
121
121
imagePullPolicy : IfNotPresent
122
122
livenessProbe :
123
- exec :
124
- command :
125
- - /usr/libexec/check-container
126
- - --live
123
+ tcpSocket :
124
+ port : 5432
127
125
initialDelaySeconds : 120
128
126
timeoutSeconds : 10
129
127
name : postgresql
@@ -133,12 +131,11 @@ objects:
133
131
readinessProbe :
134
132
exec :
135
133
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
137
137
initialDelaySeconds : 5
138
138
timeoutSeconds : 1
139
- securityContext :
140
- capabilities : {}
141
- privileged : false
142
139
terminationMessagePath : /dev/termination-log
143
140
volumeMounts :
144
141
- mountPath : /var/lib/pgsql/data
@@ -147,31 +144,18 @@ objects:
147
144
restartPolicy : Always
148
145
volumes :
149
146
- name : ${DATABASE_SERVICE_NAME}-data
147
+ # emptyDir: {}
150
148
persistentVolumeClaim :
151
149
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
163
150
status : {}
164
151
165
152
- apiVersion : v1
166
153
kind : Secret
167
154
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']}"
172
155
name : ${DATABASE_SERVICE_NAME}
173
156
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"
0 commit comments