rails-postgresql.json 17 KB

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