huginn-postgresql.json 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "huginn-pgsql-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "Huginn + PostgreSQL (Persistent)",
  8. "description": "A Huginn deployment with a PostgreSQL database. For more information, see https://github.com/huginn/huginn.",
  9. "tags": "quickstart,ruby,huginn",
  10. "iconClass": "icon-huginn"
  11. }
  12. },
  13. "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}. Visit https://${NAME}-YOUR_PROJECT_NAME.${ROUTER_SHARD}.${CLUSTER_NAME}.openshiftapps.com and login as '${HUGINN_SEED_USERNAME}' with your password. If you'd like to make more users, you can visit https://${NAME}-YOUR_PROJECT_NAME.${ROUTER_SHARD}.${CLUSTER_NAME}.openshiftapps.com/users/sign_up and use the invitation code: ${HUGINN_INVITATION_CODE}\n\nFor more information, see https://github.com/huginn/huginn.",
  14. "labels": {
  15. "template": "huginn-pgsql-persistent"
  16. },
  17. "objects": [{
  18. "kind": "Secret",
  19. "apiVersion": "v1",
  20. "metadata": {
  21. "name": "${NAME}"
  22. },
  23. "stringData" : {
  24. "databaseName" : "${DATABASE_NAME}",
  25. "databaseUser" : "${DATABASE_USER}",
  26. "databasePassword" : "${DATABASE_PASSWORD}",
  27. "seedUser" : "${HUGINN_SEED_USERNAME}",
  28. "seedPassword" : "${HUGINN_SEED_PASSWORD}",
  29. "seedEmail" : "${HUGINN_SEED_EMAIL}",
  30. "smtpDomain" : "${HUGINN_SMTP_DOMAIN}",
  31. "smtpUser" : "${HUGINN_SMTP_USER_NAME}",
  32. "smtpPassword" : "${HUGINN_SMTP_PASSWORD}",
  33. "smtpServer" : "${HUGINN_SMTP_SERVER}"
  34. }
  35. }, {
  36. "kind": "Service",
  37. "apiVersion": "v1",
  38. "metadata": {
  39. "name": "${NAME}",
  40. "annotations": {
  41. "description": "Exposes and load balances the application pods",
  42. "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]"
  43. }
  44. },
  45. "spec": {
  46. "ports": [{
  47. "name": "web",
  48. "port": 8080,
  49. "targetPort": 8080
  50. }],
  51. "selector": {
  52. "name": "${NAME}"
  53. }
  54. }
  55. }, {
  56. "kind": "Route",
  57. "apiVersion": "v1",
  58. "metadata": {
  59. "name": "${NAME}"
  60. },
  61. "spec": {
  62. "host": "${APPLICATION_DOMAIN}",
  63. "tls": {
  64. "insecureEdgeTerminationPolicy": "Redirect",
  65. "termination": "edge"
  66. },
  67. "to": {
  68. "kind": "Service",
  69. "name": "${NAME}"
  70. }
  71. }
  72. }, {
  73. "kind": "ImageStream",
  74. "apiVersion": "v1",
  75. "metadata": {
  76. "name": "${NAME}",
  77. "annotations": {
  78. "description": "Keeps track of changes in the application image"
  79. }
  80. }
  81. }, {
  82. "kind": "BuildConfig",
  83. "apiVersion": "v1",
  84. "metadata": {
  85. "name": "${NAME}",
  86. "annotations": {
  87. "description": "Defines how to build the application"
  88. }
  89. },
  90. "spec": {
  91. "source": {
  92. "type": "Git",
  93. "git": {
  94. "uri": "${SOURCE_REPOSITORY_URL}",
  95. "ref": "${SOURCE_REPOSITORY_REF}"
  96. },
  97. "contextDir": "${CONTEXT_DIR}"
  98. },
  99. "resources": {
  100. "limits": {
  101. "memory": "${BUILD_MEMORY_LIMIT}"
  102. }
  103. },
  104. "strategy": {
  105. "type": "Source",
  106. "sourceStrategy": {
  107. "from": {
  108. "kind": "ImageStreamTag",
  109. "namespace": "${NAMESPACE}",
  110. "name": "ruby:2.5"
  111. },
  112. "env": [{
  113. "name": "APP_SECRET_TOKEN",
  114. "value": "${HUGINN_APP_SECRET}"
  115. }, {
  116. "name": "DATABASE_ADAPTER",
  117. "value": "${DATABASE_ADAPTER}"
  118. }, {
  119. "name": "LC_ALL",
  120. "value": "en_US.UTF-8"
  121. }, {
  122. "name": "ON_HEROKU",
  123. "value": "true"
  124. }]
  125. }
  126. },
  127. "output": {
  128. "to": {
  129. "kind": "ImageStreamTag",
  130. "name": "${NAME}:latest"
  131. }
  132. },
  133. "triggers": [{
  134. "type": "ImageChange"
  135. }, {
  136. "type": "ConfigChange"
  137. }, {
  138. "type": "GitHub",
  139. "github": {
  140. "secret": "${GITHUB_WEBHOOK_SECRET}"
  141. }
  142. }]
  143. }
  144. }, {
  145. "kind": "PersistentVolumeClaim",
  146. "apiVersion": "v1",
  147. "metadata": {
  148. "name": "${DATABASE_SERVICE_NAME}"
  149. },
  150. "spec": {
  151. "accessModes": [
  152. "ReadWriteOnce"
  153. ],
  154. "resources": {
  155. "requests": {
  156. "storage": "${VOLUME_CAPACITY}"
  157. }
  158. }
  159. }
  160. }, {
  161. "kind": "DeploymentConfig",
  162. "apiVersion": "v1",
  163. "metadata": {
  164. "name": "${NAME}",
  165. "annotations": {
  166. "description": "Defines how to deploy the application server"
  167. }
  168. },
  169. "spec": {
  170. "strategy": {
  171. "type": "Recreate"
  172. },
  173. "triggers": [{
  174. "type": "ImageChange",
  175. "imageChangeParams": {
  176. "automatic": true,
  177. "containerNames": [
  178. "huginn-pgsql-persistent"
  179. ],
  180. "from": {
  181. "kind": "ImageStreamTag",
  182. "name": "${NAME}:latest"
  183. }
  184. }
  185. }, {
  186. "type": "ConfigChange"
  187. }],
  188. "replicas": 1,
  189. "selector": {
  190. "name": "${NAME}"
  191. },
  192. "template": {
  193. "metadata": {
  194. "name": "${NAME}",
  195. "labels": {
  196. "name": "${NAME}"
  197. }
  198. },
  199. "spec": {
  200. "containers": [{
  201. "name": "huginn-pgsql-persistent",
  202. "image": "${NAME}",
  203. "ports": [{
  204. "containerPort": 8080
  205. }],
  206. "readinessProbe": {
  207. "timeoutSeconds": 3,
  208. "initialDelaySeconds": 3,
  209. "httpGet": {
  210. "path": "/",
  211. "port": 8080
  212. }
  213. },
  214. "livenessProbe": {
  215. "timeoutSeconds": 3,
  216. "initialDelaySeconds": 30,
  217. "httpGet": {
  218. "path": "/",
  219. "port": 8080
  220. }
  221. },
  222. "env": [{
  223. "name": "SEED_USERNAME",
  224. "valueFrom": {
  225. "secretKeyRef" : {
  226. "name" : "${NAME}",
  227. "key" : "seedUser"
  228. }
  229. }
  230. }, {
  231. "name": "SEED_PASSWORD",
  232. "valueFrom": {
  233. "secretKeyRef" : {
  234. "name" : "${NAME}",
  235. "key" : "seedPassword"
  236. }
  237. }
  238. }, {
  239. "name": "SEED_EMAIL",
  240. "valueFrom": {
  241. "secretKeyRef" : {
  242. "name" : "${NAME}",
  243. "key" : "seedEmail"
  244. }
  245. }
  246. }, {
  247. "name": "INVITATION_CODE",
  248. "value": "${HUGINN_INVITATION_CODE}"
  249. }, {
  250. "name": "SMTP_DOMAIN",
  251. "valueFrom": {
  252. "secretKeyRef" : {
  253. "name" : "${NAME}",
  254. "key" : "smtpDomain"
  255. }
  256. }
  257. }, {
  258. "name": "SMTP_USER_NAME",
  259. "valueFrom": {
  260. "secretKeyRef" : {
  261. "name" : "${NAME}",
  262. "key" : "smtpUser"
  263. }
  264. }
  265. }, {
  266. "name": "SMTP_PASSWORD",
  267. "valueFrom": {
  268. "secretKeyRef" : {
  269. "name" : "${NAME}",
  270. "key" : "smtpPassword"
  271. }
  272. }
  273. }, {
  274. "name": "SMTP_SERVER",
  275. "valueFrom": {
  276. "secretKeyRef" : {
  277. "name" : "${NAME}",
  278. "key" : "smtpServer"
  279. }
  280. }
  281. }, {
  282. "name": "EMAIL_FROM_ADDRESS",
  283. "value": "${HUGINN_EMAIL_FROM_ADDRESS}"
  284. }, {
  285. "name": "APPLICATION_DOMAIN",
  286. "value": "${APPLICATION_DOMAIN}"
  287. }, {
  288. "name": "RAILS_ENV",
  289. "value": "${HUGINN_RAILS_ENV}"
  290. }, {
  291. "name": "OPCACHE_REVALIDATE_FREQ",
  292. "value": "${OPCACHE_REVALIDATE_FREQ}"
  293. }, {
  294. "name": "DATABASE_NAME",
  295. "valueFrom": {
  296. "secretKeyRef" : {
  297. "name" : "${NAME}",
  298. "key" : "databaseName"
  299. }
  300. }
  301. }, {
  302. "name": "DATABASE_USERNAME",
  303. "valueFrom": {
  304. "secretKeyRef" : {
  305. "name" : "${NAME}",
  306. "key" : "databaseUser"
  307. }
  308. }
  309. }, {
  310. "name": "DATABASE_PASSWORD",
  311. "valueFrom": {
  312. "secretKeyRef" : {
  313. "name" : "${NAME}",
  314. "key" : "databasePassword"
  315. }
  316. }
  317. }, {
  318. "name": "DATABASE_HOST",
  319. "value": "${DATABASE_SERVICE_NAME}_SERVICE_HOST"
  320. }, {
  321. "name": "DATABASE_PORT",
  322. "value": "${DATABASE_SERVICE_NAME}_SERVICE_PORT"
  323. }, {
  324. "name": "DATABASE_ENCODING",
  325. "value": "utf8"
  326. }, {
  327. "name": "DO_NOT_CREATE_DATABASE",
  328. "value": "1"
  329. }, {
  330. "name": "RAILS_SERVE_STATIC_FILES",
  331. "value": "1"
  332. }, {
  333. "name": "WORKER_CMD",
  334. "value": "unicorn -c ./deployment/heroku/unicorn.rb --listen 0.0.0.0:8080"
  335. }],
  336. "resources": {
  337. "limits": {
  338. "memory": "${MEMORY_LIMIT}"
  339. }
  340. }
  341. }]
  342. }
  343. }
  344. }
  345. }, {
  346. "kind": "Service",
  347. "apiVersion": "v1",
  348. "metadata": {
  349. "name": "${DATABASE_SERVICE_NAME}",
  350. "annotations": {
  351. "description": "Exposes the database server"
  352. }
  353. },
  354. "spec": {
  355. "ports": [{
  356. "name": "pgsql",
  357. "port": 5432,
  358. "targetPort": 5432
  359. }],
  360. "selector": {
  361. "name": "${DATABASE_SERVICE_NAME}"
  362. }
  363. }
  364. }, {
  365. "kind": "DeploymentConfig",
  366. "apiVersion": "v1",
  367. "metadata": {
  368. "name": "${DATABASE_SERVICE_NAME}",
  369. "annotations": {
  370. "description": "Defines how to deploy the database"
  371. }
  372. },
  373. "spec": {
  374. "strategy": {
  375. "type": "Recreate"
  376. },
  377. "triggers": [{
  378. "type": "ImageChange",
  379. "imageChangeParams": {
  380. "automatic": true,
  381. "containerNames": [
  382. "postgresql"
  383. ],
  384. "from": {
  385. "kind": "ImageStreamTag",
  386. "namespace": "${NAMESPACE}",
  387. "name": "postgresql:9.6"
  388. }
  389. }
  390. }, {
  391. "type": "ConfigChange"
  392. }],
  393. "replicas": 1,
  394. "selector": {
  395. "name": "${DATABASE_SERVICE_NAME}"
  396. },
  397. "template": {
  398. "metadata": {
  399. "name": "${DATABASE_SERVICE_NAME}",
  400. "labels": {
  401. "name": "${DATABASE_SERVICE_NAME}"
  402. }
  403. },
  404. "spec": {
  405. "containers": [{
  406. "name": "postgresql",
  407. "image": "postgresql",
  408. "ports": [{
  409. "containerPort": 5432
  410. }],
  411. "readinessProbe": {
  412. "timeoutSeconds": 1,
  413. "initialDelaySeconds": 5,
  414. "exec": {
  415. "command": ["/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${DATABASE_USER} -q -d ${DATABASE_NAME} -c 'SELECT 1'"]
  416. }
  417. },
  418. "livenessProbe": {
  419. "timeoutSeconds": 1,
  420. "initialDelaySeconds": 30,
  421. "tcpSocket": {
  422. "port": 5432
  423. }
  424. },
  425. "env": [{
  426. "name": "POSTGRESQL_DATABASE",
  427. "valueFrom": {
  428. "secretKeyRef" : {
  429. "name" : "${NAME}",
  430. "key" : "databaseName"
  431. }
  432. }
  433. }, {
  434. "name": "POSTGRESQL_USER",
  435. "valueFrom": {
  436. "secretKeyRef" : {
  437. "name" : "${NAME}",
  438. "key" : "databaseUser"
  439. }
  440. }
  441. }, {
  442. "name": "POSTGRESQL_PASSWORD",
  443. "valueFrom": {
  444. "secretKeyRef" : {
  445. "name" : "${NAME}",
  446. "key" : "databasePassword"
  447. }
  448. }
  449. }],
  450. "resources": {
  451. "limits": {
  452. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  453. }
  454. },
  455. "volumeMounts": [{
  456. "name": "${DATABASE_SERVICE_NAME}-data",
  457. "mountPath": "/var/lib/pgsql/data"
  458. }]
  459. }],
  460. "volumes": [{
  461. "name": "${DATABASE_SERVICE_NAME}-data",
  462. "persistentVolumeClaim": {
  463. "claimName": "${DATABASE_SERVICE_NAME}"
  464. }
  465. }]
  466. }
  467. }
  468. }
  469. }],
  470. "parameters": [{
  471. "name": "NAME",
  472. "displayName": "Name",
  473. "description": "The name assigned to all of the frontend objects defined in this template.",
  474. "required": true,
  475. "value": "huginn"
  476. }, {
  477. "name": "HUGINN_SEED_USERNAME",
  478. "displayName": "Huginn SEED_USERNAME",
  479. "description": "Account ID for the admin user.",
  480. "value": "admin",
  481. "required": true
  482. }, {
  483. "name": "HUGINN_SEED_PASSWORD",
  484. "displayName": "Huginn SEED_PASSWORD",
  485. "description": "Password for the admin user.",
  486. "value": "password",
  487. "required": true
  488. }, {
  489. "name": "HUGINN_SEED_EMAIL",
  490. "displayName": "Huginn SEED_EMAIL",
  491. "description": "Email for the admin user.",
  492. "value": "huginn@example.com",
  493. "required": true
  494. }, {
  495. "name": "HUGINN_INVITATION_CODE",
  496. "displayName": "Huginn INVITATION_CODE",
  497. "description": "If you'd like to invite more users, give them this invitation code.",
  498. "generate": "expression",
  499. "from": "[\\w]{10}"
  500. }, {
  501. "name": "HUGINN_SMTP_DOMAIN",
  502. "displayName": "Huginn SMTP_DOMAIN",
  503. "description": "Domain for outbound emails.",
  504. "value": "example.com",
  505. "required": true
  506. }, {
  507. "name": "HUGINN_SMTP_USER_NAME",
  508. "displayName": "Huginn SMTP_USER_NAME",
  509. "description": "SMTP user name.",
  510. "value": "huginn@example.com",
  511. "required": true
  512. }, {
  513. "name": "HUGINN_SMTP_PASSWORD",
  514. "displayName": "Huginn SMTP_PASSWORD",
  515. "description": "SMTP password.",
  516. "value": "somepassword",
  517. "required": true
  518. }, {
  519. "name": "HUGINN_SMTP_SERVER",
  520. "displayName": "Huginn SMTP_SERVER",
  521. "description": "SMTP server address.",
  522. "value": "smtp.example.com",
  523. "required": true
  524. }, {
  525. "name": "HUGINN_EMAIL_FROM_ADDRESS",
  526. "displayName": "Huginn EMAIL_FROM_ADDRESS",
  527. "description": "The address from which system emails will appear to be sent.",
  528. "value": "huginn@example.com",
  529. "required": true
  530. }, {
  531. "name": "HUGINN_APP_SECRET",
  532. "displayName": "Huginn APP_SECRET_TOKEN",
  533. "description": "Set this to a 64 character random string (e.g., from 'rake secret').",
  534. "generate": "expression",
  535. "from": "[\\w]{64}"
  536. }, {
  537. "name": "SOURCE_REPOSITORY_URL",
  538. "displayName": "Git Repository URL",
  539. "description": "The URL of the repository with your application source code.",
  540. "value": "https://github.com/huginn/huginn.git",
  541. "required": true
  542. }, {
  543. "name": "SOURCE_REPOSITORY_REF",
  544. "displayName": "Git Reference",
  545. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  546. }, {
  547. "name": "CONTEXT_DIR",
  548. "displayName": "Context Directory",
  549. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  550. }, {
  551. "name": "GITHUB_WEBHOOK_SECRET",
  552. "displayName": "GitHub Webhook Secret",
  553. "description": "A secret string used to configure the GitHub webhook.",
  554. "generate": "expression",
  555. "from": "[a-zA-Z0-9]{40}"
  556. }, {
  557. "displayName": "Cluster Name",
  558. "name": "CLUSTER_NAME",
  559. "description": "The name of your current OpenShift cluster (console.CLUSTER_NAME.openshift.com).",
  560. "value": "starter-us-west-2",
  561. "required": true
  562. }, {
  563. "displayName": "Router Shard",
  564. "name": "ROUTER_SHARD",
  565. "description": "The router shard used by routes in your current OpenShift cluster (http://PROJECT_NAME-APPLICATION_NAME.ROUTER_SHARD.CLUSTER_NAME.openshiftapps.com/).",
  566. "value": "7e14",
  567. "required": true
  568. }, {
  569. "name": "APPLICATION_DOMAIN",
  570. "displayName": "Application Hostname",
  571. "description": "The exposed hostname that will route to the Huginn service, if left blank a value will be defaulted.",
  572. "value": ""
  573. }, {
  574. "name": "NAMESPACE",
  575. "displayName": "Namespace",
  576. "description": "The OpenShift Namespace where the ImageStream resides.",
  577. "required": true,
  578. "value": "openshift"
  579. }, {
  580. "name": "DATABASE_SERVICE_NAME",
  581. "displayName": "Database Service Name",
  582. "value": "postgresql",
  583. "required": true
  584. }, {
  585. "name": "HUGINN_RAILS_ENV",
  586. "displayName": "Huginn Application Environment",
  587. "description": "Determines the 'environment' your application is currently.",
  588. "value": "production",
  589. "required": true
  590. }, {
  591. "name": "OPCACHE_REVALIDATE_FREQ",
  592. "displayName": "OPcache Revalidation Frequency",
  593. "description": "How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.",
  594. "value": "0"
  595. }, {
  596. "name": "MEMORY_LIMIT",
  597. "displayName": "Memory Limit",
  598. "description": "Maximum amount of memory the Huginn container can use.",
  599. "value": "1Gi",
  600. "required": true
  601. }, {
  602. "name": "MEMORY_POSTGRESQL_LIMIT",
  603. "displayName": "Memory Limit (PostgreSQL)",
  604. "description": "Maximum amount of memory the PostgreSQL container can use.",
  605. "value": "512Mi",
  606. "required": true
  607. }, {
  608. "name": "BUILD_MEMORY_LIMIT",
  609. "displayName": "Memory Limit",
  610. "description": "Maximum amount of memory the Huginn container can use.",
  611. "value": "1Gi",
  612. "required": true
  613. }, {
  614. "name": "VOLUME_CAPACITY",
  615. "displayName": "Volume Capacity",
  616. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  617. "value": "1Gi",
  618. "required": true
  619. }, {
  620. "name": "DATABASE_ADAPTER",
  621. "displayName": "Database Engine",
  622. "description": "Database engine: mysql2 or postgresql (default).",
  623. "value": "postgresql",
  624. "required": true
  625. }, {
  626. "name": "DATABASE_NAME",
  627. "displayName": "Database Name",
  628. "generate": "expression",
  629. "from": "[a-zA-Z0-9]{6}"
  630. }, {
  631. "name": "DATABASE_USER",
  632. "displayName": "Database User",
  633. "generate": "expression",
  634. "from": "[a-zA-Z0-9]{6}"
  635. }, {
  636. "name": "DATABASE_PASSWORD",
  637. "displayName": "Database Password",
  638. "generate": "expression",
  639. "from": "[a-zA-Z0-9]{16}"
  640. }]
  641. }