「.NET 開発基盤部会 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
OpenShiftのファーストステップをどうやるか?
取り敢えず、Test Drive OpenShift (on Azure)から入ることにした。
国立公園サンプル・アプリケーション
Azure上にデプロイされる。
「No test drive was found!」
と表示されるので、
「Explore more solutions on Azure Marketplace [See more]」
を押下して、Marketplace 起動する。
C:\openshift-cli
>oc OpenShift Client ・・・ >oc version oc v1.4.1+3f9807a kubernetes v1.4.0+776c994 features: Basic-Auth
https://masterdnsxx.centralus.cloudapp.azure.com/console
>oc login opnshdnsxx.westus.cloudapp.azure.com:8443
Use insecure connections? (y/n):
>oc login https://opnshdnsxx.westus.cloudapp.azure.com:8443 –insecure-skip-tls-verify=true
Username: (The username provided to you in Access information section of the test-drive) Password: (The password provided to you in Access information section of the test-drive) Login successful.
>oc login https://opnshdnsxx.centralus.cloudapp.azure.com --token=XXXXX
>oc new-project <projectname>
最初のイメージを展開する。
https://hub.docker.com/r/kubernetes/guestbook/
>oc new-project usertestdrive-guestbook
Now using project "usertestdrive-guestbook" on server "https://masterdnsxx.centralus.cloudapp.azure.com:443". You can add applications to this project with the 'new-app' command. For example, try: oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git to build a new example application in Ruby.
>oc get projects NAME DISPLAY NAME STATUS default Active kube-public Active kube-system Active logging Active management-infra Active openshift Active openshift-infra Active openshift-node Active openshift-web-console Active usertestdrive-guestbook Active
>oc new-app kubernetes/guestbook --> Found Docker image 4305190 (3 years old) from Docker Hub for "kubernetes/guestbook" * An image stream will be created as "guestbook:latest" that will track this image * This image will be deployed in deployment config "guestbook" * Port 3000/tcp will be load balanced by service "guestbook" * Other containers can access this service through the hostname "guestbook" * WARNING: Image "kubernetes/guestbook" runs as the 'root' user which may not be permitted by your cluster administrator --> Creating resources ... imagestream "guestbook" created deploymentconfig "guestbook" created service "guestbook" created --> Success Run 'oc status' to view your app.
>oc get pods -w NAME READY STATUS RESTARTS AGE guestbook-1-deploy 0/1 ContainerCreating 0 39s NAME READY STATUS RESTARTS AGE guestbook-1-deploy 1/1 Running 0 1m guestbook-1-zw947 0/1 Pending 0 0s guestbook-1-zw947 0/1 Pending 0 0s guestbook-1-zw947 0/1 ContainerCreating 0 0s guestbook-1-zw947 1/1 Running 0 8s guestbook-1-deploy 0/1 Completed 0 1m guestbook-1-deploy 0/1 Terminating 0 1m guestbook-1-deploy 0/1 Terminating 0 1m※ To exit, hit Ctrl+C.
>oc get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE guestbook 172.30.XXX.XXX <none> 3000/TCP 8m
>oc get service guestbook -o json ・・・JSON・・・
>oc get pods NAME READY STATUS RESTARTS AGE guestbook-1-zw947 1/1 Running 0 5m >oc get pod guestbook-1-zw947 -o json ・・・JSON・・・
>oc describe service guestbook
>oc get routes No resources found.
>oc get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE guestbook 172.30.XXX.XXX <none> 3000/TCP 8m
>oc expose service guestbook route "guestbook" exposed
>oc get routes NAME HOST/PORT PATH SERVICES PORT TERMINATION guestbook guestbook-usertestdrive-guestbook.XXX.XXX.XXX.XXX.Xip.io guestbook 3000-tcp
https://guestbook-usertestdrive-guestbook.XXX.XXX.XXX.XXX.Xip.io/
>oc get pods NAME READY STATUS RESTARTS AGE guestbook-1-zw947 1/1 Running 0 16m
>oc rsh guestbook-1-zw947 BusyBox v1.21.1 (Ubuntu 1:1.21.0-1ubuntu1) built-in shell (ash) Enter 'help' for a list of built-in commands. /app $ ls public/ index.html script.js style.css /app $ exit >
>oc rsh guestbook-1-zw947 ls public/ index.html script.js style.css
>oc exec guestbook-1-zw947 ls public/ index.html script.js style.css
>oc get dc NAME DESIRED CURRENT READY AGE guestbook-1 3 3 3 45m
>$ oc get rc NAME DESIRED CURRENT AGE guestbook-1 1 1 59m >oc get rc guestbook-1 -o json ・・・JSON・・・
>oc get rc guestbook-1 -o json | grep -B1 -E "replicas" | grep -v "deployment" -- "spec": { "replicas": 1, -- "status": { "replicas": 1,※ Windowsではgrepが実行不可能。WSLを使用するとイイかもしれない。
>oc scale --replicas=3 dc/guestbook