rails-postgresql.json 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "rails-postgresql-example",
  6. "annotations": {
  7. "openshift.io/display-name": "Rails + PostgreSQL (Ephemeral)",
  8. "description": "An example Rails application with a PostgreSQL database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/rails-ex/blob/master/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.",
  9. "tags": "quickstart,ruby,rails",
  10. "iconClass": "icon-ruby"
  11. }
  12. },
  13. "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/openshift/rails-ex/blob/master/README.md.",
  14. "labels": {
  15. "template": "rails-postgresql-example"
  16. },
  17. "objects": [
  18. {
  19. "kind": "Secret",
  20. "apiVersion": "v1",
  21. "metadata": {
  22. "name": "${NAME}"
  23. },
  24. "stringData" : {
  25. "databaseUser" : "${DATABASE_USER}",
  26. "databasePassword" : "${DATABASE_PASSWORD}",
  27. "applicationUser" : "${APPLICATION_USER}",
  28. "applicationPassword" : "${APPLICATION_PASSWORD}",
  29. "keyBase" : "${SECRET_KEY_BASE}"
  30. }
  31. },
  32. {
  33. "kind": "Service",
  34. "apiVersion": "v1",
  35. "metadata": {
  36. "name": "${NAME}",
  37. "annotations": {
  38. "description": "Exposes and load balances the application pods",
  39. "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]"
  40. }
  41. },
  42. "spec": {
  43. "ports": [
  44. {
  45. "name": "web",
  46. "port": 8080,
  47. "targetPort": 8080
  48. }
  49. ],
  50. "selector": {
  51. "name": "${NAME}"
  52. }
  53. }
  54. },
  55. {
  56. "kind": "Route",
  57. "apiVersion": "v1",
  58. "metadata": {
  59. "name": "${NAME}"
  60. },
  61. "spec": {
  62. "host": "${APPLICATION_DOMAIN}",
  63. "to": {
  64. "kind": "Service",
  65. "name": "${NAME}"
  66. }
  67. }
  68. },
  69. {
  70. "kind": "ImageStream",
  71. "apiVersion": "v1",
  72. "metadata": {
  73. "name": "${NAME}",
  74. "annotations": {
  75. "description": "Keeps track of changes in the application image"
  76. }
  77. }
  78. },
  79. {
  80. "kind": "BuildConfig",
  81. "apiVersion": "v1",
  82. "metadata": {
  83. "name": "${NAME}",
  84. "annotations": {
  85. "description": "Defines how to build the application"
  86. }
  87. },
  88. "spec": {
  89. "source": {
  90. "type": "Git",
  91. "git": {
  92. "uri": "${SOURCE_REPOSITORY_URL}",
  93. "ref": "${SOURCE_REPOSITORY_REF}"
  94. },
  95. "contextDir": "${CONTEXT_DIR}"
  96. },
  97. "strategy": {
  98. "type": "Source",
  99. "sourceStrategy": {
  100. "from": {
  101. "kind": "ImageStreamTag",
  102. "namespace": "${NAMESPACE}",
  103. "name": "ruby:2.3"
  104. },
  105. "env": [
  106. {
  107. "name": "RUBYGEM_MIRROR",
  108. "value": "${RUBYGEM_MIRROR}"
  109. }
  110. ]
  111. }
  112. },
  113. "output": {
  114. "to": {
  115. "kind": "ImageStreamTag",
  116. "name": "${NAME}:latest"
  117. }
  118. },
  119. "triggers": [
  120. {
  121. "type": "ImageChange"
  122. },
  123. {
  124. "type": "ConfigChange"
  125. },
  126. {
  127. "type": "GitHub",
  128. "github": {
  129. "secret": "${GITHUB_WEBHOOK_SECRET}"
  130. }
  131. }
  132. ],
  133. "postCommit": {
  134. "script": "bundle exec rake test"
  135. }
  136. }
  137. },
  138. {
  139. "kind": "DeploymentConfig",
  140. "apiVersion": "v1",
  141. "metadata": {
  142. "name": "${NAME}",
  143. "annotations": {
  144. "description": "Defines how to deploy the application server"
  145. }
  146. },
  147. "spec": {
  148. "strategy": {
  149. "type": "Recreate",
  150. "recreateParams": {
  151. "pre": {
  152. "failurePolicy": "Abort",
  153. "execNewPod": {
  154. "command": [
  155. "./migrate-database.sh"
  156. ],
  157. "containerName": "${NAME}"
  158. }
  159. }
  160. }
  161. },
  162. "triggers": [
  163. {
  164. "type": "ImageChange",
  165. "imageChangeParams": {
  166. "automatic": true,
  167. "containerNames": [
  168. "rails-postgresql-example"
  169. ],
  170. "from": {
  171. "kind": "ImageStreamTag",
  172. "name": "${NAME}:latest"
  173. }
  174. }
  175. },
  176. {
  177. "type": "ConfigChange"
  178. }
  179. ],
  180. "replicas": 1,
  181. "selector": {
  182. "name": "${NAME}"
  183. },
  184. "template": {
  185. "metadata": {
  186. "name": "${NAME}",
  187. "labels": {
  188. "name": "${NAME}"
  189. }
  190. },
  191. "spec": {
  192. "containers": [
  193. {
  194. "name": "rails-postgresql-example",
  195. "image": " ",
  196. "ports": [
  197. {
  198. "containerPort": 8080
  199. }
  200. ],
  201. "readinessProbe": {
  202. "timeoutSeconds": 3,
  203. "initialDelaySeconds": 5,
  204. "httpGet": {
  205. "path": "/articles",
  206. "port": 8080
  207. }
  208. },
  209. "livenessProbe": {
  210. "timeoutSeconds": 3,
  211. "initialDelaySeconds": 10,
  212. "httpGet": {
  213. "path": "/articles",
  214. "port": 8080
  215. }
  216. },
  217. "env": [
  218. {
  219. "name": "DATABASE_SERVICE_NAME",
  220. "value": "${DATABASE_SERVICE_NAME}"
  221. },
  222. {
  223. "name": "POSTGRESQL_USER",
  224. "valueFrom": {
  225. "secretKeyRef" : {
  226. "name" : "${NAME}",
  227. "key" : "databaseUser"
  228. }
  229. }
  230. },
  231. {
  232. "name": "POSTGRESQL_PASSWORD",
  233. "valueFrom": {
  234. "secretKeyRef" : {
  235. "name" : "${NAME}",
  236. "key" : "databasePassword"
  237. }
  238. }
  239. },
  240. {
  241. "name": "POSTGRESQL_DATABASE",
  242. "value": "${DATABASE_NAME}"
  243. },
  244. {
  245. "name": "SECRET_KEY_BASE",
  246. "valueFrom": {
  247. "secretKeyRef" : {
  248. "name" : "${NAME}",
  249. "key" : "keyBase"
  250. }
  251. }
  252. },
  253. {
  254. "name": "POSTGRESQL_MAX_CONNECTIONS",
  255. "value": "${POSTGRESQL_MAX_CONNECTIONS}"
  256. },
  257. {
  258. "name": "POSTGRESQL_SHARED_BUFFERS",
  259. "value": "${POSTGRESQL_SHARED_BUFFERS}"
  260. },
  261. {
  262. "name": "APPLICATION_DOMAIN",
  263. "value": "${APPLICATION_DOMAIN}"
  264. },
  265. {
  266. "name": "APPLICATION_USER",
  267. "valueFrom": {
  268. "secretKeyRef" : {
  269. "name" : "${NAME}",
  270. "key" : "applicationUser"
  271. }
  272. }
  273. },
  274. {
  275. "name": "APPLICATION_PASSWORD",
  276. "valueFrom": {
  277. "secretKeyRef" : {
  278. "name" : "${NAME}",
  279. "key" : "applicationPassword"
  280. }
  281. }
  282. },
  283. {
  284. "name": "RAILS_ENV",
  285. "value": "${RAILS_ENV}"
  286. }
  287. ],
  288. "resources": {
  289. "limits": {
  290. "memory": "${MEMORY_LIMIT}"
  291. }
  292. }
  293. }
  294. ]
  295. }
  296. }
  297. }
  298. },
  299. {
  300. "kind": "Service",
  301. "apiVersion": "v1",
  302. "metadata": {
  303. "name": "${DATABASE_SERVICE_NAME}",
  304. "annotations": {
  305. "description": "Exposes the database server"
  306. }
  307. },
  308. "spec": {
  309. "ports": [
  310. {
  311. "name": "postgresql",
  312. "port": 5432,
  313. "targetPort": 5432
  314. }
  315. ],
  316. "selector": {
  317. "name": "${DATABASE_SERVICE_NAME}"
  318. }
  319. }
  320. },
  321. {
  322. "kind": "DeploymentConfig",
  323. "apiVersion": "v1",
  324. "metadata": {
  325. "name": "${DATABASE_SERVICE_NAME}",
  326. "annotations": {
  327. "description": "Defines how to deploy the database"
  328. }
  329. },
  330. "spec": {
  331. "strategy": {
  332. "type": "Recreate"
  333. },
  334. "triggers": [
  335. {
  336. "type": "ImageChange",
  337. "imageChangeParams": {
  338. "automatic": true,
  339. "containerNames": [
  340. "postgresql"
  341. ],
  342. "from": {
  343. "kind": "ImageStreamTag",
  344. "namespace": "${NAMESPACE}",
  345. "name": "postgresql:9.5"
  346. }
  347. }
  348. },
  349. {
  350. "type": "ConfigChange"
  351. }
  352. ],
  353. "replicas": 1,
  354. "selector": {
  355. "name": "${DATABASE_SERVICE_NAME}"
  356. },
  357. "template": {
  358. "metadata": {
  359. "name": "${DATABASE_SERVICE_NAME}",
  360. "labels": {
  361. "name": "${DATABASE_SERVICE_NAME}"
  362. }
  363. },
  364. "spec": {
  365. "volumes": [
  366. {
  367. "name": "data",
  368. "emptyDir": {}
  369. }
  370. ],
  371. "containers": [
  372. {
  373. "name": "postgresql",
  374. "image": " ",
  375. "ports": [
  376. {
  377. "containerPort": 5432
  378. }
  379. ],
  380. "readinessProbe": {
  381. "timeoutSeconds": 1,
  382. "initialDelaySeconds": 5,
  383. "exec": {
  384. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'"]
  385. }
  386. },
  387. "livenessProbe": {
  388. "timeoutSeconds": 1,
  389. "initialDelaySeconds": 30,
  390. "tcpSocket": {
  391. "port": 5432
  392. }
  393. },
  394. "volumeMounts": [
  395. {
  396. "name": "data",
  397. "mountPath": "/var/lib/pgsql/data"
  398. }
  399. ],
  400. "env": [
  401. {
  402. "name": "POSTGRESQL_USER",
  403. "value": "${DATABASE_USER}"
  404. },
  405. {
  406. "name": "POSTGRESQL_PASSWORD",
  407. "value": "${DATABASE_PASSWORD}"
  408. },
  409. {
  410. "name": "POSTGRESQL_DATABASE",
  411. "value": "${DATABASE_NAME}"
  412. },
  413. {
  414. "name": "POSTGRESQL_MAX_CONNECTIONS",
  415. "value": "${POSTGRESQL_MAX_CONNECTIONS}"
  416. },
  417. {
  418. "name": "POSTGRESQL_SHARED_BUFFERS",
  419. "value": "${POSTGRESQL_SHARED_BUFFERS}"
  420. }
  421. ],
  422. "resources": {
  423. "limits": {
  424. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  425. }
  426. }
  427. }
  428. ]
  429. }
  430. }
  431. }
  432. }
  433. ],
  434. "parameters": [
  435. {
  436. "name": "NAME",
  437. "displayName": "Name",
  438. "description": "The name assigned to all of the frontend objects defined in this template.",
  439. "required": true,
  440. "value": "rails-postgresql-example"
  441. },
  442. {
  443. "name": "NAMESPACE",
  444. "displayName": "Namespace",
  445. "required": true,
  446. "description": "The OpenShift Namespace where the ImageStream resides.",
  447. "value": "openshift"
  448. },
  449. {
  450. "name": "MEMORY_LIMIT",
  451. "displayName": "Memory Limit",
  452. "required": true,
  453. "description": "Maximum amount of memory the Rails container can use.",
  454. "value": "512Mi"
  455. },
  456. {
  457. "name": "MEMORY_POSTGRESQL_LIMIT",
  458. "displayName": "Memory Limit (PostgreSQL)",
  459. "required": true,
  460. "description": "Maximum amount of memory the PostgreSQL container can use.",
  461. "value": "512Mi"
  462. },
  463. {
  464. "name": "SOURCE_REPOSITORY_URL",
  465. "displayName": "Git Repository URL",
  466. "required": true,
  467. "description": "The URL of the repository with your application source code.",
  468. "value": "https://github.com/openshift/rails-ex.git"
  469. },
  470. {
  471. "name": "SOURCE_REPOSITORY_REF",
  472. "displayName": "Git Reference",
  473. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  474. },
  475. {
  476. "name": "CONTEXT_DIR",
  477. "displayName": "Context Directory",
  478. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  479. },
  480. {
  481. "name": "APPLICATION_DOMAIN",
  482. "displayName": "Application Hostname",
  483. "description": "The exposed hostname that will route to the Rails service, if left blank a value will be defaulted.",
  484. "value": ""
  485. },
  486. {
  487. "name": "GITHUB_WEBHOOK_SECRET",
  488. "displayName": "GitHub Webhook Secret",
  489. "description": "A secret string used to configure the GitHub webhook.",
  490. "generate": "expression",
  491. "from": "[a-zA-Z0-9]{40}"
  492. },
  493. {
  494. "name": "SECRET_KEY_BASE",
  495. "displayName": "Secret Key",
  496. "description": "Your secret key for verifying the integrity of signed cookies.",
  497. "generate": "expression",
  498. "from": "[a-z0-9]{127}"
  499. },
  500. {
  501. "name": "APPLICATION_USER",
  502. "displayName": "Application Username",
  503. "required": true,
  504. "description": "The application user that is used within the sample application to authorize access on pages.",
  505. "value": "openshift"
  506. },
  507. {
  508. "name": "APPLICATION_PASSWORD",
  509. "displayName": "Application Password",
  510. "required": true,
  511. "description": "The application password that is used within the sample application to authorize access on pages.",
  512. "value": "secret"
  513. },
  514. {
  515. "name": "RAILS_ENV",
  516. "displayName": "Rails Environment",
  517. "required": true,
  518. "description": "Environment under which the sample application will run. Could be set to production, development or test.",
  519. "value": "production"
  520. },
  521. {
  522. "name": "DATABASE_SERVICE_NAME",
  523. "required": true,
  524. "displayName": "Database Service Name",
  525. "value": "postgresql"
  526. },
  527. {
  528. "name": "DATABASE_USER",
  529. "displayName": "Database Username",
  530. "generate": "expression",
  531. "from": "user[A-Z0-9]{3}"
  532. },
  533. {
  534. "name": "DATABASE_PASSWORD",
  535. "displayName": "Database Password",
  536. "generate": "expression",
  537. "from": "[a-zA-Z0-9]{8}"
  538. },
  539. {
  540. "name": "DATABASE_NAME",
  541. "required": true,
  542. "displayName": "Database Name",
  543. "value": "root"
  544. },
  545. {
  546. "name": "POSTGRESQL_MAX_CONNECTIONS",
  547. "displayName": "Maximum Database Connections",
  548. "value": "100"
  549. },
  550. {
  551. "name": "POSTGRESQL_SHARED_BUFFERS",
  552. "displayName": "Shared Buffer Amount",
  553. "value": "12MB"
  554. },
  555. {
  556. "name": "RUBYGEM_MIRROR",
  557. "displayName": "Custom RubyGems Mirror URL",
  558. "description": "The custom RubyGems mirror URL",
  559. "value": ""
  560. }
  561. ]
  562. }