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编程
138
6
6.1
准备工作
在本章中我们会继续使用
cnat
这个例子(云原生
at
工具,在“
1.2
一个实际
的例子”中介绍过)来尝试各种不同的方案。如果想跟上这个学习进度,以
下是我们对你的一些要求:
1.
有一个安装好并完成了正确配置的
Go 1.12
或以上版本的开发环境。
2.
一个可用的
Kubernetes
集群,版本在
1.12
或以上。可以是通过
kind
k3d
搭建的本地开发环境,也可以是一个远程的云环境,正确配置了
kubectl
工具,确保可以用它来操作集群。
3.
通过
git clone
下载我们的
GitHub
仓库。下面将要使用的源代码和操作
命令都可以从这个代码仓库中找到。注意,我们在这里描述了如何从零开
始准备一切。如果你只是想看看最后的输出结果而不想自己一步步完成整
个过程,你可以选择
clone
代码仓库并直接运行相关的命令来安装
CRD
安装
CR
,并启动自定义控制器。
完成了这些准备工作,我们可以正式开始编写
Operator
了:在本章中,我们
会依次介绍
sample-controller
Kubebuilder
Operator SDK
准备好了吗?让我们一起出发吧!
6.2
基于
sample-controller
首先我们将基于
k8s.io/sample-controller
来实现
cnat
,通过直接使用
client-
go
完成。
sample-controller
使用
k8s.io/code-generator
来生成强类型的客
户端、
Informer
Lister
和深拷贝函数。如果你的自定义控制器中的 ...
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