You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h1>If you are using the deprecated layout go/v3</h1>
57
+
Then, your layout has not the internal directory. So, you will move the controller(s) under a directory with the name of the API group which it is responsible for manage.
58
+
```bash
59
+
mkdir controller/batch
60
+
mv controller/* controller/batch/
61
+
```
59
62
60
-
61
-
Next, we'll need to update all the references to the old package name.
62
-
For CronJob, that'll be `main.go` and `controllers/batch/cronjob_controller.go`.
63
+
Next, we'll need to update all the references to the old package name.
64
+
For CronJob, the paths to be replaced would be `main.go` and `controllers/batch/cronjob_controller.go` to their respective locations in the new project structure.
63
65
64
66
If you've added additional files to your project, you'll need to track down
65
67
imports there as well.
66
68
67
-
Finally, we'll run the command which enable the multi-group layout in the project:
69
+
Finally, fix the PROJECT file manually, the command `kubebuilder edit --multigroup=true`
70
+
sets our project to multigroup, but it doesn't fix the path of the existing APIs.
71
+
For each resource we need to modify the path.
68
72
69
-
```
70
-
kubebuilder edit --multigroup=true
71
-
```
73
+
For instance, for a file:
72
74
73
-
When the command `kubebuilder edit --multigroup=true` is executed it will add a new line
74
-
to `PROJECT` that marks this a multi-group project:
75
-
76
75
```yaml
77
-
version: "2"
76
+
# Code generated by tool. DO NOT EDIT.
77
+
# This file is used to track the info used to scaffold your project
78
+
# and allow the plugins properly work.
79
+
# More info: https://book.kubebuilder.io/reference/project-config.html
78
80
domain: tutorial.kubebuilder.io
79
-
repo: tutorial.kubebuilder.io/project
81
+
layout:
82
+
- go.kubebuilder.io/v4
80
83
multigroup: true
84
+
projectName: test
85
+
repo: tutorial.kubebuilder.io/project
86
+
resources:
87
+
- api:
88
+
crdVersion: v1
89
+
namespaced: true
90
+
controller: true
91
+
domain: tutorial.kubebuilder.io
92
+
group: batch
93
+
kind: CronJob
94
+
path: tutorial.kubebuilder.io/project/api/v1beta1
95
+
version: v1beta1
96
+
version: "3"
81
97
```
82
98
83
-
Note that this option indicates to Kubebuilder that this is a multi-group project.
99
+
Replace `path: tutorial.kubebuilder.io/project/api/v1beta1` for
In this process, if the project is not new and has previous implemented APIs they would still need to be modified as needed.
103
+
Notice that with the `multi-group` project the Kind API's files are created under `api/<group>/<version>` instead of `api/<version>`.
104
+
Also, note that the controllers will be created under `internal/controller/<group>` instead of `internal/controller`.
84
105
85
-
In this way, if the project is not new and has previous APIs already implemented will be in the previous structure.
86
-
Notice that with the `multi-group` project the Kind API's files are
87
-
created under `apis/<group>/<version>` instead of `api/<version>`.
88
-
Also, note that the controllers will be created under `controllers/<group>` instead of `controllers`.
89
-
That is the reason why we moved the previously generated APIs with the provided scripts in the previous steps.
90
-
Remember to update the references afterwards.
106
+
That is the reason why we moved the previously generated APIs to their respective locations in the new structure.
107
+
Remember to update the references in imports accordingly.
91
108
92
-
For envtest to install CRDs correctly into the test environment, the relative path to the CRD directory needs to be updated accordingly in each `controllers/<group>/suite_test.go` file. We need to add additional `".."` to our CRD directory relative path as shown below.
109
+
For envtest to install CRDs correctly into the test environment, the relative path to the CRD directory needs to be updated accordingly in each `internal/controller/<group>/suite_test.go` file. We need to add additional `".."` to our CRD directory relative path as shown below.
0 commit comments