nodejs-postgresql.json 16 KB

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