Project Layout

A description of the layout of projects built with Operator SDK

Operator SDK Project Layout

All projects initialized with operator-sdk init have a common base structure which builds on kubebuilder’s project layout. Each project type is customized further with code of that type’s language.

Common Base

The common structure contains the following items:

File/DirectoryDescription
DockerfileThe Dockerfile of your operator project, used to build the image with make docker-build.
MakefileBuild file with helper targets to help you work with your project.
PROJECTThis file represents the project’s configuration and is used to track useful information for the CLI and plugins.
bin/This directory contains useful binaries such as the manager which is used to run your project locally and the kustomize utility used for the project configuration. For other language types, it might have other binaries useful for developing your operator.
bundle/This directory contains all the files used to integrate your project with OLM with the bundle format. It is built from the Makefile target make bundle.
bundle/manifests/This directory has the OLM manifests of your bundle.
bundle/metadata/This directory has the OLM metadata of your bundle e.g the index image annotations.
bundle/tests/This directory has the Scorecard tests shipped with your operator bundle.
config/Contains configuration files to launch your project on a cluster. Plugins might use it to provide functionality. For example, for the CLI to help create your operator bundle it will look for the CRD’s and CR’s which are scaffolded in this directory. You will also find all Kustomize YAML definitions as well.
config/crd/Contains the Custom Resources Definitions.
config/default/Contains a Kustomize base for launching the controller in a standard configuration.
config/manager/Contains the manifests to launch your operator project as pods on the cluster.
config/manifests/Contains the base to generate your OLM manifests in the bundle directory.
config/prometheus/Contains the manifests required to enable project to serve metrics to Prometheus such as the ServiceMonitor resource.
config/scorecard/Contains the manifests required to allow you test your project with Scorecard.
config/rbac/Contains the RBAC permissions required to run your project.
config/samples/Contains the Custom Resources.
bundle.DockerfileThe Dockerfile to build the bundle image. Used to build the operator bundle image with `make bundle-build. |

Ansible

Now, let’s look at the files and directories specific to Ansible-based operators.

File/DirectoryDescription
config/testing/Manifest files to help you test your project. For example, to change the image policy for your Molecule tests or to enable debug level in the Ansible logs.
molecule/Contain the manifests for your Molecule tests.
molecule/defaultContains the default Molecule task.
molecule/kindContains the Molecule task to be executed on the cluster.
playbooks/Contains the Ansible playbooks.
roles/Contains the Ansible role files for each Kind scaffold.
requirements.ymlThis file specifies Ansible dependencies that need to be installed for your operator to function.
watches.yamlContains Group, Version, Kind, and the playbooks and rules location. Used to configure the Ansible watches.

Golang

Now, let’s look at the files and directories specific to Go-based operators.

File/DirectoryDescription
api/Contains the api definition
config/certmanagerContains the Kustomize manifests which configure the cert-manager by the Webhooks.
config/webhookContains the Kustomize manifests to configure the Webhook.
controllersContains the controllers.
main.goImplements the project initialization.
hack/Contains utility files, e.g. the file used to scaffold the license header for your project files.

Helm

Now, let’s look at the files and directories specific to Helm-based operators.

File/DirectoryDescription
helm-chartsContains the Helm charts for each Kind scaffold which can be initialized with operator-sdk init —plugins=helm [options] or operator-sdk create api [options] .
watches.yamlContains Group, Version, Kind, and Helm chart location. Used to configure the Helm watches.

Last modified June 23, 2021: reorganze scorecard documentation (#5007) (60bfe2eb)