导读 Openshift是一个开源容器云平台,是一个基于主流的容器技术Docker和Kubernetes构建的云平台。Openshift底层以Docker作为容器引擎驱动,以Kubernetes 作为容器编排引擎组件,并提供了开发语言,中间件,DevOps自动化流程工具和web console用户界面等元素,提供了一套完整的基于容器的应用云平台。

OpenShift 生态系统成了 Kubernetes 生态系统。其核心技术使生态系统可以非常地灵活,社区已经在 API 和接口上做了标准化,这为统一集成的新思想成为了可能。它还使我们可以在任何云平台上部署 OpenShift,比如 AWS、 Azure、 GCP、 OpenStack、 VMware、 RHV,以及 bare meta。

Openshift部署流程

示例过程如下
$ oc new-project project1
Now using project "project1" on server https://127.0.0.1:8443.

$ oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git
--> Found Docker image 1f02469 (8 days old) from Docker Hub for "centos/ruby-22-centos7"
...

...
 * An image stream will be created as "ruby-22-centos7:latest" that will track the source image
 * A source build using source code from https://github.com/openshift/ruby-ex.git will be created
 * The resulting image will be pushed to image stream "ruby-ex:latest"
 * Every time "ruby-22-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"
...

...
 Run 'oc status' to view your app.

上面的过程发生了什么:

OpenShift pulls Docker image centos/ruby-22-centos7

OpenShift 从 GitHub 下载了源代码

OpenShift applies GitHub 源代码转换为image, 命名为ruby-ex存储于内部仓库中

ruby-ex 用来创建build and deployment configurations

The ruby-ex service 为了pod负载均衡,使用 ruby-ex 这个名称

再看下应用构建过程

部署过程

POD管理
$ oc get pods
NAME            READY  STATUS    RESTARTS      AGE
ruby-ex-1-build  0/1   Completed   0           1h
ruby-ex-1-zzhrc  1/1   Running     0           56m

也可以使用-o wide的输出,我们可以看到pod所在结点与IP
$ oc get pod -o wide
NAME                       READY     STATUS    RESTARTS   AGE       IP              NODE
docker-registry-11-vcqzz   1/1       Running   0          36d       10.128.0.244    openshift-node-01.hsh.io
hawkular-apm-1-8c2s8       1/1       Running   0          19h       10.131.8.186    openshift-node-17.hsh.io
hawkular-apm-es-1-ddrqt    1/1       Running   0          38d       10.130.1.53     openshift-master-03.hsh.io
registry-console-3-wptmh   1/1       Running   1          63d       10.128.8.11     openshift-node-14.hsh.io
router-32-bpzcx            1/1       Running   0          7d        10.108.78.134   openshift-master-02.hsh.io
router-32-cp9sj            1/1       Running   0          7d        10.108.78.136   openshift-node-01.hsh.io
router-32-dbd0g            1/1       Running   0          7d        10.108.78.138   openshift-node-03.hsh.io
router-32-f4b46            1/1       Running   0          7d        10.108.78.140   openshift-node-05.hsh.io
router-32-k8mpx            1/1       Running   0          7d        10.108.78.139   openshift-node-04.hsh.io
router-32-lhbrl            1/1       Running   0          7d        10.108.78.145   openshift-lb-02.hsh.io
router-32-psnbh            1/1       Running   0          7d        10.108.78.133   openshift-master-01.hsh.io
router-32-zqc7k            1/1       Running   0          7d        10.108.78.135   openshift-master-03.hsh.io
router-32-zv1kx            1/1       Running   0          7d        10.108.78.137   openshift-node-02.hsh.io
Openshift部署容器过程

容器和 Kubernetes 提供了许多有价值的概念,适用于任何应用。容器可以提供一种统一的应用打包方式,让其在开发、测试、质保、准生产和生产环境中运行。它们带来了不变性,可简化运维团队处理安全更新的方式。它们还能让你在云环境间进行移植。Kubernetes 和 OpenShift 之类的平台可以跨任意云环境提供统一的、自动化的、可伸缩的环境(比如,多个云环境)。

原文来自:https://www.cnblogs.com/wintersun/p/12148210.html

本文地址:https://www.linuxprobe.com/openshift.html编辑:倪家兴,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/