2.10.2. Kompose の使用


Kompose を使用して Docker Compose プロジェクトを変換するには、以下の手順に従います。

  1. CDK を起動し、OpenShift クラスターと通信できるようにします。

    $ minishift start
    Starting local OpenShift cluster using 'kvm' hypervisor...
    -- Checking OpenShift client ... OK
    -- Checking Docker client ... OK
    -- Checking Docker version ... OK
    -- Checking for existing OpenShift container ... OK
    ...
    Copy to Clipboard Toggle word wrap
  2. サンプル Docker Compose ファイル をダウンロードするか、または独自のファイルを使用します。

    wget https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml
    Copy to Clipboard Toggle word wrap
  3. Docker Compose ファイルを OpenShift に変換します。docker-compose.yaml ファイルと同じディレクトリーで kompose convert --provider=openshift を実行します。

    $ kompose convert --provider=openshift
    INFO OpenShift file "frontend-service.yaml" created
    INFO OpenShift file "redis-master-service.yaml" created
    INFO OpenShift file "redis-slave-service.yaml" created
    INFO OpenShift file "frontend-deploymentconfig.yaml" created
    INFO OpenShift file "frontend-imagestream.yaml" created
    INFO OpenShift file "redis-master-deploymentconfig.yaml" created
    INFO OpenShift file "redis-master-imagestream.yaml" created
    INFO OpenShift file "redis-slave-deploymentconfig.yaml" created
    INFO OpenShift file "redis-slave-imagestream.yaml" created
    Copy to Clipboard Toggle word wrap

    ここでは、kompose up --provider=openshift を使用して OpenShift に直接変換およびデプロイできます。

    $ kompose up --provider=openshift
    INFO We are going to create OpenShift DeploymentConfigs, Services and PersistentVolumeClaims for your Dockerized application.
    If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.
    
    INFO Deploying application in "myproject" namespace
    INFO Successfully created Service: frontend
    INFO Successfully created Service: redis-master
    INFO Successfully created Service: redis-slave
    INFO Successfully created DeploymentConfig: frontend
    INFO Successfully created ImageStream: frontend
    INFO Successfully created DeploymentConfig: redis-master
    INFO Successfully created ImageStream: redis-master
    INFO Successfully created DeploymentConfig: redis-slave
    INFO Successfully created ImageStream: redis-slave
    
    Your application has been deployed to OpenShift. You can run 'oc get dc,svc,is,pvc' for details.
    Copy to Clipboard Toggle word wrap
  4. CDK を使用して新たにデプロイされたアプリケーションにアクセスします。

    デプロイメント後に、サービスにアクセスするために OpenShift ルートを作成する必要があります。

    oc を使用して frontend サービスのルートを作成します。

    $ oc expose service/frontend
    route "frontend" exposed
    Copy to Clipboard Toggle word wrap

    minishift を使用して frontend サービスにアクセスします。

    $ minishift openshift service frontend --namespace=myproject --in-browser
    Opening the service myproject/frontend in the default browser...
    Copy to Clipboard Toggle word wrap

    デプロイされたコンテナーの概要については、OpenShift の GUI にアクセスすることもできます。

    $ minishift console
    Opening the OpenShift Web console in the default browser...
    Copy to Clipboard Toggle word wrap
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat