rails-postgresql-persistent.json 17 KB

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