Giter VIP home page Giter VIP logo

rbshift's Introduction

RbShift usage

Obtaining client

Client object is the starting point of interaction with Openshift, it can be created either by providing bearer token or username and password.

require 'rb_shift/client'

# Getting client with token
cli = RbShift::Client.new 'https.ose3.example.com:8443', bearer_token: 'SomeToken'

# Getting client with username/password
cli2 = RbShift::Client.new 'https.ose3.example.com:8443', username: 'admin', password: 'P@ssw0rd'

Working with projects

All resources in openshift are created and managed in projects.

# Get list of projects
projects = cli.projects

# selecting specific project
my_proj = projects['MyAwesomeProject']

# Delete project without waiting
my_proj.delete

# Delete project and wait until it disappears
my_proj.delete true

# Create new project
my_proj = cli.create_project 'AwesomeProject'

Creating template and deploying application

# Create template from url
my_proj.create_template 'http://example.com/template.yml'

# Create template from file
my_proj.create_template '/home/user/template.yml'

# Start application from template this will be translated to oc command
# oc new-app template TemplateName --param='param1=Value1' --param='param2=Value2' --env='SOME_VAR=Value3' --group='gr1' --group='gr2'
# This command is blocking
my_proj.new_app 'template', 'TemplateName', block: true, timeout: 30, param: 
  {
    param1: 'Value1',
    param2: 'Value2',
  }, 
  env: {
   SOME_VAR: 'Value3',
  }, 
  group:
  [
    'Gr1',
    'Gr2',
  ]
  
# Start application asynchronously
my_proj.new_app 'template', 'TemplateName'

# Wait for deployments to finish without 
my_proj.wait_for_deployments

Redeploy component

# Find DeploymentConfig to redeploy
dc = my_proj.deployments['DCName']

# Start deployment asynchronously
dc.start_deployment

# Start deployment and block until it finishes with specified timeout
dc.start_deployment block: true, timeout: 30

Creating route

# Find service to expose
service = my_proj.services['ServiceName']

# Create edge terminated https route (encrypted by default router's certificate)
service.create_route 'Route1', 'route1.example.com'

# Create unencrypted route
service.create_route 'Route2', 'route2.example.com', nil

# Create route encrypted by service's certificate
service.create_route 'Route3', 'route3.example.com', 'passthrough'

# Create route encrypted by custom certificate
service.create_route 'Route4', 'route4.example.com', 'ca-cert': '/home/user/ca.pem', cert: '/home/user/cert.pem', key: '/home/user/key.pem'

Env Variables

Logging related:

RB_SHIFT_LOG_LEVEL=(debug|info|warn|error)
RB_SHIFT_LOG_RESPONSES=(true|false)
RESTCLIENT_LOG=stdout

rbshift's People

Contributors

jcechace avatar mijaros avatar pestanko avatar mikz avatar jsmadis avatar jsmolar avatar

Watchers

James Cloos avatar mkudlej avatar  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.