Menu Close

5.6.2.4. 运行 Operator

您可以使用 Operator SDK CLI 构建和运行 Operator:

  • 作为 Go 程序在集群外本地运行。
  • 作为集群的部署运行。
  • 捆绑 Operator,并使用 Operator Lifecycle Manager(OLM)在集群中部署。
5.6.2.4.1. 在集群外本地运行

您可以作为集群外的 Go 程序运行您的 Operator 项目。这可以加快部署和测试的速度,对于开发非常有用。

流程

  • 运行以下命令,以在 ~/.kube/config 文件中配置的集群中安装自定义资源定义(CRD),并在本地运行 Operator:

    $ make install run

    输出示例

    ...
    {"level":"info","ts":1612652419.9289865,"logger":"controller-runtime.metrics","msg":"metrics server is starting to listen","addr":":8080"}
    {"level":"info","ts":1612652419.9296563,"logger":"helm.controller","msg":"Watching resource","apiVersion":"demo.example.com/v1","kind":"Nginx","namespace":"","reconcilePeriod":"1m0s"}
    {"level":"info","ts":1612652419.929983,"logger":"controller-runtime.manager","msg":"starting metrics server","path":"/metrics"}
    {"level":"info","ts":1612652419.930015,"logger":"controller-runtime.manager.controller.nginx-controller","msg":"Starting EventSource","source":"kind source: demo.example.com/v1, Kind=Nginx"}
    {"level":"info","ts":1612652420.2307851,"logger":"controller-runtime.manager.controller.nginx-controller","msg":"Starting Controller"}
    {"level":"info","ts":1612652420.2309358,"logger":"controller-runtime.manager.controller.nginx-controller","msg":"Starting workers","worker count":8}