Skip to Content
Kubernetes编程
book

Kubernetes编程

by Michael Hausenblas, Stefan Schimanski
June 2021
Intermediate to advanced
335 pages
5h 50m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes编程
client-go
基础
75
平滑退出与从连接出错状态恢复
请求可以分为长期运行和非长期运行两种。
Watch
属于长期运行的请求,
GET
LIST
UPDATE
等请求则是非长期运行的。很多子资源(比如:
流式日志、执行命令、端口映射等)也是长期运行的。
Kubernetes API
服务器重启的时候(比如,进行一次升级),它最长
会等待
60
秒以便可以平滑地退出。在这段时间中,它会完成所有非长期
运行的请求,然后再退出。当它退出时,所有的长期运行请求(比如正
在使用的
Watch
连接)都会被中断。
非长期运行的请求运行时间的上限是
60
秒(然后就会超时)。所以,从
客户端的角度来看,这样的退出过程是平滑的。
通常来说,应用程序的代码应该能正确处理失败的请求,并确保不会对
应用程序造成严重的后果。在分布式系统中,连接发生出错是非常正常
的错误,所以不需要为此担心。但是还是需要特别注意去正确处理出错
的情况,并能从出错的状态中恢复到正常状态。
出错处理对于
Watch
来说尤其重要。
Watch
是长期运行的请求,但是他
们随时可能出错。下一节即将介绍的
Informer
提供了对
Watch
的一个可
靠的封装,能正确处理各种出错,也就是说,当连接中断时,它可以创
建一个新连接并恢复到正常的工作状态中。应用程序甚至不会发现连接
曾经发生过中断。
3.4 Informer
和缓存
上一节中介绍的客户端接口中包含一个名为
Watch
的动作,它提供了对集群
对象变化(添加、删除或更新)进行响应的接口。
Informer
Watch
的基础
上对常见的使用场景提供了一个更高层的编程接口 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu
软件开发实践:项目驱动式的Java开发指南

软件开发实践:项目驱动式的Java开发指南

Raoul-Gabriel Urma, Richard Warburton

Publisher Resources

ISBN: 9787519854799