Code Monkey home page Code Monkey logo

rancherci-presentation's Introduction

Jenkins CI with Rancher-Server

This document explains the setup of a rancher-server cluster running a complete CI environment consisting of:

  • a gerrit SCM (git) server (if you arenot familiar with gerrit, think of it as a private github server)
  • a jenkins CI/CD server (your private travis.ci server)
  • a nexus repository server (aka your private maven central) which can mirror maven artifacts and also serve as a private docker registry

Please also see the accompanying other github repositories

Basic Setup

  1. Setup VMs

     cd 01-setupvms
     ./01-create-vms.sh
    

    please check /etc/hosts whether the new hosts have been added , otherwise add them manually

     docker-machine ip rancher-server
     docker-machine ip rancher-agent-01
    

    make sure that entries for rancher-server.shared, rancher-server

     10.211.55.13   	rancher-server.shared rancher-server
     10.211.55.14   	rancher-agent-01.shared rancher-agent-01
    
  2. create the local docker registry for pre-caching all images (only for presentation)

     ./02-01-start-presentation-registry.sh
    
  3. cache images that we will need (optional) (not needed when using presentation registry)

    ./03-01-prepull-images.sh

  4. start registry gui (just to see whats in there)

     ./03-02-start-registry-gui
    

    open http://rancher-server:9000/ to check the local presentation registry

  5. start rancher-server

     ./04-start-rancher-server.sh
    
  6. add rancher-agent

     ./05-add-rancher-agent.sh
    

    this will open a web browser with the correct commandline, copy it to the file 06-start-rancher-agent.sh and make the following changes:

    1. remove the sudo as this is not necessary on mac with docker-machine

    2. add rancher-server:5000 before rancher/agent:v1.2.2 in order to make it download from our cache registry

    3. once this is done execute the updated script

      ./06-start-rancher-agent.sh

  7. setup api keys

     ./07-setup-api-key.sh
    

    this will open a web browser and navigate to the "Add api key" page on your server

    • choose the following values
    • name: rancher-cli
    • description: access the server via cli
    • now copy the key
  8. download rancher CLI brew install rancher-cli, or directly download from

    https://github.com/rancher/cli/releases

  9. setup rancher CLI

     rancher config 
    
    • URL: http://rancher-server:8080
    • keys: here you have to enter the secrets that you have set up in step 6
  10. build the rancher-cli docker image

     cd ../../container/rancher-cli-configured
    
    1. update the access keys you have copied from the web page

    2. build the container and push it to our demo registry

       ./build.sh
       ./push.sh
      

Setup Infrastructure stacks

Nexus

  1. start the nexus stack (already contains all config)

     cd ../stacks/repository-nexus
     rancher up -d
    
  2. once the registry is up you can log into it from all your nodes

     ./docker-login.sh
    
  3. create a jenkins user

    • username: jenkins
    • password: password
    • role : Admin

    Usually you would use the credentials from active directory / LDAP but for the demo we make it quick

  4. add the nexus repository to the rancher UI

    http://rancher-server.shared:8080/env/1a5/infra/registries

Gerrit

  1. launch the stack

     cd ../gerrit
     rancher up -d
    

    Note that usually you would launch gerrit with the parameters for LDAP auth, for more info, check: https://github.com/openfrontier/docker-gerrit

  2. add your .ssh/id_rsa.pub to the admin ssh key list

    http://rancher-agent-01.shared:8082/#/settings/ssh-keys

  3. create a jenkins user with SSH key and projects

     ./create-projects.sh
    
  4. setup verified permission for admin group on "all projects"

    1. add verified label (for more info check the Documentation about "Verified" label

      http://rancher-agent-01.shared:8082/#/admin/projects/All-Projects

      Click on "Edit Config"

       [label "Verified"]
         function = MaxWithBlock
         value = -1 Fails
         value =  0 No score
         value = +1 Verified
      
    2. now click on "Access" to add the permission to reference refs/heads/*

      label verified

  5. finally push the following projects to gerrit

    • rancher-jenkins-seed-jobs (ssh://admin@rancher-agent-01:29418/demo/rancher-jenkins-seed-jobs)
    • demo_webshop (ssh://admin@rancher-agent-01:29418/demo/webshop)

Jenkins

  1. in order to launch Jenkins we need the SEED repo, TODO

    (?) on gerrit or github?

  2. launch jenkins

     cd ../jenkins
     rancher up -d
    
  3. go to jenkins web UI and launch the seed job

    http://rancher-agent-01.shared:8083/

Further reading

More details can be found at Lanyrd.

rancherci-presentation's People

Contributors

rburgstaller avatar rburgst avatar

Watchers

doog33k 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.