KubeBuilder 基础入门指南让你不在迷失方向
|
// Important: Run "make" to regenerate code after modifying this file
// Product 该应用所属的产品 Product string `json:"product,omitempty"` } 修改之后我们执行一下 make manifests generate 可以发现已经生成了相关的字段,并且代码中的字段注释也就是 yaml 文件中的注释 # config/crd/bases/apps.lailin.xyz_applications.yaml ...... properties: product: description: Product 该应用所属的产品 type: string ...... 实现 controllerkubebuilder 已经帮我们实现了 Operator 所需的大部分逻辑,我们只需要在 Reconcile 中实现业务逻辑就行了 // controllers/application_controller.go
func (r *ApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { _ = r.Log.WithValues("application", req.NamespacedName)
r.Log.Info("app changed", "ns", req.Namespace)
return ctrl.Result{}, nil } 逻辑修改好之后,我们先执行 make install 安装 CRD,然后执行 make run运行 controller go run ./main.go (编辑:ASP站长) 【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。 |
-
无相关信息


