rails-postgresql.json 17 KB

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