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.
248 lines
8.6 KiB
248 lines
8.6 KiB
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: default
|
|
|
|
volumes:
|
|
- name: gopath
|
|
host:
|
|
path: /usr/local/path/gopath
|
|
|
|
steps:
|
|
- name: golang-build
|
|
image: golang
|
|
volumes:
|
|
- name: gopath
|
|
path: /go
|
|
commands:
|
|
- export GOPROXY=https://goproxy.cn
|
|
- go mod init test-drone
|
|
- go mod tidy
|
|
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test-drone
|
|
when:
|
|
target: [ "" ]
|
|
|
|
- name: docker-push
|
|
image: plugins/docker
|
|
settings:
|
|
username: tjqmhu
|
|
password: tjqm4912
|
|
repo: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone
|
|
dockerfile: Dockerfile
|
|
registry: https://registry.cn-hangzhou.aliyuncs.com
|
|
tags: ${DRONE_BUILD_NUMBER}
|
|
when:
|
|
target: [ "" ]
|
|
|
|
- name: rancher-deploy
|
|
image: busybox # 直接用busybox
|
|
commands:
|
|
- curl --location --request PUT 'https://121.40.194.123:8443/v3/project/c-wh6tz:p-vwfqk/workloads/deployment:default:test-drone' \
|
|
--header 'Authorization: Bearer token-j24z5:fwbzktwzs4kqf8p4pzsfn92thzms76vrglghh2khmdxkr6svm57796' \
|
|
--header 'Content-Type: application/javascript' \
|
|
--data-raw '{
|
|
"hostIPC": false,
|
|
"hostNetwork": false,
|
|
"hostPID": false,
|
|
"paused": false,
|
|
"annotations": {
|
|
"cattle.io/timestamp": "2021-11-27T09:15:56Z"
|
|
},
|
|
"baseType": "workload",
|
|
"containers": [
|
|
{
|
|
"initContainer": false,
|
|
"restartCount": 0,
|
|
"stdin": true,
|
|
"stdinOnce": false,
|
|
"tty": true,
|
|
"allowPrivilegeEscalation": false,
|
|
"image": "registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER}",
|
|
"imagePullPolicy": "Always",
|
|
"name": "test-drone",
|
|
"ports": [
|
|
{
|
|
"containerPort": 8080,
|
|
"dnsName": "test-drone-nodeport",
|
|
"hostPort": 0,
|
|
"kind": "NodePort",
|
|
"name": "8080tcp300001",
|
|
"protocol": "TCP",
|
|
"sourcePort": 30000,
|
|
"type": "/v3/project/schemas/containerPort"
|
|
}
|
|
],
|
|
"privileged": false,
|
|
"readOnly": false,
|
|
"resources": {
|
|
"type": "/v3/project/schemas/resourceRequirements",
|
|
"requests": { },
|
|
"limits": { }
|
|
},
|
|
"runAsNonRoot": false,
|
|
"terminationMessagePath": "/dev/termination-log",
|
|
"terminationMessagePolicy": "File",
|
|
"type": "container",
|
|
"environmentFrom": [ ],
|
|
"capAdd": [ ],
|
|
"capDrop": [ ],
|
|
"livenessProbe": null,
|
|
"volumeMounts": [ ]
|
|
}
|
|
],
|
|
"created": "2021-11-27T09:08:05Z",
|
|
"createdTS": 1638004085000,
|
|
"creatorId": null,
|
|
"deploymentConfig": {
|
|
"maxSurge": 1,
|
|
"maxUnavailable": 0,
|
|
"minReadySeconds": 0,
|
|
"progressDeadlineSeconds": 600,
|
|
"revisionHistoryLimit": 10,
|
|
"strategy": "RollingUpdate"
|
|
},
|
|
"deploymentStatus": {
|
|
"availableReplicas": 1,
|
|
"conditions": [
|
|
{
|
|
"lastTransitionTime": "2021-11-27T09:08:12Z",
|
|
"lastTransitionTimeTS": 1638004092000,
|
|
"lastUpdateTime": "2021-11-27T09:08:12Z",
|
|
"lastUpdateTimeTS": 1638004092000,
|
|
"message": "Deployment has minimum availability.",
|
|
"reason": "MinimumReplicasAvailable",
|
|
"status": "True",
|
|
"type": "Available"
|
|
},
|
|
{
|
|
"lastTransitionTime": "2021-11-27T09:08:05Z",
|
|
"lastTransitionTimeTS": 1638004085000,
|
|
"lastUpdateTime": "2021-11-27T09:08:12Z",
|
|
"lastUpdateTimeTS": 1638004092000,
|
|
"message": "ReplicaSet \"test-drone-6d46b7f96d\" has successfully progressed.",
|
|
"reason": "NewReplicaSetAvailable",
|
|
"status": "True",
|
|
"type": "Progressing"
|
|
}
|
|
],
|
|
"observedGeneration": 2,
|
|
"readyReplicas": 1,
|
|
"replicas": 1,
|
|
"type": "/v3/project/schemas/deploymentStatus",
|
|
"unavailableReplicas": 0,
|
|
"updatedReplicas": 1
|
|
},
|
|
"dnsPolicy": "ClusterFirst",
|
|
"id": "deployment:default:test-drone",
|
|
"imagePullSecrets": [
|
|
{
|
|
"name": "aliyun-docker",
|
|
"type": "/v3/project/schemas/localObjectReference"
|
|
}
|
|
],
|
|
"labels": {
|
|
"workload.user.cattle.io/workloadselector": "deployment-default-test-drone"
|
|
},
|
|
"name": "test-drone",
|
|
"namespaceId": "default",
|
|
"projectId": "c-wh6tz:p-vwfqk",
|
|
"restartPolicy": "Always",
|
|
"scale": 1,
|
|
"scheduling": {
|
|
"scheduler": "default-scheduler",
|
|
"node": { }
|
|
},
|
|
"selector": {
|
|
"matchLabels": {
|
|
"workload.user.cattle.io/workloadselector": "deployment-default-test-drone"
|
|
},
|
|
"type": "/v3/project/schemas/labelSelector"
|
|
},
|
|
"state": "active",
|
|
"terminationGracePeriodSeconds": 30,
|
|
"transitioning": "no",
|
|
"transitioningMessage": "",
|
|
"type": "deployment",
|
|
"uuid": "94091e03-986e-4809-9b46-12b6716b4a7f",
|
|
"workloadAnnotations": {
|
|
"deployment.kubernetes.io/revision": "1",
|
|
"field.cattle.io/creatorId": "user-7wt8c"
|
|
},
|
|
"workloadLabels": {
|
|
"cattle.io/creator": "norman",
|
|
"workload.user.cattle.io/workloadselector": "deployment-default-test-drone"
|
|
},
|
|
"publicEndpoints": [
|
|
{
|
|
"addresses": [
|
|
"172.26.40.69"
|
|
],
|
|
"allNodes": true,
|
|
"ingressId": null,
|
|
"nodeId": null,
|
|
"podId": null,
|
|
"port": 30000,
|
|
"protocol": "TCP",
|
|
"serviceId": "default:test-drone-nodeport",
|
|
"type": "publicEndpoint"
|
|
}
|
|
],
|
|
"volumes": [ ]
|
|
}'
|
|
# # drone-rancher插件,利用此插件来启动rancher
|
|
# image: pelotech/drone-rancher
|
|
# settings:
|
|
# # rancher-server地址
|
|
# url: 'https://121.40.194.123:8443'
|
|
# access_key: token-qqrhk
|
|
# secret_key: fwbzktwzs4kqf8p4pzsfn92thzms76vrglghh2khmdxkr6svm57796
|
|
# service: pre/default
|
|
# # 为了使rancher能拉取到私有镜像, 需要在rancher控制面板"基础架构->镜像库"添加这个私有镜像库
|
|
# docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:20
|
|
|
|
# - name: run
|
|
# image: pelotech/drone-rancher
|
|
# url: https://121.40.194.123:8443
|
|
# access_key: token-j24z5
|
|
# secret_key: fwbzktwzs4kqf8p4pzsfn92thzms76vrglghh2khmdxkr6svm57796
|
|
# service: default/test-drone
|
|
# docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:20
|
|
|
|
# - name: rancher-deploy
|
|
# image: peloton/drone-rancher
|
|
# url: https://121.40.194.123:8443/
|
|
# access_key: token-qqrhk
|
|
# secret_key: wt46cz8x8xqz5t7x27htzdc46tscvpnzwzlj9gp99j2cbdrqhtcj25
|
|
# service: default/drone-test
|
|
# # 为了使rancher能拉取到私有镜像, 需要在rancher控制面板"基础架构->镜像库"添加这个私有镜像库
|
|
# docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER} # 镜像地址及版本号
|
|
# start_first: true # 先启动新服务, 后停止原服务. 如果为false则先关闭原服务再启动
|
|
# confirm: true
|
|
# timeout: 100 # 如果rancher没在这个时间内升级成功则报错, 服务大小等差异会导致升级时间不一样, 可根据自己业务修改超时时间.
|
|
|
|
|
|
# image: pelotech/drone-rancher # drone-rancher插件,利用此插件来启动rancher
|
|
# settings:
|
|
# url: 'http://121.40.194.123:8082/v3'
|
|
# access_key: token-qqrhk
|
|
# secret_key: wt46cz8x8xqz5t7x27htzdc46tscvpnzwzlj9gp99j2cbdrqhtcj25
|
|
# service: registry.cn-hangzhou.aliyuncs.com
|
|
# docker_image: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER} # 镜像地址及版本号
|
|
# start_first: false
|
|
# confirm: true
|
|
# timeout: 301
|
|
|
|
# ## 使用参数推送稳定镜像
|
|
# - name: deployment-replace-prod
|
|
# image: repository.241210.com/repository/base/kubectl:4
|
|
# commands:
|
|
# - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml
|
|
# when:
|
|
# target: [ "pre","prod" ]
|
|
#
|
|
# - name: deploy-prod
|
|
# image: repository.241210.com/repository/base/kubectl:4
|
|
# commands:
|
|
# - kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml
|
|
# when:
|
|
# target: [ "pre","prod" ]
|