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 (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |