operator-sdk add controller

operator-sdk add controller

Adds a new controller pkg

Synopsis

Add a new controller package to your operator project.

This command creates a new controller package under pkg/controller/ that, by default, reconciles on a custom resource for the specified apiversion and kind. The controller will expect to use the custom resource type that should already be defined under pkg/apis// via the “operator-sdk add api” command.

Note that, if the controller pkg for that Kind already exists at pkg/controller/ then the command will not overwrite and return an error.

This command MUST be run from the project root directory.

  1. operator-sdk add controller [flags]

Examples

  1. The following example will create a controller to manage, watch and reconcile as primary resource the <v1.AppService> from the domain <app.example.com>.
  2. Example:
  3. $ operator-sdk add controller --api-version=app.example.com/v1 --kind=AppService
  4. $ tree pkg/controller
  5. pkg/controller/
  6. ├── add_appservice.go
  7. ├── appservice
  8. └── appservice_controller.go
  9. └── controller.go
  10. The following example will create a controller to manage, watch and reconcile as a primary resource the <v1.Deployment> from the domain <k8s.io.api>, which is not defined in the project (external). Note that, it can be used to create controllers for any External API.
  11. Example:
  12. $ operator-sdk add controller --api-version=k8s.io.api/v1 --kind=Deployment --custom-api-import=k8s.io/api/apps
  13. $ tree pkg/controller
  14. pkg/controller/
  15. ├── add_deployment.go
  16. ├── deployment
  17. └── deployment_controller.go
  18. └── controller.go

Options

  1. --api-version string Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)
  2. --custom-api-import string The External API import path of the form "host.com/repo/path[=import_identifier]" Note that import_identifier is optional. ( E.g. --custom-api-import=k8s.io/api/apps )
  3. -h, --help help for controller
  4. --kind string Kubernetes resource Kind name. (e.g AppService)

SEE ALSO

Last modified January 1, 0001