django-postgresql.json 14 KB

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