rails-postgresql.json 17 KB

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