在 Kubernetes 上部署 OpenStack 是什么体验
<section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding: 0 10px; word-spacing: 0; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif; line-height: 1.6; letter-spacing: 0.034em; color: rgba(63, 63, 63, 1); font-size: 16px"><p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">红蓝出 CP,OpenStack 和 Kubernetes 在一起会怎样?</p><h2 data-tool="mdnice编辑器" style="padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 22px; display: block; text-align: center; background-image: url("https://my-wechat.mdnice.com/koala-2.png"); background-position: center; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 50px; margin-top: 1em; margin-bottom: 10px"><span class="prefix" style="display: none"></span><span class="content" style="text-align: center; display: inline-block; height: 38px; line-height: 42px; color: rgba(72, 179, 120, 1); background-position: left; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 63px; margin-top: 38px; font-size: 18px; margin-bottom: 10px">背景</span><span class="suffix"></span></h2>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">从去年开始就想深入地学习 Kubernetes,首先想到是在 OpenStack 上能比较轻松地玩转,所以去 尝试了 Magnum ,但是结果令人失望。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">不过随着我搜索到更多的内容,发现一个有趣的事情:</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">那就是相较于在 OpenStack 之上部署 Kubernetes,通过 Kubernetes 去部署 OpenStack 似乎更流行。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">特别当我去研究最近比较热门的边缘计算,发现 OpenStack 社区的两个相关项目,一个是 StarlingX,一个是 Airship,它们都是这样做的:先搭建 Kubernetes 集群,然后通过 OpenStack-Helm 部署容器化的 OpenStack。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">但是这两个项目都还挺复杂,直接去部署它们遇到了不少坑,做了很多的前置操作,涉及到很多脚本代码,结果到搭建 K8s 步骤上还是卡住了。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">于是我决定暂时先不管它们,直接跳到 OpenStack-Helm,至少让我先体验一下基于 Kubernetes 的 OpenStack 到底是啥样。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">这样就又回到了起点:我得先有一套 Kubernetes 多节点集群,但是现在只有一套 OpenStack 环境,所以我仍然得先解决在 OpenStack 上搭建 Kubernetes 的问题。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">经过了一番摸索,踩了不少坑,最后终于完成了这次尝试。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">下面简单地分享下最终的效果,其中的过程涉及较多,后续再择机分享。</p>
<h2 data-tool="mdnice编辑器" style="padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 22px; display: block; text-align: center; background-image: url("https://my-wechat.mdnice.com/koala-2.png"); background-position: center; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 50px; margin-top: 1em; margin-bottom: 10px"><span class="prefix" style="display: none"></span><span class="content" style="text-align: center; display: inline-block; height: 38px; line-height: 42px; color: rgba(72, 179, 120, 1); background-position: left; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 63px; margin-top: 38px; font-size: 18px; margin-bottom: 10px">整个环境概况</span><span class="suffix"></span></h2>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/5b9771d4-5a90-45c2-bc12-132c6d023519.png" alt="整个环境架构" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">整个环境架构</figcaption></figure>
<h2 data-tool="mdnice编辑器" style="padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 22px; display: block; text-align: center; background-image: url("https://my-wechat.mdnice.com/koala-2.png"); background-position: center; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 50px; margin-top: 1em; margin-bottom: 10px"><span class="prefix" style="display: none"></span><span class="content" style="text-align: center; display: inline-block; height: 38px; line-height: 42px; color: rgba(72, 179, 120, 1); background-position: left; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 63px; margin-top: 38px; font-size: 18px; margin-bottom: 10px">最上层:一个普通的 OpenStack 环境</span><span class="suffix"></span></h2>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">在上面的 OpenStack 中用 cirros 镜像创建了一个虚机:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608163640522.png" alt="image-20200608163640522" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">image-20200608163640522</figcaption></figure>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">细心的你可能已经发现这里的端口号不是默认的 80,而是比较奇怪的 32557,这是因为这个 openstack 环境是搭建在 Kubernetes 集群上,而且通过 NodePort 暴露的服务。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">在页面上查看 openstack 的系统信息:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608163959155.png" alt="image-20200608163959155" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">image-20200608163959155</figcaption></figure>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">各个服务的 endpoints URL 都是以 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">*.openstack.svc.cluster.local</code> 域名的形式,熟悉 Kubernetes 的应该看上去有点眼熟。</p>
<h2 data-tool="mdnice编辑器" style="padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 22px; display: block; text-align: center; background-image: url("https://my-wechat.mdnice.com/koala-2.png"); background-position: center; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 50px; margin-top: 1em; margin-bottom: 10px"><span class="prefix" style="display: none"></span><span class="content" style="text-align: center; display: inline-block; height: 38px; line-height: 42px; color: rgba(72, 179, 120, 1); background-position: left; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 63px; margin-top: 38px; font-size: 18px; margin-bottom: 10px">OpenStack 在 Kubernetes 中的细节</span><span class="suffix"></span></h2>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">下面详细地看看 OpenStack 在集群中是怎么一回事:</p>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">Helm</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">全部使用 Helm 部署:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/helm_list_openstack.png" alt="helm list" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">helm list</figcaption></figure>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">Ingress</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em"><strong style="font-weight: bold; line-height: 1.75em; color: rgba(74, 74, 74, 1)">Public</strong> 接口是通过 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">Ingress</code> 暴露的:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608165003793.png" alt="ingress" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">ingress</figcaption></figure>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">Service</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">更多的内部接口则可以在 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">service</code> 中看到:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608165418688.png" alt="service" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">service</figcaption></figure>
<blockquote class="multiquote-1" data-tool="mdnice编辑器" style="border-top: none; border-right: none; border-bottom: none; border-left: 3px solid rgba(53, 179, 120, 1); font-size: 0.9em; overflow: auto; overflow-scrolling: touch; background: rgba(251, 249, 253, 1); color: rgba(106, 115, 125, 1); padding: 15px 20px; margin-bottom: 20px; margin-top: 20px; line-height: 27px; display: block">
<p style="padding: 0; margin: 0; line-height: 26px; font-size: 15px; color: rgba(89, 89, 89, 1)">注意 horizon-int 对应的就是 Dashboard 服务,它的类型是 NodePort 而且映射的端口号是 32557</p>
</blockquote>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">DaemonSet</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">各种 agent 包括计算节点、OVS、Libvirt 等,都是通过 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">DaemonSet</code> :</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608165752973.png" alt="daemonsets" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">daemonsets</figcaption></figure>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">StatefulSet</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">带状态的数据库和消息队列,以 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">StatefulSet</code> 的形式:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608170004768.png" alt="statefulset" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">statefulset</figcaption></figure>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">Job</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">还有部署过程中的各种任务,包括初始化数据库,注册 endpoint 等,都是以 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">job</code> 方式执行的:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608170158822.png" alt="job" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">job</figcaption></figure>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">Pod</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">最终所有这些 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">pod</code> 构成了这个 openstack 环境:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608170314788.png" alt="pod" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">pod</figcaption></figure>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">PV 和 PVC</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">当然还要用到持久化的卷存储,即 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">PersistentVolumeClaim</code> 和 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">PersistentVolume</code> :</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608170712499.png" alt="pv and pvc" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">pv and pvc</figcaption></figure>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">Ceph</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">持久化存储由 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">ceph</code> 提供,它们同样部署在当前集群中 :</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608170920234.png" alt="ceph" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">ceph</figcaption></figure>
<h2 data-tool="mdnice编辑器" style="padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 22px; display: block; text-align: center; background-image: url("https://my-wechat.mdnice.com/koala-2.png"); background-position: center; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 50px; margin-top: 1em; margin-bottom: 10px"><span class="prefix" style="display: none"></span><span class="content" style="text-align: center; display: inline-block; height: 38px; line-height: 42px; color: rgba(72, 179, 120, 1); background-position: left; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 63px; margin-top: 38px; font-size: 18px; margin-bottom: 10px">中间层:Kubernetes on OpenStack</span><span class="suffix"></span></h2>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">这个 Kubernetes 集群有 4 个节点,1 个 master 节点,3 个 worker 节点:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608172635305.png" alt="nodes" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">nodes</figcaption></figure>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">4 个节点都是底层 OpenStack 环境提供的虚机:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200608172954363.png" alt="vm 实例" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">vm 实例</figcaption></figure>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">在 openstack 中部署 Kubernetes 的方案很多,在尝试了其中的一些(包括 magnum)之后,最终使用基于 Ansible 的 Kubespray 部署。为了简化操作,这套 Kubernetes 集群也并没有对接底层的 OpenStack。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">手动创建了虚机之后,完成这样一套集群大概需要 20 分钟:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200609142153862.png" alt="kubespray playbook" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">kubespray playbook</figcaption></figure>
<blockquote class="multiquote-1" data-tool="mdnice编辑器" style="border-top: none; border-right: none; border-bottom: none; border-left: 3px solid rgba(53, 179, 120, 1); font-size: 0.9em; overflow: auto; overflow-scrolling: touch; background: rgba(251, 249, 253, 1); color: rgba(106, 115, 125, 1); padding: 15px 20px; margin-bottom: 20px; margin-top: 20px; line-height: 27px; display: block">
<p style="padding: 0; margin: 0; line-height: 26px; font-size: 15px; color: rgba(89, 89, 89, 1)">这里最初的 node-4 不幸被折腾挂了,所以上面显示的是后面新增的 node-5</p>
</blockquote>
<h2 data-tool="mdnice编辑器" style="padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 22px; display: block; text-align: center; background-image: url("https://my-wechat.mdnice.com/koala-2.png"); background-position: center; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 50px; margin-top: 1em; margin-bottom: 10px"><span class="prefix" style="display: none"></span><span class="content" style="text-align: center; display: inline-block; height: 38px; line-height: 42px; color: rgba(72, 179, 120, 1); background-position: left; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 63px; margin-top: 38px; font-size: 18px; margin-bottom: 10px">最下层:基于 Kolla 的 OpenStack</span><span class="suffix"></span></h2>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">最底层的 openstack 是搭建在一台物理服务器上的 All-In-One 环境,使用 Kolla 作为部署工具。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">Kolla 使用容器来部署 OpenStack,所以可以通过 <code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27, 31, 35, 0.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: rgba(40, 202, 113, 1)">docker ps</code> 查看服务:</p>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/image-20200609143027326.png" alt="openstack in docker" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">openstack in docker</figcaption></figure>
<h2 data-tool="mdnice编辑器" style="padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 22px; display: block; text-align: center; background-image: url("https://my-wechat.mdnice.com/koala-2.png"); background-position: center; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 50px; margin-top: 1em; margin-bottom: 10px"><span class="prefix" style="display: none"></span><span class="content" style="text-align: center; display: inline-block; height: 38px; line-height: 42px; color: rgba(72, 179, 120, 1); background-position: left; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; background-size: 63px; margin-top: 38px; font-size: 18px; margin-bottom: 10px">总结和思考</span><span class="suffix"></span></h2>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">OpenStack 和 Kubernetes 的关系</span><span class="suffix" style="display: none"></span></h3>
<figure data-tool="mdnice编辑器" style="margin: 10px 0; display: flex; flex-direction: column; justify-content: center; align-items: center"><img src="https://img-cloud-yy.oss-cn-shanghai.aliyuncs.com/pic/openstack_vs_kubernetes.png" alt="红蓝组CP" style="display: block; margin: 0 auto 25px; max-width: 100%; border-radius: 4px"><figcaption style="margin-top: 5px; text-align: center; color: rgba(136, 136, 136, 1); display: block; font-size: 12px; font-family: PingFangSC-Light">红蓝组CP</figcaption></figure>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">一直以来 OpenStack 作为 IaaS 层,用来管理底层计算资源,而 Kubernetes 则被视作 PaaS 层,来管理应用和容器。在通常的架构图中,OpenStack 都是处在 Kubernetes 的下层,作为云计算平台提供诸如持久卷、负载均衡等资源。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">事实上,OpenStack 系统本身就是一个微服务的架构,使用容器化部署,进而使用 Kubernetes 来管理已经是大势所趋。通过 Kubernetes 强大的容器编排能力,长久以来被诟病的 OpenStack 的部署难,升级难等问题可以得到有效解决。 在这次测试中,当中途遇到错误时,处理方式非常「简单粗暴」,直接删掉重来。管理面要求高可用?直接改 replicas 就行。Kubernetes 和 Helm 的强大功能令人印象深刻。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">同时现在可以无缝引入云原生社区强大生态,例如 Prometheus,ELK 等,想用的话基本就是一键部署和接入。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">由于 Kubernetes 基于云的设计,在私有云场景下,OpenStack 仍然是 Cloud Provider 的不二选择。不仅可以提供可用于部署集群的 Node 实例(虚机或裸金属),也能补充底层网络/存储资源的管理能力。</p>
<h3 data-tool="mdnice编辑器" style="margin-bottom: 15px; padding: 0; font-weight: bold; color: rgba(0, 0, 0, 1); font-size: 20px; margin-top: 1.2em"><span style="background-image: url("https://my-wechat.mdnice.com/koala-3.png"); background-size: 100% 100%; background-repeat: no-repeat; display: inline-block; width: 16px; height: 15px; line-height: 15px; margin-bottom: -1px"></span><span class="prefix" style="display: none"></span><span class="content" style="font-size: 17px; font-weight: bold; display: inline-block; margin-left: 8px; color: rgba(72, 179, 120, 1)">关于实际应用的思考</span><span class="suffix" style="display: none"></span></h3>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">因为环境所限,这里最上层 OpenStack 已经是二次虚拟化了,显然没有实用价值,实际应用中需要有所变化。</p>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">我能想到的可行方案:</p>
<ul data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: rgba(0, 0, 0, 1); list-style-type: disc">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgba(1, 1, 1, 1); font-weight: 500">以虚拟机为主要工作负载的,容器作为补充的,可以考虑保留下面两层,通过 OpenStack 提供基于虚机的 Kubernetes 集群和容器服务。</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgba(1, 1, 1, 1); font-weight: 500">以容器为主要工作负载的,可以考虑仅使用上面两层,在裸机上部署 Kubernetes。这样部署在上层的 OpenStack 就是一个用来供给虚机的服务,本质和部署一个网站没啥区别。</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgba(1, 1, 1, 1); font-weight: 500">结合我们前面介绍的裸金属技术,保留所有三层,底层的 OpenStack 只负责提供裸金属实例,这样上面两层的作用和上一个方案类似。</section></li></ul>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">当然,显而易见的,这样一套架构最大的问题就是太过于复杂。同时引入两套技术栈,对团队的要求较高。如果非要二选一,大多数的小公司会作何选择不言而喻。</p>
<p>你对 Kubernetes 和 OpenStack 之间关系有何想法,欢迎在评论区讨论。</p>
<p>感谢你的阅读,请继续关注「云计算实验室」</p>
<p id="nice-suffix-juejin-container" class="nice-suffix-juejin-container" data-tool="mdnice编辑器" style="font-size: 16px; padding-bottom: 8px; margin-top: 20px !important; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 1em; color: rgba(74, 74, 74, 1); line-height: 1.75em">本文使用 mdnice 排版</p></section><br><br>
来源:https://www.cnblogs.com/davyyy/p/13748322.html
頁:
[1]