django-postgresql.json 12 KB

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