django-postgresql.json 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "django-psql-example",
  6. "annotations": {
  7. "openshift.io/display-name": "Django + PostgreSQL (Ephemeral)",
  8. "description": "An example Django application with a PostgreSQL database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/django-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,python,django",
  10. "iconClass": "icon-python",
  11. "template.openshift.io/long-description": "This template defines resources needed to develop a Django based 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/django-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/django-ex/blob/master/README.md.",
  18. "labels": {
  19. "template": "django-psql-example"
  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. "django-secret-key" : "${DJANGO_SECRET_KEY}"
  32. }
  33. },
  34. {
  35. "kind": "Service",
  36. "apiVersion": "v1",
  37. "metadata": {
  38. "name": "${NAME}",
  39. "annotations": {
  40. "description": "Exposes and load balances the application pods",
  41. "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]"
  42. }
  43. },
  44. "spec": {
  45. "ports": [
  46. {
  47. "name": "web",
  48. "port": 8080,
  49. "targetPort": 8080
  50. }
  51. ],
  52. "selector": {
  53. "name": "${NAME}"
  54. }
  55. }
  56. },
  57. {
  58. "kind": "Route",
  59. "apiVersion": "v1",
  60. "metadata": {
  61. "name": "${NAME}"
  62. },
  63. "spec": {
  64. "host": "${APPLICATION_DOMAIN}",
  65. "to": {
  66. "kind": "Service",
  67. "name": "${NAME}"
  68. }
  69. }
  70. },
  71. {
  72. "kind": "ImageStream",
  73. "apiVersion": "v1",
  74. "metadata": {
  75. "name": "${NAME}",
  76. "annotations": {
  77. "description": "Keeps track of changes in the application image"
  78. }
  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. "strategy": {
  100. "type": "Source",
  101. "sourceStrategy": {
  102. "from": {
  103. "kind": "ImageStreamTag",
  104. "namespace": "${NAMESPACE}",
  105. "name": "python:3.5"
  106. },
  107. "env": [
  108. {
  109. "name": "PIP_INDEX_URL",
  110. "value": "${PIP_INDEX_URL}"
  111. }
  112. ]
  113. }
  114. },
  115. "output": {
  116. "to": {
  117. "kind": "ImageStreamTag",
  118. "name": "${NAME}:latest"
  119. }
  120. },
  121. "triggers": [
  122. {
  123. "type": "ImageChange"
  124. },
  125. {
  126. "type": "ConfigChange"
  127. },
  128. {
  129. "type": "GitHub",
  130. "github": {
  131. "secret": "${GITHUB_WEBHOOK_SECRET}"
  132. }
  133. }
  134. ],
  135. "postCommit": {
  136. "script": "./manage.py test"
  137. }
  138. }
  139. },
  140. {
  141. "kind": "DeploymentConfig",
  142. "apiVersion": "v1",
  143. "metadata": {
  144. "name": "${NAME}",
  145. "annotations": {
  146. "description": "Defines how to deploy the application server"
  147. }
  148. },
  149. "spec": {
  150. "strategy": {
  151. "type": "Rolling"
  152. },
  153. "triggers": [
  154. {
  155. "type": "ImageChange",
  156. "imageChangeParams": {
  157. "automatic": true,
  158. "containerNames": [
  159. "django-psql-example"
  160. ],
  161. "from": {
  162. "kind": "ImageStreamTag",
  163. "name": "${NAME}:latest"
  164. }
  165. }
  166. },
  167. {
  168. "type": "ConfigChange"
  169. }
  170. ],
  171. "replicas": 1,
  172. "selector": {
  173. "name": "${NAME}"
  174. },
  175. "template": {
  176. "metadata": {
  177. "name": "${NAME}",
  178. "labels": {
  179. "name": "${NAME}"
  180. }
  181. },
  182. "spec": {
  183. "containers": [
  184. {
  185. "name": "django-psql-example",
  186. "image": " ",
  187. "ports": [
  188. {
  189. "containerPort": 8080
  190. }
  191. ],
  192. "readinessProbe": {
  193. "timeoutSeconds": 3,
  194. "initialDelaySeconds": 3,
  195. "httpGet": {
  196. "path": "/health",
  197. "port": 8080
  198. }
  199. },
  200. "livenessProbe": {
  201. "timeoutSeconds": 3,
  202. "initialDelaySeconds": 30,
  203. "httpGet": {
  204. "path": "/health",
  205. "port": 8080
  206. }
  207. },
  208. "env": [
  209. {
  210. "name": "DATABASE_SERVICE_NAME",
  211. "value": "${DATABASE_SERVICE_NAME}"
  212. },
  213. {
  214. "name": "DATABASE_ENGINE",
  215. "value": "${DATABASE_ENGINE}"
  216. },
  217. {
  218. "name": "DATABASE_NAME",
  219. "value": "${DATABASE_NAME}"
  220. },
  221. {
  222. "name": "DATABASE_USER",
  223. "valueFrom": {
  224. "secretKeyRef" : {
  225. "name" : "${NAME}",
  226. "key" : "database-user"
  227. }
  228. }
  229. },
  230. {
  231. "name": "DATABASE_PASSWORD",
  232. "valueFrom": {
  233. "secretKeyRef" : {
  234. "name" : "${NAME}",
  235. "key" : "database-password"
  236. }
  237. }
  238. },
  239. {
  240. "name": "APP_CONFIG",
  241. "value": "${APP_CONFIG}"
  242. },
  243. {
  244. "name": "DJANGO_SECRET_KEY",
  245. "valueFrom": {
  246. "secretKeyRef" : {
  247. "name" : "${NAME}",
  248. "key" : "django-secret-key"
  249. }
  250. }
  251. }
  252. ],
  253. "resources": {
  254. "limits": {
  255. "memory": "${MEMORY_LIMIT}"
  256. }
  257. }
  258. }
  259. ]
  260. }
  261. }
  262. }
  263. },
  264. {
  265. "kind": "Service",
  266. "apiVersion": "v1",
  267. "metadata": {
  268. "name": "${DATABASE_SERVICE_NAME}",
  269. "annotations": {
  270. "description": "Exposes the database server"
  271. }
  272. },
  273. "spec": {
  274. "ports": [
  275. {
  276. "name": "postgresql",
  277. "port": 5432,
  278. "targetPort": 5432
  279. }
  280. ],
  281. "selector": {
  282. "name": "${DATABASE_SERVICE_NAME}"
  283. }
  284. }
  285. },
  286. {
  287. "kind": "DeploymentConfig",
  288. "apiVersion": "v1",
  289. "metadata": {
  290. "name": "${DATABASE_SERVICE_NAME}",
  291. "annotations": {
  292. "description": "Defines how to deploy the database"
  293. }
  294. },
  295. "spec": {
  296. "strategy": {
  297. "type": "Recreate"
  298. },
  299. "triggers": [
  300. {
  301. "type": "ImageChange",
  302. "imageChangeParams": {
  303. "automatic": true,
  304. "containerNames": [
  305. "postgresql"
  306. ],
  307. "from": {
  308. "kind": "ImageStreamTag",
  309. "namespace": "${NAMESPACE}",
  310. "name": "postgresql:9.5"
  311. }
  312. }
  313. },
  314. {
  315. "type": "ConfigChange"
  316. }
  317. ],
  318. "replicas": 1,
  319. "selector": {
  320. "name": "${DATABASE_SERVICE_NAME}"
  321. },
  322. "template": {
  323. "metadata": {
  324. "name": "${DATABASE_SERVICE_NAME}",
  325. "labels": {
  326. "name": "${DATABASE_SERVICE_NAME}"
  327. }
  328. },
  329. "spec": {
  330. "volumes": [
  331. {
  332. "name": "data",
  333. "emptyDir": {}
  334. }
  335. ],
  336. "containers": [
  337. {
  338. "name": "postgresql",
  339. "image": " ",
  340. "ports": [
  341. {
  342. "containerPort": 5432
  343. }
  344. ],
  345. "env": [
  346. {
  347. "name": "POSTGRESQL_USER",
  348. "valueFrom": {
  349. "secretKeyRef" : {
  350. "name" : "${NAME}",
  351. "key" : "database-user"
  352. }
  353. }
  354. },
  355. {
  356. "name": "POSTGRESQL_PASSWORD",
  357. "valueFrom": {
  358. "secretKeyRef" : {
  359. "name" : "${NAME}",
  360. "key" : "database-password"
  361. }
  362. }
  363. },
  364. {
  365. "name": "POSTGRESQL_DATABASE",
  366. "value": "${DATABASE_NAME}"
  367. }
  368. ],
  369. "volumeMounts": [
  370. {
  371. "name": "data",
  372. "mountPath": "/var/lib/pgsql/data"
  373. }
  374. ],
  375. "readinessProbe": {
  376. "timeoutSeconds": 1,
  377. "initialDelaySeconds": 5,
  378. "exec": {
  379. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'"]
  380. }
  381. },
  382. "livenessProbe": {
  383. "timeoutSeconds": 1,
  384. "initialDelaySeconds": 30,
  385. "tcpSocket": {
  386. "port": 5432
  387. }
  388. },
  389. "resources": {
  390. "limits": {
  391. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  392. }
  393. }
  394. }
  395. ]
  396. }
  397. }
  398. }
  399. }
  400. ],
  401. "parameters": [
  402. {
  403. "name": "NAME",
  404. "displayName": "Name",
  405. "description": "The name assigned to all of the frontend objects defined in this template.",
  406. "required": true,
  407. "value": "django-psql-example"
  408. },
  409. {
  410. "name": "NAMESPACE",
  411. "displayName": "Namespace",
  412. "required": true,
  413. "description": "The OpenShift Namespace where the ImageStream resides.",
  414. "value": "openshift"
  415. },
  416. {
  417. "name": "MEMORY_LIMIT",
  418. "displayName": "Memory Limit",
  419. "required": true,
  420. "description": "Maximum amount of memory the Django container can use.",
  421. "value": "512Mi"
  422. },
  423. {
  424. "name": "MEMORY_POSTGRESQL_LIMIT",
  425. "displayName": "Memory Limit (PostgreSQL)",
  426. "required": true,
  427. "description": "Maximum amount of memory the PostgreSQL container can use.",
  428. "value": "512Mi"
  429. },
  430. {
  431. "name": "SOURCE_REPOSITORY_URL",
  432. "displayName": "Git Repository URL",
  433. "required": true,
  434. "description": "The URL of the repository with your application source code.",
  435. "value": "https://github.com/openshift/django-ex.git"
  436. },
  437. {
  438. "name": "SOURCE_REPOSITORY_REF",
  439. "displayName": "Git Reference",
  440. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  441. },
  442. {
  443. "name": "CONTEXT_DIR",
  444. "displayName": "Context Directory",
  445. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  446. },
  447. {
  448. "name": "APPLICATION_DOMAIN",
  449. "displayName": "Application Hostname",
  450. "description": "The exposed hostname that will route to the Django service, if left blank a value will be defaulted.",
  451. "value": ""
  452. },
  453. {
  454. "name": "GITHUB_WEBHOOK_SECRET",
  455. "displayName": "GitHub Webhook Secret",
  456. "description": "A secret string used to configure the GitHub webhook.",
  457. "generate": "expression",
  458. "from": "[a-zA-Z0-9]{40}"
  459. },
  460. {
  461. "name": "DATABASE_SERVICE_NAME",
  462. "displayName": "Database Service Name",
  463. "required": true,
  464. "value": "postgresql"
  465. },
  466. {
  467. "name": "DATABASE_ENGINE",
  468. "displayName": "Database Engine",
  469. "required": true,
  470. "description": "Database engine: postgresql, mysql or sqlite (default).",
  471. "value": "postgresql"
  472. },
  473. {
  474. "name": "DATABASE_NAME",
  475. "displayName": "Database Name",
  476. "required": true,
  477. "value": "default"
  478. },
  479. {
  480. "name": "DATABASE_USER",
  481. "displayName": "Database Username",
  482. "required": true,
  483. "value": "django"
  484. },
  485. {
  486. "name": "DATABASE_PASSWORD",
  487. "displayName": "Database User Password",
  488. "generate": "expression",
  489. "from": "[a-zA-Z0-9]{16}"
  490. },
  491. {
  492. "name": "APP_CONFIG",
  493. "displayName": "Application Configuration File Path",
  494. "description": "Relative path to Gunicorn configuration file (optional)."
  495. },
  496. {
  497. "name": "DJANGO_SECRET_KEY",
  498. "displayName": "Django Secret Key",
  499. "description": "Set this to a long random string.",
  500. "generate": "expression",
  501. "from": "[\\w]{50}"
  502. },
  503. {
  504. "name": "PIP_INDEX_URL",
  505. "displayName": "Custom PyPi Index URL",
  506. "description": "The custom PyPi index URL",
  507. "value": ""
  508. }
  509. ]
  510. }