django-postgresql.json 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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": "django-psql-example",
  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": false,
  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. "containers": [
  291. {
  292. "name": "postgresql",
  293. "image": "postgresql",
  294. "ports": [
  295. {
  296. "containerPort": 5432
  297. }
  298. ],
  299. "env": [
  300. {
  301. "name": "POSTGRESQL_USER",
  302. "value": "${DATABASE_USER}"
  303. },
  304. {
  305. "name": "POSTGRESQL_PASSWORD",
  306. "value": "${DATABASE_PASSWORD}"
  307. },
  308. {
  309. "name": "POSTGRESQL_DATABASE",
  310. "value": "${DATABASE_NAME}"
  311. }
  312. ],
  313. "readinessProbe": {
  314. "timeoutSeconds": 1,
  315. "initialDelaySeconds": 5,
  316. "exec": {
  317. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'"]
  318. }
  319. },
  320. "livenessProbe": {
  321. "timeoutSeconds": 1,
  322. "initialDelaySeconds": 30,
  323. "tcpSocket": {
  324. "port": 5432
  325. }
  326. },
  327. "resources": {
  328. "limits": {
  329. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  330. }
  331. }
  332. }
  333. ]
  334. }
  335. }
  336. }
  337. }
  338. ],
  339. "parameters": [
  340. {
  341. "name": "NAME",
  342. "displayName": "Name",
  343. "description": "The name assigned to all of the frontend objects defined in this template.",
  344. "required": true,
  345. "value": "django-psql-example"
  346. },
  347. {
  348. "name": "NAMESPACE",
  349. "displayName": "Namespace",
  350. "description": "The OpenShift Namespace where the ImageStream resides.",
  351. "value": "openshift"
  352. },
  353. {
  354. "name": "MEMORY_LIMIT",
  355. "displayName": "Memory Limit",
  356. "description": "Maximum amount of memory the Django container can use.",
  357. "value": "512Mi"
  358. },
  359. {
  360. "name": "MEMORY_POSTGRESQL_LIMIT",
  361. "displayName": "Memory Limit (PostgreSQL)",
  362. "description": "Maximum amount of memory the PostgreSQL container can use.",
  363. "value": "512Mi"
  364. },
  365. {
  366. "name": "SOURCE_REPOSITORY_URL",
  367. "displayName": "Git Repository URL",
  368. "description": "The URL of the repository with your application source code.",
  369. "value": "https://github.com/openshift/django-ex.git"
  370. },
  371. {
  372. "name": "SOURCE_REPOSITORY_REF",
  373. "displayName": "Git Reference",
  374. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  375. },
  376. {
  377. "name": "CONTEXT_DIR",
  378. "displayName": "Context Directory",
  379. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  380. },
  381. {
  382. "name": "APPLICATION_DOMAIN",
  383. "displayName": "Application Hostname",
  384. "description": "The exposed hostname that will route to the Django service, if left blank a value will be defaulted.",
  385. "value": ""
  386. },
  387. {
  388. "name": "GITHUB_WEBHOOK_SECRET",
  389. "displayName": "GitHub Webhook Secret",
  390. "description": "A secret string used to configure the GitHub webhook.",
  391. "generate": "expression",
  392. "from": "[a-zA-Z0-9]{40}"
  393. },
  394. {
  395. "name": "DATABASE_SERVICE_NAME",
  396. "displayName": "Database Service Name",
  397. "value": "postgresql"
  398. },
  399. {
  400. "name": "DATABASE_ENGINE",
  401. "displayName": "Database Engine",
  402. "description": "Database engine: postgresql, mysql or sqlite (default).",
  403. "value": "postgresql"
  404. },
  405. {
  406. "name": "DATABASE_NAME",
  407. "displayName": "Database Name",
  408. "value": "default"
  409. },
  410. {
  411. "name": "DATABASE_USER",
  412. "displayName": "Database Username",
  413. "value": "django"
  414. },
  415. {
  416. "name": "DATABASE_PASSWORD",
  417. "displayName": "Database User Password",
  418. "generate": "expression",
  419. "from": "[a-zA-Z0-9]{16}"
  420. },
  421. {
  422. "name": "APP_CONFIG",
  423. "displayName": "Application Configuration File Path",
  424. "description": "Relative path to Gunicorn configuration file (optional)."
  425. },
  426. {
  427. "name": "DJANGO_SECRET_KEY",
  428. "displayName": "Djange Secret Key",
  429. "description": "Set this to a long random string.",
  430. "generate": "expression",
  431. "from": "[\\w]{50}"
  432. }
  433. ]
  434. }