Giter Club home page Giter Club logo

drone-rancher's Introduction

drone-rancher

Build Status Go Doc Go Report

Drone plugin to deploy or update a project on Rancher 1.x only. For the usage information and a listing of the available options please take a look at the docs.

Binary

Build the binary using drone cli:

drone exec

Example

Usage

Build and deploy from your current working directory:

docker run --rm                          \
  -e PLUGIN_URL=<source>                 \
  -e PLUGIN_ACCESS_KEY=<key>     \
  -e PLUGIN_SECRET_KEY=<secret>  \
  -e PLUGIN_SERVICE=<service>            \  
  -e PLUGIN_DOCKER_IMAGE=<image>         \
  -v $(pwd):$(pwd)                       \
  -w $(pwd)                              \
  pelotech/drone-rancher 

Contribution

This repo is setup in a way that if you enable a personal drone server to build your fork it will build and publish your image (makes it easier to test PRs and use the image till the contributions get merged)

  • Build local DRONE_REPO_OWNER=josmo DRONE_REPO_NAME=drone-rancher drone exec
  • on your server just make sure you have DOCKER_USERNAME, DOCKER_PASSWORD, and PLUGIN_REPO set as secrets

drone-rancher's People

Contributors

0rax avatar andrewsuzuki avatar ashtonian avatar bradrydzewski avatar itestinprod avatar jackspirou avatar johnrengelman avatar josmo avatar nlf avatar rakhmanov avatar tboerger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

drone-rancher's Issues

The plugin isn't able to find my stacks anymore

Hello, I've like 10 environments and each of them contains ~10 stacks (with 2 to 3 containers per stack) and everything was working well until I added a new Env.

In this rancher env I've added 8 stacks, when I deploy with drone, 7 of those stacks works well, but anything after this 7th return in drone:

Unable to find stack

I've added a 8th and 9th one.. none of them will be found by the plugin.

screen shot 2018-02-21 at 12 13 16

Failed to list rancher services?

the output from my drone:

$ docker images -q -f dangling=true
[info] Pulling image plugins/drone-rancher:latest
Drone Rancher Plugin built from b4cd686
Failed to list rancher services: json: cannot unmarshal number into Go value of type string
[info] build failed (exit code 1)

rancher version: v1.1.2
drone version: 0.4

i have tried every combination of rancher plugin parameters, still could not figure out why.

plus my .drone.yml part ๏ผš

 deploy:
  rancher:
    url: http://192.168.1.220:8084
    access_key: 25317F6D60E3110BC2E2
    secret_key: ryAmtmSd4WpajBc9q9JRk9KfubJEmHDjxAHFTQyw
    service: p1/agent
    docker_image: 192.168.1.220:5000/agent:latest
    timeout: 30

PS.

tried quoting access_key.

Support Rancher environments

Multiple Rancher environments with the same stack name, possibly containing different services but that is not necessary, results in drone-rancher selecting the first matching stack name, from any environment, to act upon. This can cause unexpected service upgrades or failures to find the service depending on what the upgrade targets.

Example Rancher site layout:

Rancher Environment -> Stack -> Services
Cloud - Dev1 -> MyCoolStack -> Service4, Service5
Cloud - Dev2 -> MyCoolStack -> Service6
Cloud - Prod1 -> MyCoolStack -> Service1, Service3
Cloud - Prod2 -> MyCoolStack -> Service1, Service2

Example drone.yml snippet:

- name: rancher-deploy
  image: peloton/drone-rancher
  settings:
    url: https://rancher
    access_key:
      from_secret: rancher_access_key_id
    secret_key:
      from_secret: rancher_secret_access_key
    service: MyCoolStack/Service6
    docker_image: foo/bar:v1.1.3-alpha
    confirm: true
    timeout: 180

Using the above snippet upgrading the service MyCoolStack/Service6 in the environment Cloud - Dev2 will fail with a service not found error because drone-rancher matched the first stack name MyCoolStack in the site Cloud - Dev1. As Service6 doesn't exist in this stack the upgrade fails.

Likewise attempting to upgrade the service MyCoolStack/Service1 in the environment Cloud - Prod2 will actually upgrade the service MyCoolStack/Service1 in the environment Cloud - Prod1 as there is no way to specify the target environment.

Workarounds-

  • Per-environment API keys
  • Unique Stack naming in each environment

Rancher Load Balancer Support

It would be awesome to wrap support for Rancher's LB into this plugin.

The idea would be to focus rancher LBs and remove targets from the LB. Then preform an image upgrade and add the target back to the LB after the upgrade has been confirmed. This could solve true zero downtime/rolling deployments in rancher, from the CI server, for production setups.

Problem with secrets

I started a thread on the drone discourse, posting here as well. I think I'm following the docs on this repo but it's not working.

https://discourse.drone.io/t/problem-with-rancher-plugin-secrets/1739

====================================================

I can't figure out how to configure the rancher plugin properly. Here's my .drone.yml:
https://github.com/tahosalodge/elections-frontend/blob/master/.drone.yml

And for that repo, here's a screenshot of the defined secrets:
screenshot 2018-02-09 13 12 46

On my latest build I get this:

    time="2018-02-09T19:49:16Z" level=info msg="Drone Rancher Plugin built" 
    time="2018-02-09T19:49:16Z" level=fatal msg="Eek: Must have url, key, secret, and service definied"

custom env variable names

Based on Drone-secret's documentation I was expecting that I can name my secrets anything I want if I refer to them in my .drone.yml. However, the below snippet presents me with an error: "Eek: Must have url, key, secret, and service definied"

So my question is: is there a way to use access and secret key names different from RANCHER_ACCESS_KEY and RANCHER_SECRET_KEY?

Use case being that different when events would deploy to different rancher environments having different keys along the lines of:

  rancher_staging:
    image: peloton/drone-rancher
    service: my_service
    url: https://rancher.mycompany.com
    ...
    access_key: ${RANCHER_STAGING_ACCESS_KEY}
    secret_key: ${RANCHER_STAGING_SECRET_KEY}
    start_first: false
    when:
      event:
        - pull_request
    secrets:
      - RANCHER_STAGING_ACCESS_KEY
      - RANCHER_STAGING_SECRET_KEY

Ability to confirm before update

It would be great to have an option like confirm_previous which confirms any previous upgrade before running the current one. Currently, if a previous upgrade has not been confirmed yet, the job fails with the following error message:

Unable to upgrade service stack/service: Action [upgrade] not available on ...

Especially when using this to update a test environment after pull requests (where you don't really care about the ability to roll back) this feature would be really useful.

Batch size and batch interval

It would be great to be able to alter the batch size at least. If you have a global container across 10 separate hosts with the image being 250 MB in size, it can take a while to upgrade them 1 at a time. Allowing for adjustable batch sizes would allow for more to upgrade simultaneously, thus speeding up deployment.

Confirm fails

Hi,

I have a problem for the confirmation step, it ends up with status code "1" but there is no line printed out whereas I read in the main.go that there should be either :

  • "Error waiting for service upgrade to complete" if after 30 seconds the service wouldn't be upgraded (the service is updated in time)
  • "Unable to finish upgrade" if the method ActionFinishupgrade would have returned an error
  • "Finished upgrade" if everything went fine

Here is the log output :
[info] Pulling image artifactory.myoffice.me.fr:5001/drone-rancher:latest
Drone Rancher Plugin built at 2016-02-02 08:56:57 UTC
Upgraded glpi/glpi to docker:artifactory.myoffice.me:5003/glpi:latest
[info] build failed (exit code 1)

On Rancher, the service is upgraded but not confirmed.

Here is the deploy part of my .drone.yml :
deploy:
rancher:
image: artifactory.myoffice.me:5001/drone-rancher:latest
url: 'https://rancher.myoffice.me'
access_key: xxx
secret_key: xxx
service: glpi/glpi
docker_image: 'artifactory.myoffice.me:5003/glpi:latest'
start_first: true
confirm: true

Any idea ?

Thx

Unable to find service

Hello, help please. I throw an error when deploying drone io on rancher Unable to find service demo/wordpress3

rancher:
  image: peloton/drone-rancher
  url: http://*****:8080
  access_key: ***
  secret_key: ******
  service: demo/wordpress3
  docker_image: registry.gitlab.com/*****/******

rancher_2017-04-02_02-08-22

Force pull

Add the ability to make the upgrade force pull images. Helpful when using :latest tags.

Option: confirm upgrade

Confirm upgrade when it is done (like rancher-compose --confirm-upgrade). That will be useful for staging environment. Now with the second push error "Unable to upgrade service" appears.

Error using Rancher v1

Getting an error:

time="2017-11-05T14:09:18Z" level=info msg="Drone Rancher Plugin built" 0s 2 2017/11/05 14:09:20 Unable to upgrade service FE-APP-PROD/react-client: Action [upgrade] not available on [&{1s42 service map[environment:http://beta.dev.co:9999/v1/environment/1e23 self:http://beta.dev.co:9999/v1/services/1s42 consumedbyservices:http://beta.dev.co:9999/v1/services/1s42/consumedbyservices networkDrivers:http://beta.dev.co:9999/v1/services/1s42/networkdrivers serviceLogs:http://beta.dev.co:9999/v1/services/1s42/servicelogs storageDrivers:http://beta.dev.co:9999/v1/services/1s42/storagedrivers containerStats:http://beta.dev.co:9999/v1/services/1s42/containerstats account:http://beta.dev.co:9999/v1/services/1s42/account configItemStatuses:http://beta.dev.co:9999/v1/services/1s42/configitemstatuses consumedservices:http://beta.dev.co:9999/v1/services/1s42/consumedservices instances:http://beta.dev.co:9999/v1/services/1s42/instances serviceExposeMaps:http://beta.dev.co:9999/v1/services/1s42/serviceexposemaps] map[rollback:http://beta.dev.co:9999/v1/services/1s42/?action=rollback remove:http://beta.dev.co:9999/v1/services/1s42/?action=remove finishupgrade:http://beta.dev.co:9999/v1/services/1s42/?action=finishupgrade removeservicelink:http://beta.dev.co:9999/v1/services/1s42/?action=removeservicelink addservicelink:http://beta.dev.co:9999/v1/services/1s42/?action=addservicelink setservicelinks:http://beta.dev.co:9999/v1/services/1s42/?action=setservicelinks]}]

Could it be, that Rancher API was changed?

Research: Rancher 2.0 move away from cattle and using K8s

Rancher 2.0 is moving away from cattle and using k8s for everything. We should research how this will impact the drone-plugin.

If someone is testing 2.0 feel free to comment here. Otherwise I'll get around to it in the next month or so.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.