rails-postgresql.json 13 KB

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