rails-postgresql.json 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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": " ",
  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": true,
  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. "volumes": [
  318. {
  319. "name": "data",
  320. "emptyDir": {}
  321. }
  322. ],
  323. "containers": [
  324. {
  325. "name": "postgresql",
  326. "image": " ",
  327. "ports": [
  328. {
  329. "containerPort": 5432
  330. }
  331. ],
  332. "readinessProbe": {
  333. "timeoutSeconds": 1,
  334. "initialDelaySeconds": 5,
  335. "exec": {
  336. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'"]
  337. }
  338. },
  339. "livenessProbe": {
  340. "timeoutSeconds": 1,
  341. "initialDelaySeconds": 30,
  342. "tcpSocket": {
  343. "port": 5432
  344. }
  345. },
  346. "volumeMounts": [
  347. {
  348. "name": "data",
  349. "mountPath": "/var/lib/pgsql/data"
  350. }
  351. ],
  352. "env": [
  353. {
  354. "name": "POSTGRESQL_USER",
  355. "value": "${DATABASE_USER}"
  356. },
  357. {
  358. "name": "POSTGRESQL_PASSWORD",
  359. "value": "${DATABASE_PASSWORD}"
  360. },
  361. {
  362. "name": "POSTGRESQL_DATABASE",
  363. "value": "${DATABASE_NAME}"
  364. },
  365. {
  366. "name": "POSTGRESQL_MAX_CONNECTIONS",
  367. "value": "${POSTGRESQL_MAX_CONNECTIONS}"
  368. },
  369. {
  370. "name": "POSTGRESQL_SHARED_BUFFERS",
  371. "value": "${POSTGRESQL_SHARED_BUFFERS}"
  372. }
  373. ],
  374. "resources": {
  375. "limits": {
  376. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  377. }
  378. }
  379. }
  380. ]
  381. }
  382. }
  383. }
  384. }
  385. ],
  386. "parameters": [
  387. {
  388. "name": "NAME",
  389. "displayName": "Name",
  390. "description": "The name assigned to all of the frontend objects defined in this template.",
  391. "required": true,
  392. "value": "rails-postgresql-example"
  393. },
  394. {
  395. "name": "NAMESPACE",
  396. "displayName": "Namespace",
  397. "description": "The OpenShift Namespace where the ImageStream resides.",
  398. "value": "openshift"
  399. },
  400. {
  401. "name": "MEMORY_LIMIT",
  402. "displayName": "Memory Limit",
  403. "description": "Maximum amount of memory the Rails container can use.",
  404. "value": "512Mi"
  405. },
  406. {
  407. "name": "MEMORY_POSTGRESQL_LIMIT",
  408. "displayName": "Memory Limit (PostgreSQL)",
  409. "description": "Maximum amount of memory the PostgreSQL container can use.",
  410. "value": "512Mi"
  411. },
  412. {
  413. "name": "SOURCE_REPOSITORY_URL",
  414. "displayName": "Git Repository URL",
  415. "description": "The URL of the repository with your application source code.",
  416. "value": "https://github.com/openshift/rails-ex.git"
  417. },
  418. {
  419. "name": "SOURCE_REPOSITORY_REF",
  420. "displayName": "Git Reference",
  421. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  422. },
  423. {
  424. "name": "CONTEXT_DIR",
  425. "displayName": "Context Directory",
  426. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  427. },
  428. {
  429. "name": "APPLICATION_DOMAIN",
  430. "displayName": "Application Hostname",
  431. "description": "The exposed hostname that will route to the Rails service, if left blank a value will be defaulted.",
  432. "value": ""
  433. },
  434. {
  435. "name": "GITHUB_WEBHOOK_SECRET",
  436. "displayName": "GitHub Webhook Secret",
  437. "description": "A secret string used to configure the GitHub webhook.",
  438. "generate": "expression",
  439. "from": "[a-zA-Z0-9]{40}"
  440. },
  441. {
  442. "name": "SECRET_KEY_BASE",
  443. "displayName": "Secret Key",
  444. "description": "Your secret key for verifying the integrity of signed cookies.",
  445. "generate": "expression",
  446. "from": "[a-z0-9]{127}"
  447. },
  448. {
  449. "name": "APPLICATION_USER",
  450. "displayName": "Application Username",
  451. "description": "The application user that is used within the sample application to authorize access on pages.",
  452. "value": "openshift"
  453. },
  454. {
  455. "name": "APPLICATION_PASSWORD",
  456. "displayName": "Application Password",
  457. "description": "The application password that is used within the sample application to authorize access on pages.",
  458. "value": "secret"
  459. },
  460. {
  461. "name": "RAILS_ENV",
  462. "displayName": "Rails Environment",
  463. "description": "Environment under which the sample application will run. Could be set to production, development or test.",
  464. "value": "production"
  465. },
  466. {
  467. "name": "DATABASE_SERVICE_NAME",
  468. "displayName": "Database Service Name",
  469. "value": "postgresql"
  470. },
  471. {
  472. "name": "DATABASE_USER",
  473. "displayName": "Database Username",
  474. "generate": "expression",
  475. "from": "user[A-Z0-9]{3}"
  476. },
  477. {
  478. "name": "DATABASE_PASSWORD",
  479. "displayName": "Database Password",
  480. "generate": "expression",
  481. "from": "[a-zA-Z0-9]{8}"
  482. },
  483. {
  484. "name": "DATABASE_NAME",
  485. "displayName": "Database Name",
  486. "value": "root"
  487. },
  488. {
  489. "name": "POSTGRESQL_MAX_CONNECTIONS",
  490. "displayName": "Maximum Database Connections",
  491. "value": "100"
  492. },
  493. {
  494. "name": "POSTGRESQL_SHARED_BUFFERS",
  495. "displayName": "Shared Buffer Amount",
  496. "value": "12MB"
  497. }
  498. ]
  499. }