rails-postgresql-persistent.json 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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. },
  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": "SECRET_KEY_BASE",
  246. "valueFrom": {
  247. "secretKeyRef" : {
  248. "name" : "${NAME}",
  249. "key" : "keybase"
  250. }
  251. }
  252. },
  253. {
  254. "name": "POSTGRESQL_DATABASE",
  255. "value": "${DATABASE_NAME}"
  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": "PersistentVolumeClaim",
  305. "apiVersion": "v1",
  306. "metadata": {
  307. "name": "${DATABASE_SERVICE_NAME}"
  308. },
  309. "spec": {
  310. "accessModes": [
  311. "ReadWriteOnce"
  312. ],
  313. "resources": {
  314. "requests": {
  315. "storage": "${VOLUME_CAPACITY}"
  316. }
  317. }
  318. }
  319. },
  320. {
  321. "kind": "Service",
  322. "apiVersion": "v1",
  323. "metadata": {
  324. "name": "${DATABASE_SERVICE_NAME}",
  325. "annotations": {
  326. "description": "Exposes the database server"
  327. }
  328. },
  329. "spec": {
  330. "ports": [
  331. {
  332. "name": "postgresql",
  333. "port": 5432,
  334. "targetPort": 5432
  335. }
  336. ],
  337. "selector": {
  338. "name": "${DATABASE_SERVICE_NAME}"
  339. }
  340. }
  341. },
  342. {
  343. "kind": "DeploymentConfig",
  344. "apiVersion": "v1",
  345. "metadata": {
  346. "name": "${DATABASE_SERVICE_NAME}",
  347. "annotations": {
  348. "description": "Defines how to deploy the database"
  349. }
  350. },
  351. "spec": {
  352. "strategy": {
  353. "type": "Recreate"
  354. },
  355. "triggers": [
  356. {
  357. "type": "ImageChange",
  358. "imageChangeParams": {
  359. "automatic": true,
  360. "containerNames": [
  361. "postgresql"
  362. ],
  363. "from": {
  364. "kind": "ImageStreamTag",
  365. "namespace": "${NAMESPACE}",
  366. "name": "postgresql:9.5"
  367. }
  368. }
  369. },
  370. {
  371. "type": "ConfigChange"
  372. }
  373. ],
  374. "replicas": 1,
  375. "selector": {
  376. "name": "${DATABASE_SERVICE_NAME}"
  377. },
  378. "template": {
  379. "metadata": {
  380. "name": "${DATABASE_SERVICE_NAME}",
  381. "labels": {
  382. "name": "${DATABASE_SERVICE_NAME}"
  383. }
  384. },
  385. "spec": {
  386. "volumes": [
  387. {
  388. "name": "${DATABASE_SERVICE_NAME}-data",
  389. "persistentVolumeClaim": {
  390. "claimName": "${DATABASE_SERVICE_NAME}"
  391. }
  392. }
  393. ],
  394. "containers": [
  395. {
  396. "name": "postgresql",
  397. "image": " ",
  398. "ports": [
  399. {
  400. "containerPort": 5432
  401. }
  402. ],
  403. "readinessProbe": {
  404. "timeoutSeconds": 1,
  405. "initialDelaySeconds": 5,
  406. "exec": {
  407. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'"]
  408. }
  409. },
  410. "livenessProbe": {
  411. "timeoutSeconds": 1,
  412. "initialDelaySeconds": 30,
  413. "tcpSocket": {
  414. "port": 5432
  415. }
  416. },
  417. "volumeMounts": [
  418. {
  419. "name": "${DATABASE_SERVICE_NAME}-data",
  420. "mountPath": "/var/lib/pgsql/data"
  421. }
  422. ],
  423. "env": [
  424. {
  425. "name": "POSTGRESQL_USER",
  426. "valueFrom": {
  427. "secretKeyRef" : {
  428. "name" : "${NAME}",
  429. "key" : "database-user"
  430. }
  431. }
  432. },
  433. {
  434. "name": "POSTGRESQL_PASSWORD",
  435. "valueFrom": {
  436. "secretKeyRef" : {
  437. "name" : "${NAME}",
  438. "key" : "database-password"
  439. }
  440. }
  441. },
  442. {
  443. "name": "POSTGRESQL_DATABASE",
  444. "value": "${DATABASE_NAME}"
  445. },
  446. {
  447. "name": "POSTGRESQL_MAX_CONNECTIONS",
  448. "value": "${POSTGRESQL_MAX_CONNECTIONS}"
  449. },
  450. {
  451. "name": "POSTGRESQL_SHARED_BUFFERS",
  452. "value": "${POSTGRESQL_SHARED_BUFFERS}"
  453. }
  454. ],
  455. "resources": {
  456. "limits": {
  457. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  458. }
  459. }
  460. }
  461. ]
  462. }
  463. }
  464. }
  465. }
  466. ],
  467. "parameters": [
  468. {
  469. "name": "NAME",
  470. "displayName": "Name",
  471. "description": "The name assigned to all of the frontend objects defined in this template.",
  472. "required": true,
  473. "value": "rails-pgsql-persistent"
  474. },
  475. {
  476. "name": "NAMESPACE",
  477. "displayName": "Namespace",
  478. "required": true,
  479. "description": "The OpenShift Namespace where the ImageStream resides.",
  480. "value": "openshift"
  481. },
  482. {
  483. "name": "MEMORY_LIMIT",
  484. "displayName": "Memory Limit",
  485. "required": true,
  486. "description": "Maximum amount of memory the Rails container can use.",
  487. "value": "512Mi"
  488. },
  489. {
  490. "name": "MEMORY_POSTGRESQL_LIMIT",
  491. "displayName": "Memory Limit (PostgreSQL)",
  492. "required": true,
  493. "description": "Maximum amount of memory the PostgreSQL container can use.",
  494. "value": "512Mi"
  495. },
  496. {
  497. "name": "VOLUME_CAPACITY",
  498. "displayName": "Volume Capacity",
  499. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  500. "value": "1Gi",
  501. "required": true
  502. },
  503. {
  504. "name": "SOURCE_REPOSITORY_URL",
  505. "displayName": "Git Repository URL",
  506. "required": true,
  507. "description": "The URL of the repository with your application source code.",
  508. "value": "https://github.com/openshift/rails-ex.git"
  509. },
  510. {
  511. "name": "SOURCE_REPOSITORY_REF",
  512. "displayName": "Git Reference",
  513. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  514. },
  515. {
  516. "name": "CONTEXT_DIR",
  517. "displayName": "Context Directory",
  518. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  519. },
  520. {
  521. "name": "APPLICATION_DOMAIN",
  522. "displayName": "Application Hostname",
  523. "description": "The exposed hostname that will route to the Rails service, if left blank a value will be defaulted.",
  524. "value": ""
  525. },
  526. {
  527. "name": "GITHUB_WEBHOOK_SECRET",
  528. "displayName": "GitHub Webhook Secret",
  529. "description": "A secret string used to configure the GitHub webhook.",
  530. "generate": "expression",
  531. "from": "[a-zA-Z0-9]{40}"
  532. },
  533. {
  534. "name": "SECRET_KEY_BASE",
  535. "displayName": "Secret Key",
  536. "description": "Your secret key for verifying the integrity of signed cookies.",
  537. "generate": "expression",
  538. "from": "[a-z0-9]{127}"
  539. },
  540. {
  541. "name": "APPLICATION_USER",
  542. "displayName": "Application Username",
  543. "required": true,
  544. "description": "The application user that is used within the sample application to authorize access on pages.",
  545. "value": "openshift"
  546. },
  547. {
  548. "name": "APPLICATION_PASSWORD",
  549. "displayName": "Application Password",
  550. "required": true,
  551. "description": "The application password that is used within the sample application to authorize access on pages.",
  552. "value": "secret"
  553. },
  554. {
  555. "name": "RAILS_ENV",
  556. "displayName": "Rails Environment",
  557. "required": true,
  558. "description": "Environment under which the sample application will run. Could be set to production, development or test.",
  559. "value": "production"
  560. },
  561. {
  562. "name": "DATABASE_SERVICE_NAME",
  563. "required": true,
  564. "displayName": "Database Service Name",
  565. "value": "postgresql"
  566. },
  567. {
  568. "name": "DATABASE_USER",
  569. "displayName": "Database Username",
  570. "generate": "expression",
  571. "from": "user[A-Z0-9]{3}"
  572. },
  573. {
  574. "name": "DATABASE_PASSWORD",
  575. "displayName": "Database Password",
  576. "generate": "expression",
  577. "from": "[a-zA-Z0-9]{8}"
  578. },
  579. {
  580. "name": "DATABASE_NAME",
  581. "required": true,
  582. "displayName": "Database Name",
  583. "value": "root"
  584. },
  585. {
  586. "name": "POSTGRESQL_MAX_CONNECTIONS",
  587. "displayName": "Maximum Database Connections",
  588. "value": "100"
  589. },
  590. {
  591. "name": "POSTGRESQL_SHARED_BUFFERS",
  592. "displayName": "Shared Buffer Amount",
  593. "value": "12MB"
  594. },
  595. {
  596. "name": "RUBYGEM_MIRROR",
  597. "displayName": "Custom RubyGems Mirror URL",
  598. "description": "The custom RubyGems mirror URL",
  599. "value": ""
  600. }
  601. ]
  602. }