You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
8.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. ---
  2. kind: pipeline
  3. type: docker
  4. name: default
  5. volumes:
  6. - name: gopath
  7. host:
  8. path: /usr/local/path/gopath
  9. steps:
  10. - name: golang-build
  11. image: golang
  12. volumes:
  13. - name: gopath
  14. path: /go
  15. commands:
  16. - export GOPROXY=https://goproxy.cn
  17. - go mod init test-drone
  18. - go mod tidy
  19. - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test-drone
  20. when:
  21. target: [ "" ]
  22. - name: docker-push
  23. image: plugins/docker
  24. settings:
  25. username: tjqmhu
  26. password: tjqm4912
  27. repo: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone
  28. dockerfile: Dockerfile
  29. registry: https://registry.cn-hangzhou.aliyuncs.com
  30. tags: ${DRONE_BUILD_NUMBER}
  31. when:
  32. target: [ "" ]
  33. - name: rancher-deploy
  34. image: busybox # 直接用busybox
  35. commands:
  36. - curl --location --request PUT 'https://121.40.194.123:8443/v3/project/c-wh6tz:p-vwfqk/workloads/deployment:default:test-drone' \
  37. --header 'Authorization: Bearer token-j24z5:fwbzktwzs4kqf8p4pzsfn92thzms76vrglghh2khmdxkr6svm57796' \
  38. --header 'Content-Type: application/javascript' \
  39. --data-raw '{
  40. "hostIPC": false,
  41. "hostNetwork": false,
  42. "hostPID": false,
  43. "paused": false,
  44. "annotations": {
  45. "cattle.io/timestamp": "2021-11-27T09:15:56Z"
  46. },
  47. "baseType": "workload",
  48. "containers": [
  49. {
  50. "initContainer": false,
  51. "restartCount": 0,
  52. "stdin": true,
  53. "stdinOnce": false,
  54. "tty": true,
  55. "allowPrivilegeEscalation": false,
  56. "image": "registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER}",
  57. "imagePullPolicy": "Always",
  58. "name": "test-drone",
  59. "ports": [
  60. {
  61. "containerPort": 8080,
  62. "dnsName": "test-drone-nodeport",
  63. "hostPort": 0,
  64. "kind": "NodePort",
  65. "name": "8080tcp300001",
  66. "protocol": "TCP",
  67. "sourcePort": 30000,
  68. "type": "/v3/project/schemas/containerPort"
  69. }
  70. ],
  71. "privileged": false,
  72. "readOnly": false,
  73. "resources": {
  74. "type": "/v3/project/schemas/resourceRequirements",
  75. "requests": { },
  76. "limits": { }
  77. },
  78. "runAsNonRoot": false,
  79. "terminationMessagePath": "/dev/termination-log",
  80. "terminationMessagePolicy": "File",
  81. "type": "container",
  82. "environmentFrom": [ ],
  83. "capAdd": [ ],
  84. "capDrop": [ ],
  85. "livenessProbe": null,
  86. "volumeMounts": [ ]
  87. }
  88. ],
  89. "created": "2021-11-27T09:08:05Z",
  90. "createdTS": 1638004085000,
  91. "creatorId": null,
  92. "deploymentConfig": {
  93. "maxSurge": 1,
  94. "maxUnavailable": 0,
  95. "minReadySeconds": 0,
  96. "progressDeadlineSeconds": 600,
  97. "revisionHistoryLimit": 10,
  98. "strategy": "RollingUpdate"
  99. },
  100. "deploymentStatus": {
  101. "availableReplicas": 1,
  102. "conditions": [
  103. {
  104. "lastTransitionTime": "2021-11-27T09:08:12Z",
  105. "lastTransitionTimeTS": 1638004092000,
  106. "lastUpdateTime": "2021-11-27T09:08:12Z",
  107. "lastUpdateTimeTS": 1638004092000,
  108. "message": "Deployment has minimum availability.",
  109. "reason": "MinimumReplicasAvailable",
  110. "status": "True",
  111. "type": "Available"
  112. },
  113. {
  114. "lastTransitionTime": "2021-11-27T09:08:05Z",
  115. "lastTransitionTimeTS": 1638004085000,
  116. "lastUpdateTime": "2021-11-27T09:08:12Z",
  117. "lastUpdateTimeTS": 1638004092000,
  118. "message": "ReplicaSet \"test-drone-6d46b7f96d\" has successfully progressed.",
  119. "reason": "NewReplicaSetAvailable",
  120. "status": "True",
  121. "type": "Progressing"
  122. }
  123. ],
  124. "observedGeneration": 2,
  125. "readyReplicas": 1,
  126. "replicas": 1,
  127. "type": "/v3/project/schemas/deploymentStatus",
  128. "unavailableReplicas": 0,
  129. "updatedReplicas": 1
  130. },
  131. "dnsPolicy": "ClusterFirst",
  132. "id": "deployment:default:test-drone",
  133. "imagePullSecrets": [
  134. {
  135. "name": "aliyun-docker",
  136. "type": "/v3/project/schemas/localObjectReference"
  137. }
  138. ],
  139. "labels": {
  140. "workload.user.cattle.io/workloadselector": "deployment-default-test-drone"
  141. },
  142. "name": "test-drone",
  143. "namespaceId": "default",
  144. "projectId": "c-wh6tz:p-vwfqk",
  145. "restartPolicy": "Always",
  146. "scale": 1,
  147. "scheduling": {
  148. "scheduler": "default-scheduler",
  149. "node": { }
  150. },
  151. "selector": {
  152. "matchLabels": {
  153. "workload.user.cattle.io/workloadselector": "deployment-default-test-drone"
  154. },
  155. "type": "/v3/project/schemas/labelSelector"
  156. },
  157. "state": "active",
  158. "terminationGracePeriodSeconds": 30,
  159. "transitioning": "no",
  160. "transitioningMessage": "",
  161. "type": "deployment",
  162. "uuid": "94091e03-986e-4809-9b46-12b6716b4a7f",
  163. "workloadAnnotations": {
  164. "deployment.kubernetes.io/revision": "1",
  165. "field.cattle.io/creatorId": "user-7wt8c"
  166. },
  167. "workloadLabels": {
  168. "cattle.io/creator": "norman",
  169. "workload.user.cattle.io/workloadselector": "deployment-default-test-drone"
  170. },
  171. "publicEndpoints": [
  172. {
  173. "addresses": [
  174. "172.26.40.69"
  175. ],
  176. "allNodes": true,
  177. "ingressId": null,
  178. "nodeId": null,
  179. "podId": null,
  180. "port": 30000,
  181. "protocol": "TCP",
  182. "serviceId": "default:test-drone-nodeport",
  183. "type": "publicEndpoint"
  184. }
  185. ],
  186. "volumes": [ ]
  187. }'
  188. # # drone-rancher插件,利用此插件来启动rancher
  189. # image: pelotech/drone-rancher
  190. # settings:
  191. # # rancher-server地址
  192. # url: 'https://121.40.194.123:8443'
  193. # access_key: token-qqrhk
  194. # secret_key: fwbzktwzs4kqf8p4pzsfn92thzms76vrglghh2khmdxkr6svm57796
  195. # service: pre/default
  196. # # 为了使rancher能拉取到私有镜像, 需要在rancher控制面板"基础架构->镜像库"添加这个私有镜像库
  197. # docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:20
  198. # - name: run
  199. # image: pelotech/drone-rancher
  200. # url: https://121.40.194.123:8443
  201. # access_key: token-j24z5
  202. # secret_key: fwbzktwzs4kqf8p4pzsfn92thzms76vrglghh2khmdxkr6svm57796
  203. # service: default/test-drone
  204. # docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:20
  205. # - name: rancher-deploy
  206. # image: peloton/drone-rancher
  207. # url: https://121.40.194.123:8443/
  208. # access_key: token-qqrhk
  209. # secret_key: wt46cz8x8xqz5t7x27htzdc46tscvpnzwzlj9gp99j2cbdrqhtcj25
  210. # service: default/drone-test
  211. # # 为了使rancher能拉取到私有镜像, 需要在rancher控制面板"基础架构->镜像库"添加这个私有镜像库
  212. # docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER} # 镜像地址及版本号
  213. # start_first: true # 先启动新服务, 后停止原服务. 如果为false则先关闭原服务再启动
  214. # confirm: true
  215. # timeout: 100 # 如果rancher没在这个时间内升级成功则报错, 服务大小等差异会导致升级时间不一样, 可根据自己业务修改超时时间.
  216. # image: pelotech/drone-rancher # drone-rancher插件,利用此插件来启动rancher
  217. # settings:
  218. # url: 'http://121.40.194.123:8082/v3'
  219. # access_key: token-qqrhk
  220. # secret_key: wt46cz8x8xqz5t7x27htzdc46tscvpnzwzlj9gp99j2cbdrqhtcj25
  221. # service: registry.cn-hangzhou.aliyuncs.com
  222. # docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER} # 镜像地址及版本号
  223. # start_first: false
  224. # confirm: true
  225. # timeout: 301
  226. # ## 使用参数推送稳定镜像
  227. # - name: deployment-replace-prod
  228. # image: repository.241210.com/repository/base/kubectl:4
  229. # commands:
  230. # - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml
  231. # when:
  232. # target: [ "pre","prod" ]
  233. #
  234. # - name: deploy-prod
  235. # image: repository.241210.com/repository/base/kubectl:4
  236. # commands:
  237. # - kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml
  238. # when:
  239. # target: [ "pre","prod" ]