jenkins-persistent-template.json 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "jenkins-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "Jenkins",
  8. "description": "Jenkins service, with persistent storage.\n\nNOTE: You must have persistent volumes available in your cluster to use this template.",
  9. "iconClass": "icon-jenkins",
  10. "tags": "instant-app,jenkins",
  11. "openshift.io/long-description": "This template deploys a Jenkins server capable of managing OpenShift Pipeline builds and supporting OpenShift-based oauth login.",
  12. "openshift.io/provider-display-name": "Red Hat, Inc.",
  13. "openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/other_images/jenkins.html",
  14. "openshift.io/support-url": "https://access.redhat.com"
  15. }
  16. },
  17. "message": "A Jenkins service has been created in your project. Log into Jenkins with your OpenShift account. The tutorial at https://github.com/openshift/origin/blob/master/examples/jenkins/README.md contains more information about using this template.",
  18. "labels": {
  19. "app": "jenkins-persistent"
  20. },
  21. "objects": [
  22. {
  23. "kind": "Route",
  24. "apiVersion": "v1",
  25. "metadata": {
  26. "name": "${JENKINS_SERVICE_NAME}",
  27. "annotations": {
  28. "template.openshift.io/expose-uri": "http://{.spec.host}{.spec.path}"
  29. }
  30. },
  31. "spec": {
  32. "to": {
  33. "kind": "Service",
  34. "name": "${JENKINS_SERVICE_NAME}"
  35. },
  36. "tls": {
  37. "termination": "edge",
  38. "insecureEdgeTerminationPolicy": "Redirect"
  39. }
  40. }
  41. },
  42. {
  43. "kind": "PersistentVolumeClaim",
  44. "apiVersion": "v1",
  45. "metadata": {
  46. "name": "${JENKINS_SERVICE_NAME}"
  47. },
  48. "spec": {
  49. "accessModes": [
  50. "ReadWriteOnce"
  51. ],
  52. "resources": {
  53. "requests": {
  54. "storage": "${VOLUME_CAPACITY}"
  55. }
  56. }
  57. }
  58. },
  59. {
  60. "kind": "DeploymentConfig",
  61. "apiVersion": "v1",
  62. "metadata": {
  63. "name": "${JENKINS_SERVICE_NAME}",
  64. "annotations": {
  65. "template.alpha.openshift.io/wait-for-ready": "true"
  66. }
  67. },
  68. "spec": {
  69. "strategy": {
  70. "type": "Recreate"
  71. },
  72. "triggers": [
  73. {
  74. "type": "ImageChange",
  75. "imageChangeParams": {
  76. "automatic": true,
  77. "containerNames": [
  78. "jenkins"
  79. ],
  80. "from": {
  81. "kind": "ImageStreamTag",
  82. "name": "${JENKINS_IMAGE_STREAM_TAG}",
  83. "namespace": "${NAMESPACE}"
  84. },
  85. "lastTriggeredImage": ""
  86. }
  87. },
  88. {
  89. "type": "ConfigChange"
  90. }
  91. ],
  92. "replicas": 1,
  93. "selector": {
  94. "name": "${JENKINS_SERVICE_NAME}"
  95. },
  96. "template": {
  97. "metadata": {
  98. "labels": {
  99. "name": "${JENKINS_SERVICE_NAME}"
  100. }
  101. },
  102. "spec": {
  103. "serviceAccountName": "${JENKINS_SERVICE_NAME}",
  104. "containers": [
  105. {
  106. "name": "jenkins",
  107. "image": " ",
  108. "readinessProbe": {
  109. "timeoutSeconds": 3,
  110. "initialDelaySeconds": 3,
  111. "httpGet": {
  112. "path": "/login",
  113. "port": 8080
  114. }
  115. },
  116. "livenessProbe": {
  117. "timeoutSeconds": 3,
  118. "initialDelaySeconds": 420,
  119. "failureThreshold" : 30,
  120. "httpGet": {
  121. "path": "/login",
  122. "port": 8080
  123. }
  124. },
  125. "env": [
  126. {
  127. "name": "OPENSHIFT_ENABLE_OAUTH",
  128. "value": "${ENABLE_OAUTH}"
  129. },
  130. {
  131. "name": "OPENSHIFT_ENABLE_REDIRECT_PROMPT",
  132. "value": "true"
  133. },
  134. {
  135. "name": "KUBERNETES_MASTER",
  136. "value": "https://kubernetes.default:443"
  137. },
  138. {
  139. "name": "KUBERNETES_TRUST_CERTIFICATES",
  140. "value": "true"
  141. },
  142. {
  143. "name": "JENKINS_SERVICE_NAME",
  144. "value": "${JENKINS_SERVICE_NAME}"
  145. },
  146. {
  147. "name": "JNLP_SERVICE_NAME",
  148. "value": "${JNLP_SERVICE_NAME}"
  149. }
  150. ],
  151. "resources": {
  152. "limits": {
  153. "memory": "${MEMORY_LIMIT}"
  154. }
  155. },
  156. "volumeMounts": [
  157. {
  158. "name": "${JENKINS_SERVICE_NAME}-data",
  159. "mountPath": "/var/lib/jenkins"
  160. }
  161. ],
  162. "terminationMessagePath": "/dev/termination-log",
  163. "imagePullPolicy": "IfNotPresent",
  164. "capabilities": {},
  165. "securityContext": {
  166. "capabilities": {},
  167. "privileged": false
  168. }
  169. }
  170. ],
  171. "volumes": [
  172. {
  173. "name": "${JENKINS_SERVICE_NAME}-data",
  174. "persistentVolumeClaim": {
  175. "claimName": "${JENKINS_SERVICE_NAME}"
  176. }
  177. }
  178. ],
  179. "restartPolicy": "Always",
  180. "dnsPolicy": "ClusterFirst"
  181. }
  182. }
  183. }
  184. },
  185. {
  186. "kind": "ServiceAccount",
  187. "apiVersion": "v1",
  188. "metadata": {
  189. "name": "${JENKINS_SERVICE_NAME}",
  190. "annotations": {
  191. "serviceaccounts.openshift.io/oauth-redirectreference.jenkins": "{\"kind\":\"OAuthRedirectReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"Route\",\"name\":\"${JENKINS_SERVICE_NAME}\"}}"
  192. }
  193. }
  194. },
  195. {
  196. "kind": "RoleBinding",
  197. "apiVersion": "v1",
  198. "metadata": {
  199. "name": "${JENKINS_SERVICE_NAME}_edit"
  200. },
  201. "groupNames": null,
  202. "subjects": [
  203. {
  204. "kind": "ServiceAccount",
  205. "name": "${JENKINS_SERVICE_NAME}"
  206. }
  207. ],
  208. "roleRef": {
  209. "name": "edit"
  210. }
  211. },
  212. {
  213. "kind": "Service",
  214. "apiVersion": "v1",
  215. "metadata": {
  216. "name": "${JNLP_SERVICE_NAME}"
  217. },
  218. "spec": {
  219. "ports": [
  220. {
  221. "name": "agent",
  222. "protocol": "TCP",
  223. "port": 50000,
  224. "targetPort": 50000,
  225. "nodePort": 0
  226. }
  227. ],
  228. "selector": {
  229. "name": "${JENKINS_SERVICE_NAME}"
  230. },
  231. "type": "ClusterIP",
  232. "sessionAffinity": "None"
  233. }
  234. },
  235. {
  236. "kind": "Service",
  237. "apiVersion": "v1",
  238. "metadata": {
  239. "name": "${JENKINS_SERVICE_NAME}",
  240. "annotations": {
  241. "service.alpha.openshift.io/dependencies": "[{\"name\": \"${JNLP_SERVICE_NAME}\", \"namespace\": \"\", \"kind\": \"Service\"}]",
  242. "service.openshift.io/infrastructure": "true"
  243. }
  244. },
  245. "spec": {
  246. "ports": [
  247. {
  248. "name": "web",
  249. "protocol": "TCP",
  250. "port": 80,
  251. "targetPort": 8080,
  252. "nodePort": 0
  253. }
  254. ],
  255. "selector": {
  256. "name": "${JENKINS_SERVICE_NAME}"
  257. },
  258. "type": "ClusterIP",
  259. "sessionAffinity": "None"
  260. }
  261. }
  262. ],
  263. "parameters": [
  264. {
  265. "name": "JENKINS_SERVICE_NAME",
  266. "displayName": "Jenkins Service Name",
  267. "description": "The name of the OpenShift Service exposed for the Jenkins container.",
  268. "value": "jenkins"
  269. },
  270. {
  271. "name": "JNLP_SERVICE_NAME",
  272. "displayName": "Jenkins JNLP Service Name",
  273. "description": "The name of the service used for master/slave communication.",
  274. "value": "jenkins-jnlp"
  275. },
  276. {
  277. "name": "ENABLE_OAUTH",
  278. "displayName": "Enable OAuth in Jenkins",
  279. "description": "Whether to enable OAuth OpenShift integration. If false, the static account 'admin' will be initialized with the password 'password'.",
  280. "value": "true"
  281. },
  282. {
  283. "name": "MEMORY_LIMIT",
  284. "displayName": "Memory Limit",
  285. "description": "Maximum amount of memory the container can use.",
  286. "value": "512Mi"
  287. },
  288. {
  289. "name": "VOLUME_CAPACITY",
  290. "displayName": "Volume Capacity",
  291. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  292. "value": "1Gi",
  293. "required": true
  294. },
  295. {
  296. "name": "NAMESPACE",
  297. "displayName": "Jenkins ImageStream Namespace",
  298. "description": "The OpenShift Namespace where the Jenkins ImageStream resides.",
  299. "value": "openshift"
  300. },
  301. {
  302. "name": "JENKINS_IMAGE_STREAM_TAG",
  303. "displayName": "Jenkins ImageStreamTag",
  304. "description": "Name of the ImageStreamTag to be used for the Jenkins image.",
  305. "value": "jenkins:latest"
  306. }
  307. ],
  308. "labels": {
  309. "template": "jenkins-persistent-template"
  310. }
  311. }