📜 ⬆️ ⬇️

OpenShift v3. Part II. Continue dating. ROR4

In the previous part , the product itself is considered, as well as a simple example of working with the PaaS implementation. Let's go further. Let's put Ruby-on-Rail 4 with PostgreSQL. In the process we will meet:

1. With built-in rake.
2. Development scheme, it differs from that of v2.
3. Some console client commands.

Create a developer environment


In general, the ready-made configuration "Ruby-on-Rail 4 with PostgreSQL" appeared on the web console and disappeared as it got crooked. More reliably handles according to the instructions from the repository on the githaba . We briefly fork ourselves, then clone locally.

Create a project:
')
$ oc new-project myror4 $ oc new-app openshift/templates/rails-postgresql.json -p SOURCE_REPOSITORY_URL=https://github.com/< yourusername >/rails-ex 

Something like this
 --> Deploying template rails-postgresql-example for "openshift/templates/rails-postgresql.json" rails-postgresql-example --------- An example Rails application with a PostgreSQL database * With parameters: * Name=rails-postgresql-example * Namespace=openshift * Memory Limit=512Mi * Memory Limit (PostgreSQL)=512Mi * Git Repository URL=https://github.com/zirf0/rails-ex * Git Reference= * Context Directory= * Application Hostname= * GitHub Webhook Secret=epApEumIQAFhye32wPsXlnAaDrh34UdoJlw6fGyC # generated * Secret Key=b7augcv4ehdml4lyicyvi0tykum1t6stpwbrv8wpkxydrjpsg5rsrsoovxkjb6lf3wcp45f0wwp60b8uxd7qk1ma7kdmpm3kc00620girongf5aoqlh16fv3xsr0lqh # generated * Application Username=openshift * Application Password=secret * Rails Environment=production * Database Service Name=postgresql * Database Username=userJSV # generated * Database Password=0gD2YwnJ # generated * Database Name=root * Maximum Database Connections=100 * Shared Buffer Amount=12MB * Custom RubyGems Mirror URL= --> Creating resources with label app=rails-postgresql-example ... service "rails-postgresql-example" created route "rails-postgresql-example" created imagestream "rails-postgresql-example" created buildconfig "rails-postgresql-example" created deploymentconfig "rails-postgresql-example" created service "postgresql" created deploymentconfig "postgresql" created --> Success Build scheduled, use 'oc logs -f bc/rails-postgresql-example' to track its progress. Run 'oc status' to view your app. 


In general, this output is important information appearances names / passwords / base PostgreSQL, and GitHub Webhook Secret, which will be needed below.

 $ oc logs -f bc/rails-postgresql-example 

And here is the log
 Pulling image "registry.ops.openshift.com/rhscl/ruby-23-rhel7@sha256:26423d3ba7749e77884580dfec370c0007d6bcfd331b89c2c24d45964f9da7ff" ... Pulling image "registry.ops.openshift.com/rhscl/ruby-23-rhel7@sha256:26423d3ba7749e77884580dfec370c0007d6bcfd331b89c2c24d45964f9da7ff" ... Cloning "https://github.com/zirf0/rails-ex" ... Commit: b857f63c0fdb991cf93a52b80d325f7ab635c775 (Merge pull request #61 from luciddreamz/master) Author: Ben Parees <bparees@users.noreply.github.com> Date: Tue Sep 20 09:12:28 2016 -0400 ---> Installing application source ... ---> Building your Ruby application from source ... ---> Running 'bundle install --deployment' ... Fetching gem metadata from https://rubygems.org/........... Fetching version metadata from https://rubygems.org/... Fetching dependency metadata from https://rubygems.org/.. Installing rake 10.4.2 Installing i18n 0.7.0 Installing json 1.8.2 with native extensions Installing minitest 5.6.1 Installing thread_safe 0.3.5 Installing tzinfo 1.2.2 Installing activesupport 4.2.1 Installing builder 3.2.2 Installing erubis 2.7.0 Installing mini_portile 0.6.2 Installing nokogiri 1.6.6.2 with native extensions Installing rails-deprecated_sanitizer 1.0.3 Installing rails-dom-testing 1.0.6 Installing loofah 2.0.1 Installing rails-html-sanitizer 1.0.2 Installing actionview 4.2.1 Installing rack 1.6.0 Installing rack-test 0.6.3 Installing actionpack 4.2.1 Installing globalid 0.3.5 Installing activejob 4.2.1 Installing mime-types 2.5 Installing mail 2.6.3 Installing actionmailer 4.2.1 Installing activemodel 4.2.1 Installing arel 6.0.0 Installing activerecord 4.2.1 Installing debug_inspector 0.0.2 with native extensions Installing binding_of_caller 0.7.2 with native extensions Installing columnize 0.9.0 Installing byebug 4.0.5 with native extensions Installing coffee-script-source 1.9.1.1 Installing execjs 2.5.2 Installing coffee-script 2.4.1 Installing thor 0.19.1 Installing railties 4.2.1 Installing coffee-rails 4.1.0 Installing multi_json 1.11.0 Installing jbuilder 2.2.13 Installing jquery-rails 4.0.3 Installing pg 0.18.1 with native extensions Installing puma 2.11.3 with native extensions Using bundler 1.10.6 Installing sprockets 3.0.3 Installing sprockets-rails 2.2.4 Installing rails 4.2.1 Installing rdoc 4.2.0 Installing sass 3.4.13 Installing tilt 1.4.1 Installing sass-rails 5.0.3 Installing sdoc 0.4.1 Installing spring 1.3.4 Installing sqlite3 1.3.11 with native extensions Installing turbolinks 2.5.3 Installing uglifier 2.7.1 Installing web-console 2.1.2 Bundle complete! 14 Gemfile dependencies, 56 gems now installed. Bundled gems are installed into ./bundle. Post-install message from rdoc: Depending on your version of ruby, you may need to install ruby rdoc/ri data: <= 1.8.6 : unsupported = 1.8.7 : gem install rdoc-data; rdoc-data --install = 1.9.1 : gem install rdoc-data; rdoc-data --install >= 1.9.2 : nothing to do! Yay! ---> Cleaning up unused ruby gems ... ---> Starting asset compilation ... I, [2016-10-12T12:07:17.702238 #18863] INFO -- : Writing /opt/app-root/src/public/assets/application-dfda1387e2621704c9c53ddd9c1573c1f5099fd3108a2a96d2b02d9b79203f15.js I, [2016-10-12T12:07:17.717678 #18863] INFO -- : Writing /opt/app-root/src/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css Running post commit hook ... sh: cannot set terminal process group (-1): Inappropriate ioctl for device sh: no job control in this shell Run options: --seed 19349 Running: . Finished in 0.096597s, 10.3523 runs/s, 10.3523 assertions/s. 1 runs, 1 assertions, 0 failures, 0 errors, 0 skips Pushing image 172.30.47.227:5000/myror4/rails-postgresql-example:latest ... Pushed 0/5 layers, 1% complete Pushed 1/5 layers, 33% complete Pushed 2/5 layers, 74% complete Pushed 3/5 layers, 83% complete Pushed 4/5 layers, 100% complete Pushed 5/5 layers, 100% complete Push successful 


Go to the "Overview" on the web console in order to go to our application. Our public / index.html flaunts. We can see for ourselves, if that.

Configure Github Webhook


The idea is simple. On the page instructions on how to configure auto-heat on push on github.com. There is an inaccuracy (like the QuickStart ROR4) in “Builds” → “rails-postgesql-example” → “Action” (drop-down menu) → “Edit”. There "GitHub WebHook". Further, according to the instructions. But in general, we have already saved GitHub Webhook Secret earlier, a hook in itself:

 https://api.preview.openshift.com/oapi/v1/namespaces/project.metadata.name/buildconfigs/buildConfig.metadata.name/webhooks/<Our GitHub WebHook Secret>/github. 

That is, you can immediately go to the githabu.

Now, if you have done something locally and sent it to a github, then the change will automatically fall into OpenShift PaaS.

By the way, in a piggy bank.

 $ oc get -o wide pods NAME READY STATUS RESTARTS AGE IP NODE postgresql-1-72xmi 1/1 Running 0 1h 10.1.51.8 ip-172-31-10-169.ec2.internal rails-postgresql-example-1-build 0/1 Completed 0 1h 10.1.8.4 ip-172-31-11-86.ec2.internal rails-postgresql-example-1-z6q8d 1/1 Running 0 58m 10.1.8.4 ip-172-31-11-86.ec2.internal $ oc rsh postgresql-1-72xmi sh-4.2$ exit $ 

You can connect to any working hearth. In v2, there was an ssh connection.

What to do


There is an option to go on picking up the platform, but there are no projects in the work, but to invent a task ... I tend to write a compilation on the product architecture through in-depth study of the documentation. The result will not be instant, but the documentation is raw and only in English.

UPD1. Webhook github works, and OpenShift v3 responds 401, is not authorized, that is, the rebuild needs to be started manually. We'll figure out.

Source: https://habr.com/ru/post/312492/


All Articles