# System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates.
┌──[root@vms16.liruilongs.github.io]-[~] └─$oc get project NAME DISPLAY NAME STATUS hello-world-oc Active myproject My Project Active ┌──[root@vms16.liruilongs.github.io]-[~] └─$oc login -u system:admin ┌──[root@vms16.liruilongs.github.io]-[~] └─$oc get ns | grep hello hello-world-oc Active 4m
假设我们已经走过了 CI 的过程,现在拥有一个包含应用的打好的镜像 openshift/hello-openshift ,拉取镜像
1 2 3 4 5 6 7
┌──[root@192.168.26.16]-[~] └─$docker pull openshift/hello-openshift Using default tag: latest latest: Pulling from openshift/hello-openshift Digest: sha256:aaea76ff622d2f8bcb32e538e7b3cd0ef6d291953f3e7c9f556c1ba5baf47e2e Status: Downloaded newer image for openshift/hello-openshift:latest docker.io/openshift/hello-openshift:latest
OKD 中应用的概念和和传统的应用概念相关,当前应用的所有的 API 资源都会打上 app=appname 的标签
通过 oc new-app openshift/hello-openshift 创建的应用,OKD 会自动的创建一些应用相关的 API 资源对象,这些资源包括 OKD 所特有的和原生的 k8s API 对象。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
┌──[root@192.168.26.16]-[~] └─$oc new-app openshift/hello-openshift --> Found Docker image 7af3297 (4 years old) from Docker Hub for"openshift/hello-openshift"
* An image stream tag will be created as "hello-openshift:latest" that will track this image * This image will be deployed in deployment config "hello-openshift" * Ports 8080/tcp, 8888/tcp will be load balanced by service "hello-openshift" * Other containers can access this service through the hostname "hello-openshift"
--> Creating resources ... imagestream.image.openshift.io "hello-openshift" created deploymentconfig.apps.openshift.io "hello-openshift" created service "hello-openshift" created --> Success Application is not exposed. You can expose services to the outside world by executing one or more of the commands below: 'oc expose svc/hello-openshift' Run 'oc status' to view your app. ┌──[root@192.168.26.16]-[~] └─$
用构建日志可以看到,我们只提供了镜像,其他的 API 资源都是自动生成的。
从Docker Hub 找到镜像,用于 openshift/hello-openshift”
创建 Image Stream为 hello-openshift:latest 使之指向最新的镜像
创建 Deployment Config 为 hello-openshift,
创建 Replication Controller 为 hello-openshift-1
创建 Service ,且 8080/tcp, 8888/tcp 端口将被服务”hello-openshift”负载均衡
┌──[root@vms16.liruilongs.github.io]-[~] └─$oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git --> Found Docker image e96bd99 (18 months old) from Docker Hub for"centos/ruby-25-centos7"
Ruby 2.5 -------- Ruby 2.5 available as container is a base platform for building and running various Ruby 2.5 applications and frameworks. Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, and extensible.
Tags: builder, ruby, ruby25, rh-ruby25
* An image stream tag will be created as "ruby-25-centos7:latest" that will track the source image * A source build using source code from https://github.com/sclorg/ruby-ex.git will be created * The resulting image will be pushed to image stream tag "ruby-ex:latest" * Every time "ruby-25-centos7:latest" changes a new build will be triggered * This image will be deployed in deployment config "ruby-ex" * Port 8080/tcp will be load balanced by service "ruby-ex" * Other containers can access this service through the hostname "ruby-ex"
--> Creating resources ... imagestream.image.openshift.io "ruby-25-centos7" created imagestream.image.openshift.io "ruby-ex" created buildconfig.build.openshift.io "ruby-ex" created deploymentconfig.apps.openshift.io "ruby-ex" created service "ruby-ex" created --> Success Build scheduled, use 'oc logs -f bc/ruby-ex' to track its progress. Application is not exposed. You can expose services to the outside world by executing one or more of the commands below: 'oc expose svc/ruby-ex' Run 'oc status' to view your app.