Change directory structure for operator-sdk (Kubernetes) generated project

6/18/2021

By default operator-sdk generates folder structure as following

root_folder

   |- api
   |- config
   |-   |-  crd
   |-   |-  default
   |-   |-  manager
   |-   |-  ..
   |- controllers
   |- hack

some folders have been omitted for brevity.

What I am looking for is how to modify this folder structure and configure operator sdk to honor that folder structure.

So say I want to rename config to cmd, how to achieve this when using operator-sdk

-- rushidesai1
kubernetes
operator-sdk

1 Answer

6/18/2021

You kind of can't. Some stuff is based on special comments and will mostly work no matter the layout but the further you deviate from the default layout, the more of the scaffolding won't work for you in the future.

That said, you can just do whatever you want and not use OSDK again. The underlying Go libraries (controller-runtime, controller-tools) mostly don't care about layouts and it's your software so you can do whatever.

-- coderanger
Source: StackOverflow