In this post, we will dive into Custom Resource Definition as a way to extends K8S.
在本文中,我们将深入研究“自定义资源定义”,以扩展K8S。
We will first describe the use case of CRD, some hygiene of writing CRD and finally you will learn how to use Java to generate CRD instead of manually editing it.
我们将首先描述CRD的用例,编写CRD的一些习惯,最后您将学习如何使用Java生成CRD而不是手动编辑它。
This post will demonstrate how to implement Controller and CRD using Java to build CRD without YAML, running a custom controller for your CRD and detail on controller implementation step by step.
这篇文章将演示如何使用Java来实现Controller和CRD,以在不使用YAML的情况下构建CRD,并为CRD运行自定义控制器,并逐步介绍控制器的实现细节。
This post will not dive deep if you should use CRD or note, read the great comparison documentation from K8S.
如果您应该使用CRD或笔记,那么这篇文章将不会深入探讨,请阅读K8S的出色比较文档 。
This is an advanced level of information and only needed if you extend K8S, therefore I assume you are familiar with in deep of K8S, how to use K8S Java Client, and understand previous posts: Coding K8S resource in Java Part 1 and Part 2 .
这是高级信息 ,仅在您扩展K8S时才需要,因此,我假设您对K8S熟悉,如何使用K8S Java Client,并了解以前的文章: 在Java Part 1和Part 2中 编码K8S资源 。
All the sample code can be download from the GitHub repo and Gist
什么是自定义资源定义? (What is Custom Resource Definition?)
Most of the time, using K8S with built-in resource is sufficient, all the built-in resources have well structured and comprehensive YAML.
在大多数情况下,将K8S与内置资源一起使用就足够了,所有内置资源都具有结构良好且全面的YAML。
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/2e9fd9b1154e26d5f54538ca04f7faf4.png)
These YAML could be extremely verbose, for example, if you have a MySQL cluster that want to deploy, it will require StatefulSet
, Service
, leader election, loa