nodejs-postgresql-persistent.json 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. {
  2. "kind": "Template",
  3. "apiVersion": "template.openshift.io/v1",
  4. "metadata": {
  5. "name": "nodejs-postgresql-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "Node.js + PostgreSQL",
  8. "description": "An example Node.js application with a PostgreSQL database. For more information about using this template, including OpenShift considerations, see https://github.com/nodeshift-starters/nodejs-rest-http-crud/blob/master/README.md.",
  9. "tags": "quickstart,nodejs",
  10. "iconClass": "icon-nodejs",
  11. "openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration, application deployment configuration, and database deployment configuration.",
  12. "openshift.io/provider-display-name": "Red Hat, Inc.",
  13. "openshift.io/documentation-url": "https://github.com/sclorg/nodejs-ex",
  14. "openshift.io/support-url": "https://access.redhat.com",
  15. "template.openshift.io/bindable": "false"
  16. }
  17. },
  18. "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/nodeshift-starters/nodejs-rest-http-crud/blob/master/README.md.",
  19. "labels": {
  20. "template": "nodejs-postgresql-persistent",
  21. "app": "nodejs-postgresql-persistent"
  22. },
  23. "objects": [
  24. {
  25. "kind": "Secret",
  26. "apiVersion": "v1",
  27. "metadata": {
  28. "name": "${NAME}"
  29. },
  30. "stringData": {
  31. "database-user": "${DATABASE_USER}",
  32. "database-password": "${DATABASE_PASSWORD}",
  33. "database-admin-password" : "${DATABASE_ADMIN_PASSWORD}"
  34. }
  35. },
  36. {
  37. "kind": "Service",
  38. "apiVersion": "v1",
  39. "metadata": {
  40. "name": "${NAME}",
  41. "annotations": {
  42. "description": "Exposes and load balances the application pods",
  43. "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]"
  44. }
  45. },
  46. "spec": {
  47. "ports": [
  48. {
  49. "name": "web",
  50. "port": 8080,
  51. "targetPort": 8080
  52. }
  53. ],
  54. "selector": {
  55. "name": "${NAME}"
  56. }
  57. }
  58. },
  59. {
  60. "kind": "Route",
  61. "apiVersion": "route.openshift.io/v1",
  62. "metadata": {
  63. "name": "${NAME}",
  64. "annotations": {
  65. "template.openshift.io/expose-uri": "http://{.spec.host}{.spec.path}"
  66. }
  67. },
  68. "spec": {
  69. "host": "${APPLICATION_DOMAIN}",
  70. "to": {
  71. "kind": "Service",
  72. "name": "${NAME}"
  73. }
  74. }
  75. },
  76. {
  77. "kind": "ImageStream",
  78. "apiVersion": "image.openshift.io/v1",
  79. "metadata": {
  80. "name": "${NAME}",
  81. "annotations": {
  82. "description": "Keeps track of changes in the application image"
  83. }
  84. }
  85. },
  86. {
  87. "kind": "BuildConfig",
  88. "apiVersion": "build.openshift.io/v1",
  89. "metadata": {
  90. "name": "${NAME}",
  91. "annotations": {
  92. "description": "Defines how to build the application",
  93. "template.alpha.openshift.io/wait-for-ready": "true"
  94. }
  95. },
  96. "spec": {
  97. "source": {
  98. "type": "Git",
  99. "git": {
  100. "uri": "${SOURCE_REPOSITORY_URL}",
  101. "ref": "${SOURCE_REPOSITORY_REF}"
  102. },
  103. "contextDir": "${CONTEXT_DIR}"
  104. },
  105. "strategy": {
  106. "type": "Source",
  107. "sourceStrategy": {
  108. "from": {
  109. "kind": "ImageStreamTag",
  110. "namespace": "${NAMESPACE}",
  111. "name": "nodejs:${NODEJS_VERSION}"
  112. },
  113. "env": [
  114. {
  115. "name": "NPM_MIRROR",
  116. "value": "${NPM_MIRROR}"
  117. }
  118. ]
  119. }
  120. },
  121. "output": {
  122. "to": {
  123. "kind": "ImageStreamTag",
  124. "name": "${NAME}:latest"
  125. }
  126. },
  127. "triggers": [
  128. {
  129. "type": "ImageChange"
  130. },
  131. {
  132. "type": "ConfigChange"
  133. },
  134. {
  135. "type": "GitHub",
  136. "github": {
  137. "secret": "${GITHUB_WEBHOOK_SECRET}"
  138. }
  139. },
  140. {
  141. "type": "Generic",
  142. "generic": {
  143. "secret": "${GENERIC_WEBHOOK_SECRET}"
  144. }
  145. }
  146. ],
  147. "postCommit": {}
  148. }
  149. },
  150. {
  151. "kind": "Deployment",
  152. "apiVersion": "apps/v1",
  153. "metadata": {
  154. "name": "${NAME}",
  155. "labels": {
  156. "app.openshift.io/runtime": "nodejs"
  157. },
  158. "annotations": {
  159. "description": "Defines how to deploy the application server",
  160. "template.alpha.openshift.io/wait-for-ready": "true",
  161. "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${NAME}:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
  162. }
  163. },
  164. "spec": {
  165. "strategy": {
  166. "type": "Recreate"
  167. },
  168. "replicas": 1,
  169. "selector": {
  170. "matchLabels": {
  171. "name": "${NAME}"
  172. }
  173. },
  174. "template": {
  175. "metadata": {
  176. "name": "${NAME}",
  177. "labels": {
  178. "name": "${NAME}",
  179. "app.openshift.io/runtime": "nodejs"
  180. }
  181. },
  182. "spec": {
  183. "containers": [
  184. {
  185. "name": "${NAME}",
  186. "image": " ",
  187. "ports": [
  188. {
  189. "containerPort": 8080
  190. }
  191. ],
  192. "env": [
  193. {
  194. "name": "DATABASE_SERVICE_NAME",
  195. "value": "${DATABASE_SERVICE_NAME}"
  196. },
  197. {
  198. "name": "POSTGRESQL_USER",
  199. "valueFrom": {
  200. "secretKeyRef" : {
  201. "name" : "${NAME}",
  202. "key" : "database-user"
  203. }
  204. }
  205. },
  206. {
  207. "name": "POSTGRESQL_PASSWORD",
  208. "valueFrom": {
  209. "secretKeyRef" : {
  210. "name" : "${NAME}",
  211. "key" : "database-password"
  212. }
  213. }
  214. },
  215. {
  216. "name": "POSTGRESQL_DATABASE",
  217. "value": "${DATABASE_NAME}"
  218. },
  219. {
  220. "name": "POSTGRESQL_ADMIN_PASSWORD",
  221. "valueFrom": {
  222. "secretKeyRef" : {
  223. "name" : "${NAME}",
  224. "key" : "database-admin-password"
  225. }
  226. }
  227. }
  228. ],
  229. "readinessProbe": {
  230. "timeoutSeconds": 3,
  231. "initialDelaySeconds": 3,
  232. "httpGet": {
  233. "path": "/",
  234. "port": 8080
  235. }
  236. },
  237. "livenessProbe": {
  238. "timeoutSeconds": 3,
  239. "initialDelaySeconds": 30,
  240. "httpGet": {
  241. "path": "/",
  242. "port": 8080
  243. }
  244. },
  245. "resources": {
  246. "limits": {
  247. "memory": "${MEMORY_LIMIT}"
  248. }
  249. }
  250. }
  251. ]
  252. }
  253. }
  254. }
  255. },
  256. {
  257. "kind": "PersistentVolumeClaim",
  258. "apiVersion": "v1",
  259. "metadata": {
  260. "name": "${DATABASE_SERVICE_NAME}"
  261. },
  262. "spec": {
  263. "accessModes": [
  264. "ReadWriteOnce"
  265. ],
  266. "resources": {
  267. "requests": {
  268. "storage": "${VOLUME_CAPACITY}"
  269. }
  270. }
  271. }
  272. },
  273. {
  274. "kind": "Service",
  275. "apiVersion": "v1",
  276. "metadata": {
  277. "name": "${DATABASE_SERVICE_NAME}",
  278. "annotations": {
  279. "description": "Exposes the database server"
  280. }
  281. },
  282. "spec": {
  283. "ports": [
  284. {
  285. "name": "postgresql",
  286. "port": 5432,
  287. "targetPort": 5432
  288. }
  289. ],
  290. "selector": {
  291. "name": "${DATABASE_SERVICE_NAME}"
  292. }
  293. }
  294. },
  295. {
  296. "kind": "Deployment",
  297. "apiVersion": "apps/v1",
  298. "metadata": {
  299. "name": "${DATABASE_SERVICE_NAME}",
  300. "annotations": {
  301. "description": "Defines how to deploy the database",
  302. "template.alpha.openshift.io/wait-for-ready": "true",
  303. "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"postgresql:${POSTGRESQL_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
  304. }
  305. },
  306. "spec": {
  307. "strategy": {
  308. "type": "Recreate"
  309. },
  310. "replicas": 1,
  311. "selector": {
  312. "matchLabels": {
  313. "name": "${DATABASE_SERVICE_NAME}"
  314. }
  315. },
  316. "template": {
  317. "metadata": {
  318. "name": "${DATABASE_SERVICE_NAME}",
  319. "labels": {
  320. "name": "${DATABASE_SERVICE_NAME}"
  321. }
  322. },
  323. "spec": {
  324. "containers": [
  325. {
  326. "name": "postgresql",
  327. "image": " ",
  328. "ports": [
  329. {
  330. "containerPort": 5432
  331. }
  332. ],
  333. "env": [
  334. {
  335. "name": "POSTGRESQL_USER",
  336. "valueFrom": {
  337. "secretKeyRef" : {
  338. "name" : "${NAME}",
  339. "key" : "database-user"
  340. }
  341. }
  342. },
  343. {
  344. "name": "POSTGRESQL_PASSWORD",
  345. "valueFrom": {
  346. "secretKeyRef" : {
  347. "name" : "${NAME}",
  348. "key" : "database-password"
  349. }
  350. }
  351. },
  352. {
  353. "name": "POSTGRESQL_DATABASE",
  354. "value": "${DATABASE_NAME}"
  355. },
  356. {
  357. "name": "POSTGRESQL_ADMIN_PASSWORD",
  358. "valueFrom": {
  359. "secretKeyRef" : {
  360. "name" : "${NAME}",
  361. "key" : "database-admin-password"
  362. }
  363. }
  364. }
  365. ],
  366. "livenessProbe": {
  367. "timeoutSeconds": 1,
  368. "initialDelaySeconds": 30,
  369. "tcpSocket": {
  370. "port": 5432
  371. }
  372. },
  373. "resources": {
  374. "limits": {
  375. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  376. }
  377. },
  378. "volumeMounts": [
  379. {
  380. "name": "${DATABASE_SERVICE_NAME}-data",
  381. "mountPath": "/var/lib/pgsql/data"
  382. }
  383. ]
  384. }
  385. ],
  386. "volumes": [
  387. {
  388. "name": "${DATABASE_SERVICE_NAME}-data",
  389. "persistentVolumeClaim": {
  390. "claimName": "${DATABASE_SERVICE_NAME}"
  391. }
  392. }
  393. ]
  394. }
  395. }
  396. }
  397. }
  398. ],
  399. "parameters": [
  400. {
  401. "name": "NAME",
  402. "displayName": "Name",
  403. "description": "The name assigned to all of the frontend objects defined in this template.",
  404. "required": true,
  405. "value": "nodejs-postgresql-persistent"
  406. },
  407. {
  408. "name": "NAMESPACE",
  409. "displayName": "Namespace",
  410. "description": "The OpenShift Namespace where the ImageStream resides.",
  411. "required": true,
  412. "value": "openshift"
  413. },
  414. {
  415. "name": "NODEJS_VERSION",
  416. "displayName": "Version of NodeJS Image",
  417. "description": "Version of NodeJS image to be used (18-ubi9, 20-ubi9, 22-ubi9, or latest).",
  418. "value": "22-ubi9",
  419. "required": true
  420. },
  421. {
  422. "name": "POSTGRESQL_VERSION",
  423. "displayName": "Version of PostgreSQL Image",
  424. "description": "Version of PostgreSQL image to be used (12-el8, or latest).",
  425. "value": "12-el8",
  426. "required": true
  427. },
  428. {
  429. "name": "MEMORY_LIMIT",
  430. "displayName": "Memory Limit",
  431. "description": "Maximum amount of memory the Node.js container can use.",
  432. "required": true,
  433. "value": "256Mi"
  434. },
  435. {
  436. "name": "MEMORY_POSTGRESQL_LIMIT",
  437. "displayName": "Memory Limit (PostgreSQL)",
  438. "description": "Maximum amount of memory the PostgreSQL container can use.",
  439. "required": true,
  440. "value": "256Mi"
  441. },
  442. {
  443. "name": "VOLUME_CAPACITY",
  444. "displayName": "Volume Capacity",
  445. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  446. "value": "1Gi",
  447. "required": true
  448. },
  449. {
  450. "name": "SOURCE_REPOSITORY_URL",
  451. "displayName": "Git Repository URL",
  452. "description": "The URL of the repository with your application source code.",
  453. "required": true,
  454. "value": "https://github.com/sclorg/nodejs-ex.git"
  455. },
  456. {
  457. "name": "SOURCE_REPOSITORY_REF",
  458. "displayName": "Git Reference",
  459. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  460. },
  461. {
  462. "name": "CONTEXT_DIR",
  463. "displayName": "Context Directory",
  464. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  465. },
  466. {
  467. "name": "APPLICATION_DOMAIN",
  468. "displayName": "Application Hostname",
  469. "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.",
  470. "value": ""
  471. },
  472. {
  473. "name": "GITHUB_WEBHOOK_SECRET",
  474. "displayName": "GitHub Webhook Secret",
  475. "description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
  476. "generate": "expression",
  477. "from": "[a-zA-Z0-9]{40}"
  478. },
  479. {
  480. "name": "GENERIC_WEBHOOK_SECRET",
  481. "displayName": "Generic Webhook Secret",
  482. "description": "A secret string used to configure the Generic webhook.",
  483. "generate": "expression",
  484. "from": "[a-zA-Z0-9]{40}"
  485. },
  486. {
  487. "name": "DATABASE_SERVICE_NAME",
  488. "displayName": "Database Service Name",
  489. "required": true,
  490. "value": "postgresql"
  491. },
  492. {
  493. "name": "DATABASE_USER",
  494. "displayName": "PostgreSQL Username",
  495. "description": "Username for PostgreSQL user that will be used for accessing the database.",
  496. "generate": "expression",
  497. "from": "user[A-Z0-9]{3}"
  498. },
  499. {
  500. "name": "DATABASE_PASSWORD",
  501. "displayName": "PostgreSQL Password",
  502. "description": "Password for the PostgreSQL user.",
  503. "generate": "expression",
  504. "from": "[a-zA-Z0-9]{16}"
  505. },
  506. {
  507. "name": "DATABASE_NAME",
  508. "displayName": "Database Name",
  509. "required": true,
  510. "value": "my_data"
  511. },
  512. {
  513. "name": "DATABASE_ADMIN_PASSWORD",
  514. "displayName": "Database Administrator Password",
  515. "description": "Password for the database admin user.",
  516. "generate": "expression",
  517. "from": "[a-zA-Z0-9]{16}"
  518. },
  519. {
  520. "name": "NPM_MIRROR",
  521. "displayName": "Custom NPM Mirror URL",
  522. "description": "The custom NPM mirror URL",
  523. "value": ""
  524. }
  525. ]
  526. }