Skip to content

Commit b20f296

Browse files
authored
Merge pull request #3343 from camilamacedo86/cherry-pick-project-file
📖 apply changes done in the pr 3287
2 parents a03ee40 + c61141c commit b20f296

File tree

1 file changed

+92
-20
lines changed

1 file changed

+92
-20
lines changed

docs/book/src/reference/project-config.md

Lines changed: 92 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,74 @@
22

33
## Overview
44

5-
The Project Config represents the configuration of a Kubebuilder project. All projects that are scaffolded with the CLI will generate the `PROJECT` file in the projects' root directory.
5+
The Project Config represents the configuration of a KubeBuilder project. All projects that are scaffolded with the CLI (KB version 3.0 and higher) will generate the `PROJECT` file in the projects' root directory. Therefore, it will store all plugins and input data used to generate the project and APIs to better enable plugins to make useful decisions when scaffolding.
6+
7+
## Example
8+
9+
Following is an example of a PROJECT config file which is the result of a project generated with two APIs using the [Deploy Image Plugin][deploy-image-plugin].
10+
11+
```yaml
12+
# Code generated by tool. DO NOT EDIT.
13+
# This file is used to track the info used to scaffold your project
14+
# and allow the plugins properly work.
15+
# More info: https://book.kubebuilder.io/reference/project-config.html
16+
domain: testproject.org
17+
layout:
18+
- go.kubebuilder.io/v4
19+
plugins:
20+
deploy-image.go.kubebuilder.io/v1-alpha:
21+
resources:
22+
- domain: testproject.org
23+
group: example.com
24+
kind: Memcached
25+
options:
26+
containerCommand: memcached,-m=64,-o,modern,-v
27+
containerPort: "11211"
28+
image: memcached:1.4.36-alpine
29+
runAsUser: "1001"
30+
version: v1alpha1
31+
- domain: testproject.org
32+
group: example.com
33+
kind: Busybox
34+
options:
35+
image: busybox:1.28
36+
version: v1alpha1
37+
projectName: project-v4-with-deploy-image
38+
repo: sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image
39+
resources:
40+
- api:
41+
crdVersion: v1
42+
namespaced: true
43+
controller: true
44+
domain: testproject.org
45+
group: example.com
46+
kind: Memcached
47+
path: sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1
48+
version: v1alpha1
49+
webhooks:
50+
validation: true
51+
webhookVersion: v1
52+
- api:
53+
crdVersion: v1
54+
namespaced: true
55+
controller: true
56+
domain: testproject.org
57+
group: example.com
58+
kind: Busybox
59+
path: sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1
60+
version: v1alpha1
61+
version: "3"
62+
```
63+
## Why do we need to store the plugins and data used?
64+
65+
Following some examples of motivations to track the input used:
66+
- check if a plugin can or cannot be scaffolded on top of an existing plugin (i.e.) plugin compatibility while chaining multiple of them together.
67+
- what operations can or cannot be done such as verify if the layout allow API(s) for different groups to be scaffolded for the current configuration or not.
68+
- verify what data can or not be used in the CLI operations such as to ensure that WebHooks can only be created for pre-existent API(s)
69+
70+
Note that KubeBuilder is not only a CLI tool but can also be used as a library to allow users to create their plugins/tools, provide helpers and customizations on top of their existing projects - an example of which is [Operator-SDK][operator-sdk]. SDK leverages KubeBuilder to create plugins to allow users to work with other languages and provide helpers for their users to integrate their projects with, for example, the [Operator Framework solutions/OLM][olm]. You can check the [plugin's documentation][plugins-doc] to know more about creating custom plugins.
71+
72+
Additionally, another motivation for the PROJECT file is to help us to create a feature that allows users to easily upgrade their projects by providing helpers that automatically re-scaffold the project. By having all the required metadata regarding the APIs, their configurations and versions in the PROJECT file. For example, it can be used to automate the process of re-scaffolding while migrating between plugin versions. ([More info][doc-design-helper]).
673
774
## Versioning
875
@@ -15,30 +82,30 @@ The `PROJECT` version `3` layout looks like:
1582
```yaml
1683
domain: testproject.org
1784
layout:
18-
- go.kubebuilder.io/v3
85+
- go.kubebuilder.io/v3
1986
plugins:
2087
declarative.go.kubebuilder.io/v1:
2188
resources:
22-
- domain: testproject.org
23-
group: crew
24-
kind: FirstMate
25-
version: v1
89+
- domain: testproject.org
90+
group: crew
91+
kind: FirstMate
92+
version: v1
2693
projectName: example
2794
repo: sigs.k8s.io/kubebuilder/example
2895
resources:
29-
- api:
30-
crdVersion: v1
31-
namespaced: true
32-
controller: true
33-
domain: testproject.org
34-
group: crew
35-
kind: Captain
36-
path: sigs.k8s.io/kubebuilder/example/api/v1
37-
version: v1
38-
webhooks:
39-
defaulting: true
40-
validation: true
41-
webhookVersion: v1
96+
- api:
97+
crdVersion: v1
98+
namespaced: true
99+
controller: true
100+
domain: testproject.org
101+
group: crew
102+
kind: Captain
103+
path: sigs.k8s.io/kubebuilder/example/api/v1
104+
version: v1
105+
webhooks:
106+
defaulting: true
107+
validation: true
108+
webhookVersion: v1
42109
```
43110

44111
Now let's check its layout fields definition:
@@ -68,4 +135,9 @@ Now let's check its layout fields definition:
68135

69136
[project]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v3/PROJECT
70137
[versioning]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/VERSIONING.md#Versioning
71-
[core-types]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/options.go
138+
[core-types]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/options.go
139+
[deploy-image-plugin]: ../plugins/deploy-image-plugin-v1-alpha.md
140+
[olm]: https://olm.operatorframework.io/
141+
[plugins-doc]: ../plugins/creating-plugins.html#why-use-the-kubebuilder-style
142+
[doc-design-helper]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/designs/helper_to_upgrade_projects_by_rescaffolding.md
143+
[operator-sdk]: https://sdk.operatorframework.io/

0 commit comments

Comments
 (0)