博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
快速了解Kubernetes微服务中的通信
阅读量:2541 次
发布时间:2019-05-11

本文共 2676 字,大约阅读时间需要 8 分钟。

by Adam Henson

亚当·汉森(Adam Henson)

快速了解Kubernetes微服务中的通信 (A quick look at communication in Kubernetes microservices)

“服务”概念和一个Node.js示例 (The “service” concept and a Node.js example)

Based on complexity, a layer of microservices can require a variety of communication. Kubernetes provides a rich set of features in managing services, load balancing, and networking.

基于复杂性,微服务层可能需要各种通信。 Kubernetes在管理服务,负载平衡和网络方面提供了丰富的功能。

This post is intended to provide a simple example. For an in-depth overview — see .

这篇文章旨在提供一个简单的示例。 有关深入的概述,请参阅 。

服务 (Services)

A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them - sometimes called a micro-service. ~

甲Kubernetes Service是定义的一组逻辑的抽象Pods和通过该访问它们的策略-有时被称为微服务。

As documented, we have a number of options in exposing and communicating with services. Let’s take a look at Kubernetes DNS. Details about DNS naming can be found .

如记录所示,在服务公开和通信方面,我们有许多选择。 让我们看一下Kubernetes DNS。 有关DNS命名的详细信息,请参见 。

一个简单的例子 (A Simple Example)

Consider a set of microservices that need to communicate with each other through the HTTP protocol. As an example, let’s say we need to create a cron job to ping a health check endpoint from another pod and log the response status code.

考虑一组需要通过HTTP协议相互通信的微服务。 举例来说,假设我们需要创建一个cron作业,以从另一个Pod ping健康检查端点并记录响应状态代码。

We have a Node.js Express app.

我们有一个Node.js Express应用程序。

Fair enough, this app can receive HTTP GET requests to “/healthcheck” and respond with JSON.

公平地说,此应用程序可以接收HTTP GET请求以“ / healthcheck”并以JSON进行响应。

Okay, now let’s create a little cron job app to execute requests to this endpoint at 8:00am every day.

好的,现在让我们创建一个小型cron作业应用程序,以每天8:00 AM执行对此端点的请求。

Very good, very good… nothing out of the ordinary here. Well, wait a minute — let’s take a closer look at the line below which defines the endpoint to fetch.

很好,很好...这里没有什么与众不同的。 好吧,请稍等一下-让我们仔细看看下面的行,该行定义了要提取的端点。

const apiUrl = 'http://api:3000/healthcheck';

In utilizing Kubernetes DNS, communicating with other pods is that simple! Our service configuration for our first app above (the Express app) could be as simple as the below.

在利用Kubernetes DNS时,与其他Pod进行通信就这么简单! 我们上面第一个应用程序(Express应用程序)的服务配置可以像下面这样简单。

Our cron app could look very similar to the above. Configuring pods is out of scope of this post, but you can read about how you could do so utilizing .

我们的cron应用看起来可能与上面的非常相似。 配置pod超出了本文的范围,但是您可以阅读有关如何使用进行 。

结论 (Conclusion)

Kubernetes offers a plethora of features and documentation supporting various means of communication internally and exposure to the outside world. We can get significant mileage simply from DNS.

Kubernetes提供了许多功能和文档,支持内部的各种通信方式以及与外界的接触。 我们可以简单地从DNS中获得可观的里程。

翻译自:

转载地址:http://yvuzd.baihongyu.com/

你可能感兴趣的文章
关于手码编写autolayout约束
查看>>
Java参考资料
查看>>
goto语句
查看>>
简单的车票管理系统
查看>>
2016年10月25 草堂随笔1 ModelState.IsValid
查看>>
Jenkins Pipelines Summary
查看>>
倾斜摄影 实景三维建模软件photoscan教程
查看>>
Actiion Func ;Donet framework 中已经定义好的委托
查看>>
Python 模块之 xlrd (Excel文件读写)
查看>>
再探@font-face及webIcon制作
查看>>
BZOJ.4212.神牛的养成计划(Trie 可持久化Trie)
查看>>
【unityd--初始学习四--3d世界中的物体移动及角度变换】
查看>>
电脑cmos是什么?和bois的区别?
查看>>
REST WCF 使用Stream进行Server与Client交互
查看>>
Python数据分析之Matplotlib绘制柱状图
查看>>
Django组件之contenttype
查看>>
刘江的博客
查看>>
SpringBoot入门教程(二)CentOS部署SpringBoot项目从0到1
查看>>
Unity 2D游戏开发教程之为游戏场景添加多个地面
查看>>
Java日期时间处理
查看>>