Giter Site home page Giter Site logo

lab-ci-042017's Introduction

TnT 06-2017 / CI LABS / Rancher, Traefik, Jenkins

This labs is a very simple example on how to deploy an application on Rancher. We will use tutum/hello-world

During this lab, you will learn how to use Rancher to deploy an image, how to play with Traefik, and how to set up a very simple Jenkins pipeline in order to have continuous delivery.

First of all, you need an account on Github and an API Token. To generate a token, use "Personal access tokens" on your gihub profile and check repo.

Rancher vocabulary

https://docs.rancher.com

stack: A stack is a group of services. Stacks can be used to group together services that together implement an application.

services: Cattle adopts the standard Docker Compose terminology for services and defines a basic service as one or more containers created from the same Docker image.

URLS

Rancher: https://rancher.tnt-labs.org Jenkins: http://jenkins-primary.jenkins.traefik.tnt-labs.org

Deploying application using Rancher UI

  1. Create a new stack called labs-<user> into the labs environment.

  2. Add your first service app using tutum/hello-world. Don't forget to Add TCP health check on port 80.

  3. If all is ok, your image is running on your host.

  4. Now you can check that your container is running using shell or logs view

  5. You container is running but not reachable... So we have to configure a loadbalancer. Rancher provides a HAproxy LB but we will use Traefik with a wildcard dns entry (on Route53). Traefik is already deployed, you just have to add labels on your service using upgrade feature:

traefik.port: 80
traefik.enable: true
traefik.domain: traefik.tnt-labs.org

  1. Click on upgrade / finish upgrade in order to clean previous containers

  2. Congratulation, your application is available using <service>.<stack>.traefik.tnt-labs.org

  3. You can perform a rolling upgrade using an other image: dockercloud/hello-world

Using Jenkins CI

Now we want to industrialize the deployment part. We will use a Jenkins pipeline in order to upgrade image automatically.

  1. Fork the Github project.

  2. Go to Jenkins and add your Github token (genereted ising Github profile settings).

  3. Now create a new Multibranch Pipeline project called test-XXX-CI

  4. Add Github source

  5. You will see your master branch appear Jenkins will use the Jenkinsfile present on your git repo to generate 1 job per branch. This simple pipeline will have 2 steps: The first part is to configure the rancher-cli, the second part is to deploy your application.

  6. Your first pipeline will run automatically. Go on rancher, a new stack is available <jenkins_job_name>-<branch>.

  7. You can browse your website using http://helloworld-application.test-snahelou-ci-master.traefik.tnt-labs.org/

  8. Add a Github webhook in order to have continuous deployment.

  9. Try to change your docker image into your docker-compose.yml and check your pipeline on jenkins

  10. Congratulation, Rancher performs a rolling update on your service :)

  11. Take a look Blue Ocean UI

  12. Don't forget to delete stack on rancher and your jenkins jobs.

Requirements

  • Two global environment variables (rancher env api):

    • RANCHER_KEY
    • RANCHER_URL
  • One global secret RANCHER_SECRET

  • Jenkins plugins:

    • Credentials Binding Plugin
    • Folder
    • CloudBees Credentials Plugin
    • Environment Injector Plugin
    • Blue ocean

lab-ci-042017's People

Contributors

snahelou avatar c4r1570p4e avatar

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.