rails-postgresql-persistent.json 18 KB

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