django-postgresql-persistent.json 15 KB

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