django-postgresql.json 14 KB

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