Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📖 (doc): getting started: fix information about make command for generating manifests #4306

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

vtrenton
Copy link
Contributor

@vtrenton vtrenton commented Nov 8, 2024

make generate does not generate the CRDs in config/crd/base the correct command to accomplish this is make manifests. See Makefile:

generate: controller-gen  ## Generate code (deepcopy)
	$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

manifests: controller-gen  ## Generate manifests (CRDs, RBAC, etc.)
	$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

fixes: #4305

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 8, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @vtrenton!

It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubebuilder has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 8, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @vtrenton. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@vtrenton
Copy link
Contributor Author

vtrenton commented Nov 8, 2024

Also fixed a simple yam -> yaml in the same section.

@@ -125,10 +125,10 @@ Now, see our example fully completed.

#### Generating manifests with the specs and validations

To generate the required CRDs we will run `make generate` command, which will call [controller-gen][controller-gen]
To generate the required CRDs we will run `make manifests` command, which will call [controller-gen][controller-gen]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we need the macke generate right?
Since we changed the spec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick response!
make generate doesn't seem to do what this is saying this will do... Sorry very new to kubebuilder so I could be doing something wrong here:

(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ tree config/crd/
config/crd/
├── kustomization.yaml
└── kustomizeconfig.yaml

1 directory, 2 files
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ make generate
/home/trent/Source/kubebuilder-demo/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ tree config/crd/
config/crd/
├── kustomization.yaml
└── kustomizeconfig.yaml

1 directory, 2 files
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ make manifests
/home/trent/Source/kubebuilder-demo/memcached-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ tree config/crd/
config/crd/
├── bases
│   └── cache.example.com_memcacheds.yaml
├── kustomization.yaml
└── kustomizeconfig.yaml

2 directories, 3 files

just following along with the docs and running into this issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh I see what you're saying - we need both commands I expect. that's a great point! let me see if I can come up with something more clean than make generate && make manifests

Copy link
Member

@camilamacedo86 camilamacedo86 Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes both.

maybe:

To generate the required CRDs we will run make generate command to generate ... and make manisftes to generate the manifests under .... , which will call [controller-gen][controller-gen]

Something like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess make build would be the "one-shot" do everything approach but it looks like I don't need to run make generate before running make manifests if my goal is generating manifest.

(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ ls config/crd/
kustomization.yaml  kustomizeconfig.yaml
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ ls api/v1alpha1/
groupversion_info.go  memcached_types.go
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ make manifests
/home/trent/Source/kubebuilder-demo/memcached-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $ ls -al config/crd/bases/
total 16
drwxr-xr-x 2 trent users 4096 Nov  8 12:37 .
drwxr-xr-x 3 trent users 4096 Nov  8 12:37 ..
-rw-r--r-- 1 trent users 4921 Nov  8 12:37 cache.example.com_memcacheds.yaml
(.venv) (devbox) [trent@Krum:~/Source/kubebuilder-demo/memcached-operator] [master] $

probably still need to run make generate at some point to generate the deep copy stuff...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To generate all required files, run make generate to create the DeepCopy implementations in api/v1alpha1/zz_generated.deepcopy.go, followed by make manifests to generate the CRD manifests under config/crd/bases. Both commands use [controller-gen][controller-gen] with different flags for code and manifest generation respectively.

does that wording sound OK? just want to make sure i'm not missing anything critical before making another commit - updating. Thanks for your help! I haven't read too far ahead in the docs yet so i'm not sure how verbose vs concise the wording should be!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes
I loved. Just a tiny refinement :-)

To generate all required files:

1. Run `make generate` to create the DeepCopy implementations in `api/v1alpha1/zz_generated.deepcopy.go`.

2. Then, run `make manifests` to generate the CRD manifests under `config/crd/bases` and a sample for it under `config/crd/samples`.

Both commands use [controller-gen][controller-gen] with different flags for code and manifest generation, respectively.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh that is a wonderful callout in reguards to the sample dir as well!

That is perfect - thanks a bunch for the help, I've commited the changes!

to generate the CRD manifest, which is located under the `config/crd/bases` directory.

<details><summary><code>config/crd/bases/cache.example.com_memcacheds.yam</code>: Our Memcached CRD</summary>
<details><summary><code>config/crd/bases/cache.example.com_memcacheds.yaml</code>: Our Memcached CRD</summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 8, 2024
@camilamacedo86 camilamacedo86 changed the title fix make command for generating manifests 📖 (doc): getting started fix information about make command for generating manifests Nov 9, 2024
@camilamacedo86 camilamacedo86 changed the title 📖 (doc): getting started fix information about make command for generating manifests 📖 (doc): getting started: fix information about make command for generating manifests Nov 9, 2024
@camilamacedo86
Copy link
Member

Hi @vtrenton

It is all fine now. Really thank you for the contribution 🥇
Just one nit. For we are able to merge all changes need to be in one commit.
Can you please squash the commit?

@vtrenton
Copy link
Contributor Author

vtrenton commented Nov 9, 2024

Thanks @camilamacedo86
commits have been squashed. Please let me know if anything else is needed!

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🥇

/approved
/lgtm
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 9, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, vtrenton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 9, 2024
@k8s-ci-robot k8s-ci-robot merged commit d79cfa6 into kubernetes-sigs:master Nov 9, 2024
10 checks passed
@vtrenton vtrenton deleted the make-generate-fix branch November 9, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Incorrect make command
3 participants