CentOS Stream 9
Sponsored Link

CodeReady Containers : 基本操作2022/03/15

 
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

--> 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=j5e4yK75FGt1xYMxNO2unr52PrybOc4B4tuO4oxF # generated
        * Secret Key=ojw06vwxabsuj8x0b8m5y57kinfu27kh1neflu304uh4857nxu4pdhgw1058tltc58mbyqb78u5cmbmp7ujv2j470xxwguxktsnxc0wkjwkodt437vsns1vcr5p6sw3 # generated
        * Application Username=openshift
        * Application Password=secret
        * Rails Environment=production
        * Database Service Name=postgresql
        * Database Username=user3WC # generated
        * Database Password=TNfFqoLE # 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:a47a86b54f7da7e0341ff0e41f5d268ab38ed644aa450b567a4dc7d3fbafe176
Push successful
# [successful] で終了すれば OK

# ステータス確認

[cent@dlp ~]$
oc status

In project test-project on server https://api.crc.testing:6443

svc/postgresql - 10.217.4.156:5432
  dc/postgresql deploys openshift/postgresql:12-el8
    deployment #1 deployed 6 minutes ago - 1 pod

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
    deployment #1 running for 22 seconds

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          6m30s
postgresql-1-fd5j9                    1/1     Running     0          6m27s
rails-postgresql-example-1-build      0/1     Completed   0          6m31s
rails-postgresql-example-1-deploy     0/1     Completed   0          44s
rails-postgresql-example-1-hook-pre   0/1     Completed   0          41s
rails-postgresql-example-1-t587n      1/1     Running     0          13s

# サービスへのアクセスパス確認

[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

関連コンテンツ