django-postgresql-persistent.json 15 KB

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