Friday, January 25, 2019

学习舵轮(kubernetes)和埠(docker) - 前言

几年前我为别人写了个Android媒体播放器程序。他想知道用户的使用情况,以便推广告。为此,我需要建一个webserver和database用来tracking。Node.JS + MongoDB是一个理想的选择。因为不想花钱,于是选用了OpenShift Online free account (provided by RedHat),虽然有quota限制,但足够满足这个小job。不幸的是2017年9月RedHat停止了免费用户支持(随后付费用户支持也停了)。后来RedHat又开始提供新的OpenShift Container Platform,参见wikipedia的解释:
OpenShift is a family of containerization software developed by Red Hat. Its flagship product is the OpenShift Container Platform—an on-premises platform as a service built around Docker containers orchestrated and managed by Kubernetes on a foundation of Red Hat Enterprise Linux. The family's other products provide said platform through different environments: OKD serves as the community-driven upstream (akin to CentOS), OpenShift Online is the platform offered as software as a service, Openshift Dedicated is the platform offered as a managed service, and OpenShift.io is an application development environmentfor the platform available online.

关于OKDOKD is the Origin community distribution of Kubernetes optimized for continuous application development and multi-tenant deployment.  OKD adds developer and operations-centric tools on top of Kubernetes to enable rapid application development, easy deployment and scaling, and long-term lifecycle maintenance for small and large teams. OKD is also referred to as Origin in github and in the documentation.
The OKD API is located on each server at `https://:8443/apis`. OKD adds its own API groups alongside the Kubernetes APIs. Refer to the API.

也就是说OpenShift = RedHat云 + Kubernetes + Docker
OpenShift提供了很不错的起步教程和配置界面,很容易创建project,开始deployment,设置一个router路由,从而提供可从外面访问的web server,可是,不知是因为地域原因,还是因为免费的服务原因,我在OpenShift新创建的webserver很不稳定,用web browser试十次可能有一次能正常打开网页(错误信息:application is not avaliable)。另外RedHat提供的CLI utility, OC,也不能在Ubuntu 16.04上运行,会出 libssl.so.10: cannot open shared object file: No such file or directory错,按照askubuntu的这个post也不能解决问题。我build OpenSSL from source也不能解决问题。参照issues/21061最后从GitHub https://github.com/openshift/origin/releases 下载的版本可以正常工作。另外MacOS的版本也没有问题。

OpenShift提供了一些project的模版,其中就有Node.js+MongoDB, 我用这个模版创建项目,fork了GitHub project sclorg/nodejs-ex, 从OpenShift web console 获取了project的web hook URL, 然后在设置在GitHub setting/webhook payload,并且修改 "Content type" 为 'application/json',这样每当更新GitHub 上的source code,GitHub 会push change到OpenShift,并且直接trigger a build和新的deployment,很cool。
正当服务的可靠性问题还没有解决,RedHat最近又更新policy,免费用户账号每30天就会失效,种种原因,我决定放弃OpenShift,既然OpenShift基于的Kubernetes是开源的,又拥有众多支持,何不直接从Kubernetes开始呢?

0 Comments:

Post a Comment