项目部署时网关怎么回事

by Richard Li

理查德·李(Richard Li)

使用Kubernetes部署聊天网关(或技术按预期运行时) (Using Kubernetes to deploy a chat gateway (or when technology works like it’s supposed to))

TL; DR (TL;DR)

This is a story about what happens when cloud technologies work like they’re supposed to. In this case, the technologies are Docker and Kubernetes.

这是一个有关云技术按预期工作时会发生什么的故事。 在这种情况下,技术是Docker和Kubernetes。

介绍 (Introduction)

At Datawire, we use Gitter so that users of our open source tools can chat with us (and each other). We like Gitter because it’s low friction to join, especially if you have a GitHub or Twitter account. However, Gitter’s mobile client isn’t great, and the notifications in general don’t work well.

在Datawire ,我们使用Gitter,以便开放源代码工具的用户可以与我们(以及彼此)聊天。 我们之所以喜欢Gitter是因为加入的摩擦很小,特别是如果您拥有GitHub或Twitter帐户。 但是,Gitter的移动客户端不是很好,并且通知通常不能很好地工作。

Since migrating a community of users is a fair bit of work, I decided to see if I could deploy a bridge between Slack (what we use internally) and our Gitter chat. A little bit of Googling led me to Matterbridge.

由于迁移用户社区是一项相当大的工作,因此我决定看看是否可以在Slack(我们在内部使用)和Gitter聊天之间搭建桥梁。 有点谷歌搜索使我到马特布里奇 。

In the rest of the article, I’ll walk through how Docker and Kubernetes actually made my life easier, and why. I found the amount of yak shaving required to be remarkably small … which made me really appreciate how far we’ve come in the cloud world.

在本文的其余部分,我将逐步介绍Docker和Kubernetes如何使我的生活更轻松,以及为什么。 我发现所需的牛剃须量非常少……这使我非常感谢我们在云计算世界中所取得的成就。

Docker很棒 (Docker is great)

I wanted to run Matterbridge locally to debug the configuration. I followed the general instructions on creating accounts for Slack and Gitter, and then put the necessary authentication tokens into a matterbridge.toml file.

我想在本地运行Matterbridge来调试配置。 我按照有关为Slack和Gitter创建帐户的一般说明进行操作,然后将必要的身份验证令牌放到matterbridge.toml文件中。

I was happy to see how Matterbridge is available as a Docker image, so I was able to just copy my configuration file into the Docker image to test out the configuration. All I needed to do was to specify my configuration file when using docker run:

我很高兴看到Matterbridge如何作为Docker映像提供,因此我能够将配置文件复制到Docker映像中以测试配置。 我需要做的就是在使用docker run时指定我的配置文件:

docker run -ti -v /tmp/matterbridge.toml:/matterbridge.toml 42wim/matterbridge

I had to make a few turns of this to debug my configuration, but it was quick and easy. The Docker image did exactly what it’s supposed to do: provide a tested runtime environment for Matterbridge so I didn’t have to debug it on my laptop.

我不得不进行一些操作来调试我的配置,但是它既快速又容易。 Docker镜像完全按照预期的方式运行:为Matterbridge提供经过测试的运行时环境,因此我不必在笔记本电脑上对其进行调试。

在云端运行 (Running in the cloud)

The next step was to deploy my configuration to the cloud. We already run a production Kubernetes cluster fronted by an API Gateway powered by Envoy, so I wanted to deploy the service into its own namespace.

下一步是将我的配置部署到云中。 我们已经运行了一个生产的Kubernetes集群,该集群以Envoy为首的API网关为前端,因此我想将服务部署到它自己的名称空间中。

To deploy to Kubernetes, I wrote a simple Dockerfile:

为了部署到Kubernetes,我编写了一个简单的Dockerfile:

FROM 42wim/matterbridge:1.9.0ADD matterbridge.toml .CMD ["/bin/matterbridge"]

Then, all I needed was a Kubernetes manifest.

然后,我只需要一个Kubernetes清单。

Kubernetes (Kubernetes)

In my Kubernetes manifest, I’m able to specify a bunch of key information about the service:

在我的Kubernetes清单中,我可以指定有关该服务的一系列关键信息:

  • My update strategy, RollingUpdate

    我的更新策略, RollingUpdate

  • The minimum and maximum amount of CPU and memory to allocate要分配的最小和最大CPU和内存量
  • The number of replicas of the service服务的副本数

Here is my basic manifest:

这是我的基本清单:

---apiVersion: apps/v1beta1kind: Deploymentmetadata:  name: {{build.name}}  namespace: {{service.namespace}}spec:  replicas: 1  strategy:    type: RollingUpdate  template:    metadata:      labels:        app: {{build.name}}    spec:      containers:      - name: {{build.name}}        image: {{build.images["Dockerfile"]}}        imagePullPolicy: IfNotPresent        resources:          requests:            memory: 0.1G            cpu: 0.1          limits:            memory: {{service.max_memory}}            cpu: {{service.max_cpu}}

(Note that I’m using Forge to template and manage the service, so this is a templated Kubernetes manifest).

(请注意,我正在使用Forge来模板化和管理服务,所以这是一个模板化的Kubernetes清单)。

With this manifest, I was able to get my service up and running in Kubernetes.

有了这个清单,我就能在Kubernetes中启动并运行我的服务。

我在Git的Matterbridge服务 (My Matterbridge Service in Git)

In summary, my service consists of:

总而言之,我的服务包括:

  • A DockerfileDockerfile
  • A (templated) Kubernetes manifest(模板化的)Kubernetes清单
  • A matterbridge.toml configuration file

    matterbridge.toml配置文件

all of which I was able to check into a Git repository.

所有这些我都能够检入Git存储库。

前Kubernetes世界 (The pre-Kubernetes world)

The ease with which I was able to get a service reliably made me reflect on how I would have done this in the VM-days. I would’ve had to:

我能够轻松获得可靠的服务使我反思了在VM时代应该如何做到这一点。 我将不得不:

  • Provision a VM (and/or create an auto-scaling group)设置VM(和/或创建自动伸缩组)
  • Install the necessary runtime dependencies on the VM via some bash script hackery (or use Ansible, or build a custom AMI)通过一些bash脚本黑客在虚拟机上安装必要的运行时依赖项(或使用Ansible或构建自定义AMI)
  • Copy my configuration to the VM将我的配置复制到VM

Moreover, if I wanted to make the above reproducible, I would have had to use Terraform, Ansible, CloudFormation, or one of these types of tools. Here is the example from the Terraform documentation on how to create an EC2 instance:

而且,如果我想使上述内容可重复,则必须使用Terraform,Ansible,CloudFormation或这些类型的工具之一。 这是Terraform文档中有关如何创建EC2实例的示例 :

# Create a new instance of the latest Ubuntu 14.04 on an# t2.micro node with an AWS Tag naming it "HelloWorld"provider "aws" {  region = "us-west-2"}data "aws_ami" "ubuntu" {  most_recent = true  filter {    name   = "name"    values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]  }  filter {    name   = "virtualization-type"    values = ["hvm"]  }  owners = ["099720109477"] # Canonical}resource "aws_instance" "web" {  ami           = "${data.aws_ami.ubuntu.id}"  instance_type = "t2.micro"  tags {    Name = "HelloWorld"  }}

As a developer, many of the options above (region, instance type) are things that I don’t really care about. Yet, this is the current abstraction if I want to commit infrastructure-as-code.

作为开发人员,上面的许多选项(区域,实例类型)都是我并不真正关心的事情。 但是,如果要提交基础结构代码,这是当前的抽象。

摘要 (Summary)

Kubernetes is more than just a container scheduler. It really gives you the primitives you need to control how your service gets run, without bogging you down in the details of deployment. We’re definitely embracing the mentality of having a small team of ops folks manage the Kubernetes cluster, while the rest of the development team just manages their services via the Kubernetes primitives.

Kubernetes不仅仅是一个容器调度程序。 它确实为您提供了控制服务运行方式所需的原语,而不会使您陷入部署细节中。 我们确实拥抱有一个小团队OPS的人管理Kubernetes集群的心态,而开发团队的其他成员通过Kubernetes元只是管理他们的服务。

While it’s not always sunshine and roses in Kubernetes-land, in my case of deploying Matterbridge, it was. You’ll have to wait for another article to read about challenges!

虽然在Kubernetes-land并不总是阳光和玫瑰花,但在我部署Matterbridge的情况下却是。 您必须等待另一篇文章来阅读有关挑战的信息!

翻译自: https://www.freecodecamp.org/news/using-kubernetes-to-deploy-a-chat-gateway-or-when-technology-works-like-its-supposed-to-a169a8cd69a3/

项目部署时网关怎么回事

项目部署时网关怎么回事_使用Kubernetes部署聊天网关(或技术按预期运行时)...相关推荐

  1. 云原生安全之RASP技术(应用运行时自我保护)

    文章目录 一.背景 1. WAF和RASP 2. waf和rasp是非此即彼的吗? 二.RASP技术(应用运行时自我保护) 1. 应用安全测试SAST.IAST.DAST 和 RASP区别 SAST, ...

  2. 部署go的web应用_使用Docker部署Go Web应用

    为什么需要Docker? 使用docker的主要目标是容器化.也就是为你的应用程序提供一致的环境,而不依赖于它运行的主机. 想象一下你是否也会遇到下面这个场景,你在本地开发了你的应用程序,它很可能有很 ...

  3. kubernetes 部署_用于Kubernetes部署的10种反模式

    kubernetes 部署 As container adoption and usage continues to rise, Kubernetes (K8s) has become the lea ...

  4. 在没有任何数据时进行无效的读取尝试。_技术转载——JVM运行时内存是怎么分布的?...

    写在前面:2020年面试必备的Java后端进阶面试题总结了一份复习指南在Github上,内容详细,图文并茂,有需要学习的朋友可以Star一下! GitHub地址:https://github.com/ ...

  5. k8s部署jar包_使用Kubernetes部署Springboot或Nginx的详细教程

    1 前言 经过<Maven一键部署Springboot到Docker仓库,为自动化做准备>,Springboot的Docker镜像已经准备好,也能在Docker上成功运行了,是时候放上Ku ...

  6. modbus连续读取时数据不正确_使用MODBUS协议与传感器、工控屏对接时碰到的问题...

    当控制器作为可编程逻辑器件用于工控系统时,其需要与各种不同的传感器对接, 同时需要与工控屏对接,以提供人机界面与用户进行交互: 对接的传感器功能多种多样, 有检测环境的温.湿度.二氧化碳.光照等的传感 ...

  7. dns提供商主机名_在 Kubernetes 中使用 DNS 和 Headless Service 发现运行中的 Pod

    作者:Mattias te Wierik 翻译:Bach(才云) 校对:星空下的文仔(才云).bot(才云) 在 Kubernetes 集群中,Service 是将运行在一组 Pods 上的应用程序公 ...

  8. java项目经理也就那么回事_网易PM | 我们之前在需求评审环节踩过的坑...

    原本觉得需求评审也就那么回事儿,大家应该都差不多这么做的,没啥好说的.不过前不久有一位同学问起来我们是怎么做需求评审的,然后发现有一些团队的做法可能还不大一样,他们也还踩着我们之前踩过的坑,他们还在探 ...

  9. 苹果手机打电话没有声音怎么回事_手机打电话听筒没有声音,只有打开免提时才有声音,该怎么办?...

    您可以检查一下手机声音设置是否有问题,是否静音了全局音量:或者看看听筒是不是被手机壳或者是屏幕膜挡住,导致无法出声.以下是详细介绍: 1.首先,可以查看一下手机声音设置是否有问题.有的时候可能在不经意 ...

最新文章

  1. [转载]TFS测试管理
  2. java生成唯一有序序列号_分布式唯一 ID 之 Snowflake 算法
  3. java描边_shape描边设置是否显示四周描边
  4. swift 将图片保存到本地_Swift实现截屏并保存相册
  5. Git版本控制常见操作
  6. c语言指针慕课,C语言指针
  7. Qt4_写TCP客户/服务器应用程序
  8. 分享Silverlight/WPF/Windows Phone/HTML5一周学习导读(2月27日-3月4日)
  9. sql从某行开始获取数据
  10. 基金前端代码和后端代码的区别 基金后端代码和基金前端代码区别
  11. 华为修改优先级命令_华为交换机配置命令---转
  12. *使用phpspider -- PHP蜘蛛爬虫框架来爬取数据
  13. 论文笔记 Inverting Visual Representations with Convolutional Networks
  14. 【论文阅读】中医类药性分析:使用机器学习方法预测类药性
  15. Python分析并绘制可视化动态地图,实时查询全球疫情数据(11月最新...)
  16. IMX6UL系列小屏驱动之像素时钟无法修改
  17. 在Java里面使用Pairs或者二元组
  18. Spring Cloud入门-Admin服务监控中心(Hoxton版本),java高级编程技术
  19. i5 13600K和i5 12600k差距
  20. 插值法位同步 gardner算法

热门文章

  1. python 获取用户ip_Python爬虫教程:你还在苦苦拉票吗?刷票小程序案例原理剖析!...
  2. 通过分离dataSource 让我们的code具有更高的复用性.
  3. JS实现HTML标签转义及反转义
  4. iOS从通讯录中选择联系人
  5. Django web框架
  6. 积极拥抱.NET Core开源社区
  7. Thorntail 2.2.0提供从WildFly Swarm自动迁移的特性
  8. 中国HBase技术社区第一届Meetup资料大合集
  9. 不想被问年终奖?2018年春节自救攻略来了!
  10. hibernate 全面学习【lazy策略 】