rails-postgresql-persistent.json 18 KB

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