django-postgresql.json 13 KB

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