cdrx / rancher-gitlab-deploy

Painless deployment of projects built with GitLab CI onto your Rancher infrastructure
MIT License
432 stars 90 forks source link

Update By Tag #47

Open Fenikkusu opened 6 years ago

Fenikkusu commented 6 years ago

Not sure if this is possible or not, but it would be nice if this was able to update by tag. Instead of saying

upgrade --stack my-stack
upgrade --stack my-other-stack
upgrade --stack yet-another-stack

I could instead just say

upgrade --tag stack-group
cdrx commented 6 years ago

Would this upgrade by Docker tag? ie, anything with ":latest" would be upgrade --tag latest?

Fenikkusu commented 6 years ago

Not quite what I had it mind, but that’s possible to. I’m actually referring to rancher tags. For example, I could create a couple WordPress stacks and tag them WordPress in rancher. What I’d like to happen is if I then run —service pho —tag WordPress, it would proceed to upgrade each php service in every stack tagged WordPress

Sent from my iPhone

On Mar 16, 2018, at 1:34 PM, Chris R notifications@github.com wrote:

Would this upgrade by Docker tag? ie, anything with ":latest" would be upgrade --tag latest?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Fenikkusu commented 6 years ago

Some additional clarification. Due to the nature of this, I think that using --tag would need to completely ignore --stack. If you were to specify tag and multiple stacks exist with the same tag, then the assumption is that you are trying to update each stack tagged as such, not just one. It is also reasonable to say that using --tag would require a need for a --exclude-stack option as well, so we could say update all stacks tagged wordpress but the stack named 'my-legacy-stack'.

Going back to the WordPress example, If I use a custom build image of WordPress and I have multiple clients running that same build but are otherwise isolated from each other, currently I'd have to put an upgrade line to the .gitlab-ci.yml for each stack in the environment. IE:

deploy:
  image: cdrx/rancher-gitlab-deploy
  environment: production
  dependencies: []
  script:
    - upgrade --stack Client 2 --service wordpress
    - upgrade --stack Client 3 --service wordpress
    - upgrade --stack Client 4 --service wordpress
    - upgrade --stack Client 5 --service wordpress
    - upgrade --stack Client 6 --service wordpress
    - upgrade --stack Client 7 --service wordpress
    ...
    - upgrade --stack Client N --service wordpress

I would also have to update the yaml any time I add a new stack. If this functionality could be accomplished, then the pipeline only needs to use the upgrade tag line once, with the tag, and updates every stack. IE:

deploy:
  image: cdrx/rancher-gitlab-deploy
  environment: production
  dependencies: []
  script:
    - upgrade --tag wordpress --exclude-stack old-client-stack --service wordpress
sigrist commented 6 years ago

I have another example for this feature. I have two environments, development and production. I can create a new image for my container with the tag preview and so upgrade the stacks with a specific tag, for instance $CI_PROJECT_ID_preview. When all development is done, when I create the container latest, I want to upgrade all stacks with tag $CI_PROJECT_ID_latest.

It would be easy to setup in Rancher and in GitLab.

deploy-preview:
  stage: deploy
  image: cdrx/rancher-gitlab-deploy
  script:
    - upgrade --tag $CI_PROJECT_ID_preview
  only:
    - develop
  environment: 
    name: preview

deploy-production:
  stage: deploy
  image: cdrx/rancher-gitlab-deploy
  script:
    - upgrade --tag $CI_PROJECT_ID_production
  only:
    - master
  environment: 
    name: production

Regards Sigrist