当前位置:网站首页>Read the four service types of kubernetes!
Read the four service types of kubernetes!
2022-07-26 20:24:00 【51CTO】


Kubernetes It has become a powerful tool for managing and extending cloud native applications . Organizations need to deploy their software quickly , Maintain zero downtime with highly scalable and always available functionality . As more and more applications are containerized and deployed , Managing these containers in any organization becomes more and more complex . therefore , Scaling becomes a problem . This is it. Kubernetes A place of great splendor . With the help of Kubernetes, You can easily automate 、 Deploy 、 Extend and monitor your application .
If you have read anything about Kubernetes Documentation of services and Networks , You may have encountered ClusterIP、NodePort、LoadBalancer and Ingress Etc . These terms seem to have a lot of confusion , Start building the next one based on Kubernetes Before the application , You must understand the difference .
This article will explain these four Kubernetes The difference between service types , And how to choose the best one for your application .
01
Understand the network requirements of your application
Kubernetes Network and service is a complex topic . You need to understand the requirements of your application to successfully deploy it in Kubernetes On . This means knowing the type of service you want to provide 、 The size and location of the cluster , And what kind of traffic you want your application to receive .
Kubernetes Support four types of services :ClusterIP、NodePort、LoadBalancer and Ingress. Each has its own set of requirements to enable them for your application , Therefore, you must know which one you need before deployment .

for example ,NodePort Allow Pod Mutual communication , Without allocation IP Address . Your Kubernetes The cluster must have at least two nodes to make this type of network communication work properly . Besides ,NodePort Only valid when accessed from within the cluster , and LoadBalancers or Ingress Allow external access . Let's understand how they work one by one .
02
colony IP
ClusterIP Enable multiple in the cluster pod The default service for communication . By default , If you don't define it manually , Your service will be in ClusterIP Go public .ClusterIP Unable to access from the outside . however , have access to Kubernetes Proxy to access your services . This service type is used for internal networks between workloads , At the same time, debug the service 、 Display internal dashboard, etc .
03
Node port
NodePort Is the simplest network type . It does not require configuration , It just routes the traffic on the random port on the host to the random port on the container . This applies in most cases , But it does have some disadvantages :
- You may need to use a reverse proxy ( Such as Nginx) To ensure correct routing Web request .
- Each port can only expose one service .
- Every time Pod Startup time , Containers IP It's going to be different , So it can't be resolved DNS.
- The container cannot be removed from pod External access localhost, Because there is no configuration IP.
however , You can use temporary use cases during experiments ( For example, demo 、POC And internal training ) Use in NodePort, To show how traffic routing works . It is recommended not to use in production NodePort To expose the service .
04
Load Balancer
LoadBalancer yes Kubernetes The most commonly used service type of network . It is a standard load balancer service , At every pod Run on and establish a connection with the outside world , Either with Internet The network is still in your data center .
LoadBalancer Will remain active for pod The connection of is open , And close with the closed pod The connection of . This is similar to when you are AWS Upper ELB or Azure Application gateway on . Upstream HTTP(S) Flow provides the 4 Layer routing , While downstream is HTTP(S) Flow provides the 7 Layer routing .
You can use the target port number 、 Protocol and hostname routing traffic , Or use the application tag . You can send almost any type of traffic to this service type , for example HTTP、TCP、UDP、Grpc etc. . Use this method to expose your services directly .
05
entrance
Ingress Not considered official Kubernetes service , But it can be used to expose Services . You can configure by creating rules Ingress service , To define which inbound connections should reach which services .
Ingress It's a Kubernetes object , It is located in front of multiple services and acts as an intelligent router . It defines how external traffic reaches the cluster service , A set of rules is configured to allow inbound connections to reach services on the cluster .
Entry rules are usually defined by annotations .Ingress The controller reads these comments and configures them accordingly iptables or NGINX. There are many types of Ingress The controller has different functions . You can find the list of entry controllers here .
Ingress Is the most powerful type of service for exposing Services , It only requires you to maintain a load balancer , This is better than using LoadBalancer The type of service is cheap .
This is a simple comparison table , It can help you quickly understand the type of service .
06
Kubernetes
It is a necessary tool for the cloud native world
Kubernetes Automation and management IT Powerful tools for infrastructure . It enables you to group relevant parts of the infrastructure , Provide them with their own “ node ”, Make them easier to manage 、 Monitor and update .
With Kubernetes The adoption rate of has soared , It has become a necessary platform for developers and enterprises to compete in the field of cloud Nativity .
边栏推荐
猜你喜欢

How to build a super interface collaboration platform: count the six weapons of apifox

gospel! Wechat personal official account can be renamed!

Definition and use of one-dimensional array

20220725 tree array introspection

贴合课标新方向 猿辅导打造特色新概念内容体系

Introduction to component functions of blueprism process business object Chapter 3 of RPA

Record an analysis of a.Net property management background service stuck

regular expression

并行执行(二)、multiprocessing

潘多尼亚精灵 VoxEdit 创作大赛
随机推荐
2000字助你精通防抖与节流
AI 技术,让复杂世界简单化 | TeaTalk·Online 应用实战系列第 2 期
如何同步等待多个异步 task 的返回结果 ?
numpy.put()
three. Two methods of making Earth annotation with JS
【ffmpeg】给视频文件添加时间戳 汇总
使用百度飞桨 EasyDL 完成垃圾分类
有点酷,使用 .NET MAUI 探索太空
Using questpdf operation to generate PDF is faster and more efficient!
Cookies and sessions
Meeting seating & submission of meeting OA
解决AttributeError: module ‘win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9‘ has no attribu
一文读懂 Kubernetes的四种服务类型!
The Sandbox 和艺术家 Alec Monopoly 达成合作
贴合课标新方向 猿辅导打造特色新概念内容体系
Intranet penetration learning (II) information collection
go+mysql+redis+vue3简单聊室,第6弹:使用vue3和element-plus调用接口
静音台式风扇芯片-DLTAP703SD-杰力科创
同花顺靠谱吗?我刚开始学习理财,开证券账户安全吗?
Kotlin - 协程构建器 CoroutineBuilder