django-postgresql-persistent.json 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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. }
  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-persistent"
  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-persistent"
  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-persistent",
  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": "PersistentVolumeClaim",
  262. "apiVersion": "v1",
  263. "metadata": {
  264. "name": "${DATABASE_SERVICE_NAME}"
  265. },
  266. "spec": {
  267. "accessModes": [
  268. "ReadWriteOnce"
  269. ],
  270. "resources": {
  271. "requests": {
  272. "storage": "${VOLUME_CAPACITY}"
  273. }
  274. }
  275. }
  276. },
  277. {
  278. "kind": "Service",
  279. "apiVersion": "v1",
  280. "metadata": {
  281. "name": "${DATABASE_SERVICE_NAME}",
  282. "annotations": {
  283. "description": "Exposes the database server"
  284. }
  285. },
  286. "spec": {
  287. "ports": [
  288. {
  289. "name": "postgresql",
  290. "port": 5432,
  291. "targetPort": 5432
  292. }
  293. ],
  294. "selector": {
  295. "name": "${DATABASE_SERVICE_NAME}"
  296. }
  297. }
  298. },
  299. {
  300. "kind": "DeploymentConfig",
  301. "apiVersion": "v1",
  302. "metadata": {
  303. "name": "${DATABASE_SERVICE_NAME}",
  304. "annotations": {
  305. "description": "Defines how to deploy the database"
  306. }
  307. },
  308. "spec": {
  309. "strategy": {
  310. "type": "Recreate"
  311. },
  312. "triggers": [
  313. {
  314. "type": "ImageChange",
  315. "imageChangeParams": {
  316. "automatic": true,
  317. "containerNames": [
  318. "postgresql"
  319. ],
  320. "from": {
  321. "kind": "ImageStreamTag",
  322. "namespace": "${NAMESPACE}",
  323. "name": "postgresql:9.5"
  324. }
  325. }
  326. },
  327. {
  328. "type": "ConfigChange"
  329. }
  330. ],
  331. "replicas": 1,
  332. "selector": {
  333. "name": "${DATABASE_SERVICE_NAME}"
  334. },
  335. "template": {
  336. "metadata": {
  337. "name": "${DATABASE_SERVICE_NAME}",
  338. "labels": {
  339. "name": "${DATABASE_SERVICE_NAME}"
  340. }
  341. },
  342. "spec": {
  343. "volumes": [
  344. {
  345. "name": "${DATABASE_SERVICE_NAME}-data",
  346. "persistentVolumeClaim": {
  347. "claimName": "${DATABASE_SERVICE_NAME}"
  348. }
  349. }
  350. ],
  351. "containers": [
  352. {
  353. "name": "postgresql",
  354. "image": " ",
  355. "ports": [
  356. {
  357. "containerPort": 5432
  358. }
  359. ],
  360. "env": [
  361. {
  362. "name": "POSTGRESQL_USER",
  363. "valueFrom": {
  364. "secretKeyRef" : {
  365. "name" : "${NAME}",
  366. "key" : "database-user"
  367. }
  368. }
  369. },
  370. {
  371. "name": "POSTGRESQL_PASSWORD",
  372. "valueFrom": {
  373. "secretKeyRef" : {
  374. "name" : "${NAME}",
  375. "key" : "database-password"
  376. }
  377. }
  378. },
  379. {
  380. "name": "POSTGRESQL_DATABASE",
  381. "value": "${DATABASE_NAME}"
  382. }
  383. ],
  384. "volumeMounts": [
  385. {
  386. "name": "${DATABASE_SERVICE_NAME}-data",
  387. "mountPath": "/var/lib/pgsql/data"
  388. }
  389. ],
  390. "readinessProbe": {
  391. "timeoutSeconds": 1,
  392. "initialDelaySeconds": 5,
  393. "exec": {
  394. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'"]
  395. }
  396. },
  397. "livenessProbe": {
  398. "timeoutSeconds": 1,
  399. "initialDelaySeconds": 30,
  400. "tcpSocket": {
  401. "port": 5432
  402. }
  403. },
  404. "resources": {
  405. "limits": {
  406. "memory": "${MEMORY_POSTGRESQL_LIMIT}"
  407. }
  408. }
  409. }
  410. ]
  411. }
  412. }
  413. }
  414. }
  415. ],
  416. "parameters": [
  417. {
  418. "name": "NAME",
  419. "displayName": "Name",
  420. "description": "The name assigned to all of the frontend objects defined in this template.",
  421. "required": true,
  422. "value": "django-psql-persistent"
  423. },
  424. {
  425. "name": "NAMESPACE",
  426. "displayName": "Namespace",
  427. "required": true,
  428. "description": "The OpenShift Namespace where the ImageStream resides.",
  429. "value": "openshift"
  430. },
  431. {
  432. "name": "MEMORY_LIMIT",
  433. "displayName": "Memory Limit",
  434. "required": true,
  435. "description": "Maximum amount of memory the Django container can use.",
  436. "value": "512Mi"
  437. },
  438. {
  439. "name": "MEMORY_POSTGRESQL_LIMIT",
  440. "displayName": "Memory Limit (PostgreSQL)",
  441. "required": true,
  442. "description": "Maximum amount of memory the PostgreSQL container can use.",
  443. "value": "512Mi"
  444. },
  445. {
  446. "name": "VOLUME_CAPACITY",
  447. "displayName": "Volume Capacity",
  448. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  449. "value": "1Gi",
  450. "required": true
  451. },
  452. {
  453. "name": "SOURCE_REPOSITORY_URL",
  454. "displayName": "Git Repository URL",
  455. "required": true,
  456. "description": "The URL of the repository with your application source code.",
  457. "value": "https://github.com/openshift/django-ex.git"
  458. },
  459. {
  460. "name": "SOURCE_REPOSITORY_REF",
  461. "displayName": "Git Reference",
  462. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  463. },
  464. {
  465. "name": "CONTEXT_DIR",
  466. "displayName": "Context Directory",
  467. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  468. },
  469. {
  470. "name": "APPLICATION_DOMAIN",
  471. "displayName": "Application Hostname",
  472. "description": "The exposed hostname that will route to the Django service, if left blank a value will be defaulted.",
  473. "value": ""
  474. },
  475. {
  476. "name": "GITHUB_WEBHOOK_SECRET",
  477. "displayName": "GitHub Webhook Secret",
  478. "description": "A secret string used to configure the GitHub webhook.",
  479. "generate": "expression",
  480. "from": "[a-zA-Z0-9]{40}"
  481. },
  482. {
  483. "name": "DATABASE_SERVICE_NAME",
  484. "displayName": "Database Service Name",
  485. "required": true,
  486. "value": "postgresql"
  487. },
  488. {
  489. "name": "DATABASE_ENGINE",
  490. "displayName": "Database Engine",
  491. "required": true,
  492. "description": "Database engine: postgresql, mysql or sqlite (default).",
  493. "value": "postgresql"
  494. },
  495. {
  496. "name": "DATABASE_NAME",
  497. "displayName": "Database Name",
  498. "required": true,
  499. "value": "default"
  500. },
  501. {
  502. "name": "DATABASE_USER",
  503. "displayName": "Database Username",
  504. "required": true,
  505. "value": "django"
  506. },
  507. {
  508. "name": "DATABASE_PASSWORD",
  509. "displayName": "Database User Password",
  510. "generate": "expression",
  511. "from": "[a-zA-Z0-9]{16}"
  512. },
  513. {
  514. "name": "APP_CONFIG",
  515. "displayName": "Application Configuration File Path",
  516. "description": "Relative path to Gunicorn configuration file (optional)."
  517. },
  518. {
  519. "name": "DJANGO_SECRET_KEY",
  520. "displayName": "Django Secret Key",
  521. "description": "Set this to a long random string.",
  522. "generate": "expression",
  523. "from": "[\\w]{50}"
  524. },
  525. {
  526. "name": "PIP_INDEX_URL",
  527. "displayName": "Custom PyPi Index URL",
  528. "description": "The custom PyPi index URL",
  529. "value": ""
  530. }
  531. ]
  532. }