django-postgresql.json 15 KB

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