rails-postgresql.json 15 KB

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