/drone-plugin-rancher2

drone plugin for update rancher workload's docker image

Primary LanguageGo

Docker Pulls

drone-plugin-rancher2

NOTE: only can update image name

Usage

  • rancher 2.6.3 以上

    steps:
      - name: update-rancher
        image: ystyle/drone-plugin-rancher2:2.6
        when:
          branch: master
          event: [push]
        environment:
          SERVER: https://rancher.youdomain.com/k8s/clusters/c-m-w7b37mq1
          TOKEN: kubeconfig-user-d71qwk98dq:d45jfxrdx672r26xmf8ltsj46dcbw2p7lf76dck3vt5nr24gzlpbk9
        commands:
          - /setup.sh
          - kubectl set image deployment/${DRONE_REPO_NAME} ${DRONE_REPO_NAME}=registry.cn-hangzhou.aliyuncs.com/dexdev/${DRONE_REPO_NAME}:${DRONE_COMMIT_BRANCH}-${DRONE_BUILD_NUMBER}
    

    server和token取自集群-右上搜索图标旁边kubectl config的server和token

    imagew

  • drone 1.x

steps:
  - name: update-rancher
    image: ystyle/drone-plugin-rancher2
    settings:
      api: https://rancher.youdomain.com/v3/project/c-27tt1:p-wqtk3/workloads/default:default:nginx
      access_key: token-dfi8s
      secret_key: mhgb9w2csrvs6h9nm4fldl4z8f7h4sznx4m6ggvv4p54sffhjlkwvx
      data: [{
        "name": "nginx",
        "image": "nginx:alpine",
        "environment": {
          "tag": "${DRONE_COMMIT_SHA:0:8}"
          }
      }]
  • drone 0.8
pipeline:
  update-rancher:
    image: ystyle/drone-plugin-rancher2
    api: https://rancher.youdomain.com/v3/project/c-27tt1:p-wqtk3/workloads/default:default:nginx
    access_key: token-dfi8s
    secret_key: mhgb9w2csrvs6h9nm4fldl4z8f7h4sznx4m6ggvv4p54sffhjlkwvx
    data: [{
      "name": "nginx",
      "image": "nginx:alpine",
      "environment": {
        "tag": "${DRONE_COMMIT_SHA:0:8}"
        }
      }]

Parameter Reference

  • api workload api url
  • access_key rancher user api keys
  • secret_key rancher user api keys
  • data api result's containers field, only support name image and environment field