gpt4 book ai didi

go - kubectl 如何配置 CRD?

转载 作者:行者123 更新时间:2023-12-01 22:24:21 27 4
gpt4 key购买 nike

我的 kubernetes 集群中已经定义了一些 CRD。kubectl可以很好地创建/更新/删除资源。

当我尝试用程序进行这些操作时,我通过搜索找到的方法是使用以下工具生成代码:

https://github.com/kubernetes/code-generator

我想知道为什么kubectl无需为 CRD 生成代码即可开箱即用。

是否需要生成代码才能添加或删除 CRD 资源?

谢谢!

最佳答案

首先让我们了解一下 CRD 是什么。

The CustomResourceDefinition API resource allows you to define custom resources. Defining a CRD object creates a new custom resource with a name and schema that you specify. The Kubernetes API serves and handles the storage of your custom resource. The name of a CRD object must be a valid DNS subdomain name.

This frees you from writing your own API server to handle the custom resource, but the generic nature of the implementation means you have less flexibility than with API server aggregation.



为什么要创建 Custom Resources :

A resource is an endpoint in the Kubernetes API that stores a collection of API objects of a certain kind. For example, the built-in pods resource contains a collection of Pod objects.

A custom resource is an extension of the Kubernetes API that is not necessarily available in a default Kubernetes installation. It represents a customization of a particular Kubernetes installation. However, many core Kubernetes functions are now built using custom resources, making Kubernetes more modular.

Custom resources can appear and disappear in a running cluster through dynamic registration, and cluster admins can update custom resources independently of the cluster itself. Once a custom resource is installed, users can create and access its objects using kubectl, just as they do for built-in resources like Pods.



因此,要回答您的问题,如果您需要 Kubernetes 中缺少的功能,您需要使用 CRD 自己创建它。没有它,集群将不知道您想要什么以及如何获得它。

如果您正在寻找 Kubernetes Client-go 的使用示例,您可以在官方 GitHub Client-go/examples 上找到它们。

关于go - kubectl 如何配置 CRD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60942796/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com