CodeReady Containers : 基本操作2022/03/02 |
CodeReady Containers で構成した シングルノード OpenShift 4 クラスターでのアプリケーション作成等の基本操作です。
|
[1] | アプリケーションの作成/削除等の操作です。 |
# [developer] アカウントでログイン [cent@dlp ~]$ eval $(crc oc-env) [cent@dlp ~]$ oc login -u developer https://api.crc.testing:6443
# [test-project] プロジェクト作成 [cent@dlp ~]$ oc new-project test-project Now using project "test-project" on server "https://api.crc.testing:6443". You can add applications to this project with the 'new-app' command. For example, try: oc new-app rails-postgresql-example to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application: kubectl create deployment hello-node --image=k8s.gcr.io/serve_hostname # [rails-postgresql-example] アプリケーション デプロイ [cent@dlp ~]$ oc new-app rails-postgresql-example warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories. --> Deploying template "openshift/rails-postgresql-example" to project test-project Rails + PostgreSQL (Ephemeral) --------- An example Rails application with a PostgreSQL database. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/rails-ex/blob/master/README.md. WARNING: Any data stored will be lost upon pod destruction. Only use this template for testing. The following service(s) have been created in your project: rails-postgresql-example, postgresql. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/rails-ex/blob/master/README.md. * With parameters: * Name=rails-postgresql-example * Namespace=openshift * Memory Limit=512Mi * Memory Limit (PostgreSQL)=512Mi * Git Repository URL=https://github.com/sclorg/rails-ex.git * Git Reference= * Context Directory= * Application Hostname= * GitHub Webhook Secret=gA00uJ7SJo6kK5RAWL543VtAbMYCanm8fsfMfW0T # generated * Secret Key=xol1ajm5xc6qmpbvr5lf3forwbytn4qkb1b02bvpuenwms72cweouwpanbrtx5anahd00p1h6ik4an8kndarrptq351d0p8ixlwpuiu802pna4nedqxmwpygflrgpqy # generated * Application Username=openshift * Application Password=secret * Rails Environment=production * Database Service Name=postgresql * Database Username=userXUF # generated * Database Password=GHyvheq7 # generated * Database Name=root * Maximum Database Connections=100 * Shared Buffer Amount=12MB * Custom RubyGems Mirror URL= --> Creating resources ... secret "rails-postgresql-example" created service "rails-postgresql-example" created route.route.openshift.io "rails-postgresql-example" created imagestream.image.openshift.io "rails-postgresql-example" created buildconfig.build.openshift.io "rails-postgresql-example" created deploymentconfig.apps.openshift.io "rails-postgresql-example" created service "postgresql" created deploymentconfig.apps.openshift.io "postgresql" created --> Success Access your application via route 'rails-postgresql-example-test-project.apps-crc.testing' Build scheduled, use 'oc logs -f buildconfig/rails-postgresql-example' to track its progress. Run 'oc status' to view your app. # 進行状況はログで確認可 [cent@dlp ~]$ oc logs -f buildconfig/rails-postgresql-example
.....
.....
.....
Writing manifest to image destination
Storing signatures
Successfully pushed image-registry.openshift-image-registry.svc:5000/test-project/rails-postgresql-example@sha256:ed129d23512152cb0ca5cde875043343989c589b371ac7b88618753722c7d363
Push successful
# [successful] で終了すれば OK
# ステータス確認 [cent@dlp ~]$ oc status In project test-project on server https://api.crc.testing:6443 svc/postgresql - 10.217.5.7:5432 dc/postgresql deploys openshift/postgresql:12-el8 deployment #1 running for 25 seconds - 0/1 pods http://rails-postgresql-example-test-project.apps-crc.testing (svc/rails-postgresql-example) dc/rails-postgresql-example deploys istag/rails-postgresql-example:latest <- bc/rails-postgresql-example source builds https://github.com/sclorg/rails-ex.git on openshift/ruby:2.6-ubi8 build #1 running for 26 seconds - 7214e7c: Fix s2i assemble failing with Ruby 2.6. deployment #1 waiting on image or update View details with 'oc describe <resource>/<name>' or list resources with 'oc get all'.[cent@dlp ~]$ oc get pods NAME READY STATUS RESTARTS AGE postgresql-1-deploy 0/1 Completed 0 7m26s postgresql-1-pw4dp 1/1 Running 0 7m19s rails-postgresql-example-1-build 0/1 Completed 0 7m27s rails-postgresql-example-1-deploy 0/1 Completed 0 80s rails-postgresql-example-1-hook-pre 0/1 Completed 0 77s rails-postgresql-example-1-hs82t 1/1 Running 0 51s # サービスへのアクセスパス確認 [cent@dlp ~]$ oc get routes NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD rails-postgresql-example rails-postgresql-example-test-project.apps-crc.testing rails-postgresql-example >all< None # アクセス確認 [cent@dlp ~]$ curl rails-postgresql-example-test-project.apps-crc.testing <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Welcome to OpenShift</title> <style> /*! * Bootstrap v3.0.0 * * Copyright 2013 Twitter, Inc * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 ..... ..... ..... # アプリケーションを削除する場合は以下 [cent@dlp ~]$ oc delete all -l app=rails-postgresql-example |
Sponsored Link |