deploy.yaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. kind: Deployment
  2. apiVersion: apps/v1
  3. metadata:
  4. labels:
  5. k8s-app: jenkins
  6. name: jenkins
  7. spec:
  8. replicas: 1
  9. revisionHistoryLimit: 10
  10. selector:
  11. matchLabels:
  12. k8s-app: jenkins
  13. template:
  14. metadata:
  15. labels:
  16. k8s-app: jenkins
  17. name: jenkins
  18. spec:
  19. containers:
  20. - name: jenkins
  21. image: jenkins/jenkins:2.381
  22. imagePullPolicy: IfNotPresent
  23. ports:
  24. - containerPort: 30080
  25. name: web
  26. protocol: TCP
  27. - containerPort: 30081
  28. name: agent
  29. protocol: TCP
  30. resources:
  31. limits:
  32. cpu: 1000m
  33. memory: 2Gi
  34. requests:
  35. cpu: 500m
  36. memory: 512Mi
  37. livenessProbe:
  38. httpGet:
  39. path: /login
  40. port: 30080
  41. initialDelaySeconds: 60
  42. timeoutSeconds: 5
  43. failureThreshold: 12
  44. readinessProbe:
  45. httpGet:
  46. path: /login
  47. port: 30080
  48. initialDelaySeconds: 60
  49. timeoutSeconds: 5
  50. failureThreshold: 12
  51. volumeMounts:
  52. - name: jenkins-home
  53. mountPath: /var/lib/jenkins
  54. env:
  55. - name: JENKINS_HOME
  56. value: /var/lib/jenkins
  57. - name: JENKINS_OPTS
  58. value: --httpPort=30080
  59. - name: JENKINS_SLAVE_AGENT_PORT
  60. value: '30081'
  61. volumes:
  62. - name: jenkins-home
  63. persistentVolumeClaim:
  64. claimName: jenkins-data2
  65. serviceAccountName: jenkins
  66. ---
  67. kind: Service
  68. apiVersion: v1
  69. metadata:
  70. labels:
  71. k8s-app: jenkins
  72. name: jenkins
  73. spec:
  74. type: NodePort
  75. ports:
  76. - name: web
  77. port: 30080
  78. targetPort: 30080
  79. nodePort: 30080
  80. - name: slave
  81. port: 30081
  82. targetPort: 30081
  83. nodePort: 30081
  84. selector:
  85. k8s-app: jenkins
  86. ---
  87. apiVersion: v1
  88. kind: ServiceAccount
  89. metadata:
  90. labels:
  91. k8s-app: jenkins
  92. name: jenkins
  93. ---
  94. kind: ClusterRole
  95. apiVersion: rbac.authorization.k8s.io/v1
  96. metadata:
  97. name: jenkins
  98. rules:
  99. - apiGroups: ['']
  100. resources: ['pods', 'configmaps', 'namespaces', 'deployments']
  101. verbs: ['create', 'delete', 'get', 'list', 'patch', 'update', 'watch']
  102. - apiGroups: ['']
  103. resources: ['pods/exec']
  104. verbs: ['create', 'delete', 'get', 'list', 'patch', 'update', 'watch']
  105. - apiGroups: ['']
  106. resources: ['pods/log']
  107. verbs: ['get', 'list', 'watch']
  108. - apiGroups: ['']
  109. resources: ['secrets']
  110. verbs: ['get']
  111. - apiGroups: ['apps']
  112. resources: ['deployments']
  113. verbs: ['create', 'delete', 'get', 'list', 'patch', 'update', 'watch']
  114. ---
  115. apiVersion: rbac.authorization.k8s.io/v1
  116. kind: ClusterRoleBinding
  117. metadata:
  118. name: jenkins
  119. roleRef:
  120. apiGroup: rbac.authorization.k8s.io
  121. kind: ClusterRole
  122. name: jenkins
  123. subjects:
  124. - kind: ServiceAccount
  125. name: jenkins
  126. namespace: devops
  127. ---
  128. # apiVersion: networking.k8s.io/v1
  129. # kind: Ingress
  130. # metadata:
  131. # name: jenkins-ingress
  132. # spec:
  133. # ingressClassName: nginx
  134. # rules:
  135. # - host: jenkins.sxkj.com
  136. # http:
  137. # paths:
  138. # - path: /
  139. # pathType: Prefix
  140. # backend:
  141. # service:
  142. # name: jenkins
  143. # port:
  144. # number: 30080