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

🌱 Add make commands for CAPI operator #4126

Merged

Conversation

wfernandes
Copy link
Contributor

What this PR does / why we need it:
This PR adds a bunch of make commands for the CAPI operator. It is built on top of the PR #4117.
This PR should be merged after #4117.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #4122
Ref #3833

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 26, 2021
@wfernandes
Copy link
Contributor Author

/hold
Putting this on hold because this PR should be merged in after #4117.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 26, 2021
@wfernandes
Copy link
Contributor Author

/area api
/area operator

@k8s-ci-robot
Copy link
Contributor

@wfernandes: The label(s) area/operator cannot be applied, because the repository doesn't have them

In response to this:

/area api
/area operator

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the area/api Issues or PRs related to the APIs label Jan 26, 2021
@wfernandes wfernandes force-pushed the capi-operator-make branch 2 times, most recently from f065618 to c0c586f Compare January 28, 2021 04:45
@wfernandes
Copy link
Contributor Author

/retest

@vincepri
Copy link
Member

What do you think about having a separate Makefile for the operator in the relative folder and use $(MAKE) -c /path/to/operator to run commands in those?

We should probably do the same for the bootstrap, control plane providers, etc

@wfernandes
Copy link
Contributor Author

Sure. I was just being consistent with what we have now.

I don't mind breaking it up into several Makefiles but can we do that as part of a separate issue. I'm happy to create the issue describing Makefiles for each CAPI component that makes sense.
WDYT?

@wfernandes
Copy link
Contributor Author

/retest

@vincepri
Copy link
Member

vincepri commented Feb 1, 2021

/hold

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 5, 2021
@wfernandes wfernandes marked this pull request as draft February 9, 2021 22:50
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 9, 2021
@wfernandes wfernandes changed the base branch from master to operator-0.4 February 23, 2021 18:21
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 1, 2021
@wfernandes wfernandes marked this pull request as ready for review March 4, 2021 01:46
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 4, 2021
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

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/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 4, 2021
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 10, 2021
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 10, 2021
Makefile Outdated
@@ -237,7 +230,7 @@ generate-go: $(GOBINDATA) ## Runs Go related generate targets
$(MAKE) generate-go-core
$(MAKE) generate-go-kubeadm-bootstrap
$(MAKE) generate-go-kubeadm-control-plane
$(MAKE) generate-go-operator
$(MAKE) -C $(OPERATOR_DIR) generate-go-operator
Copy link
Member

Choose a reason for hiding this comment

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

I think we should not call the operator targets by default.
Let's call them explicitly, like we are doing for CAPD

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the operator is a bit different, don't we plan to ship it the same way as kubeadm stuff?

Copy link
Member

Choose a reason for hiding this comment

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

This makes sense IMO, and it will help identify early issues during manifest generation, when generated resources will overlap between CAPI and CAPIO. CI should handle this part and prevent from PRs being merged if this task fails.

Makefile Outdated
DOCKER_BUILDKIT=1 docker build --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg package=./exp/operator --build-arg ldflags="$(LDFLAGS)" . -t $(OPERATOR_CONTROLLER_IMG)-$(ARCH):$(TAG)
$(MAKE) set-manifest-image MANIFEST_IMG=$(OPERATOR_CONTROLLER_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./exp/operator/config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./exp/operator/config/default/manager_pull_policy.yaml"
$(MAKE) -C $(OPERATOR_DIR) docker-build-operator
Copy link
Member

Choose a reason for hiding this comment

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

this target should go away from the main docker file

Makefile Outdated
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${OPERATOR_CONTROLLER_IMG}:${TAG} ${OPERATOR_CONTROLLER_IMG}-$${arch}:${TAG}; done
docker manifest push --purge $(OPERATOR_CONTROLLER_IMG):$(TAG)
$(MAKE) set-manifest-image MANIFEST_IMG=$(OPERATOR_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./exp/operator/config/default/manager_image_patch.yaml"
$(MAKE) -C "./$(OPERATOR_DIR)/" docker-push-operator-manifest
Copy link
Member

Choose a reason for hiding this comment

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

this target should go away from the main docker file

Makefile Outdated
@@ -315,7 +302,7 @@ generate-manifests: ## Generate manifests e.g. CRD, RBAC etc.
$(MAKE) generate-core-manifests
$(MAKE) generate-kubeadm-bootstrap-manifests
$(MAKE) generate-kubeadm-control-plane-manifests
$(MAKE) generate-operator-manifests
$(MAKE) -C $(OPERATOR_DIR) generate-operator-manifests
Copy link
Member

Choose a reason for hiding this comment

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

same

Makefile Outdated
@@ -546,7 +518,7 @@ release-manifests: $(RELEASE_DIR) $(KUSTOMIZE) ## Builds the manifests to publis
# Build control-plane-components.
$(KUSTOMIZE) build controlplane/kubeadm/config/default > $(RELEASE_DIR)/control-plane-components.yaml
# Build operator components.
$(KUSTOMIZE) build exp/operator/config/default > $(RELEASE_DIR)/operator-components.yaml
$(KUSTOMIZE) build $(OPERATOR_DIR)/config/default > $(RELEASE_DIR)/operator-components.yaml
Copy link
Member

Choose a reason for hiding this comment

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

This should go in the operator make file

Makefile Outdated
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_pull_policy.yaml"
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml"
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE="./exp/operator/config/default/manager_pull_policy.yaml"
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE="./$(OPERATOR_DIR)/config/default/manager_pull_policy.yaml"
Copy link
Member

Choose a reason for hiding this comment

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

This should go in the operator make file

Makefile Outdated
@@ -531,11 +503,11 @@ manifest-modification: # Set the manifest images to the staging/production bucke
TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-image \
MANIFEST_IMG=$(PROD_REGISTRY)/$(OPERATOR_IMAGE_NAME) MANIFEST_TAG=$(RELEASE_TAG) \
TARGET_RESOURCE="./exp/operator/config/default/manager_image_patch.yaml"
TARGET_RESOURCE="./$(OPERATOR_DIR)/config/default/manager_image_patch.yaml"
Copy link
Member

Choose a reason for hiding this comment

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

This should go in the operator make file

Copy link
Contributor

Choose a reason for hiding this comment

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

My idea was to reuse targets like set-manifest-image instead of duplicating them across Makefiles. Another approach might be a Makefile that has all common targets and this Makefile is then included in all others.

@alexander-demicev alexander-demicev force-pushed the capi-operator-make branch 2 times, most recently from a7cd7eb to 9972a59 Compare March 10, 2021 14:04
Makefile Outdated
@@ -237,7 +230,7 @@ generate-go: $(GOBINDATA) ## Runs Go related generate targets
$(MAKE) generate-go-core
$(MAKE) generate-go-kubeadm-bootstrap
$(MAKE) generate-go-kubeadm-control-plane
$(MAKE) generate-go-operator
$(MAKE) -C $(OPERATOR_DIR) generate-go-operator
Copy link
Member

Choose a reason for hiding this comment

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

This makes sense IMO, and it will help identify early issues during manifest generation, when generated resources will overlap between CAPI and CAPIO. CI should handle this part and prevent from PRs being merged if this task fails.

Makefile Outdated
@@ -405,6 +415,7 @@ docker-push-all: $(addprefix docker-push-,$(ALL_ARCH))
$(MAKE) docker-push-core-manifest
$(MAKE) docker-push-kubeadm-bootstrap-manifest
$(MAKE) docker-push-kubeadm-control-plane-manifest
$(MAKE) docker-push-operator-manifest
Copy link
Member

Choose a reason for hiding this comment

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

I would argue that this task should be independent from core Makefile. Until the operator is experimental, default push command should accidentally create new images in release.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 10, 2021
@alexander-demicev
Copy link
Contributor

A small recap:

  • Added a separate Makefile for the operator(similar to CAPD) and separated the PR into meaningful commits.
  • Added context to Reconcile() arguments and removed zap logger from test. Without these 2 changes, the project fails to build.
  • Couple of other minor changes.

Copy link
Contributor

@MarcelMue MarcelMue left a comment

Choose a reason for hiding this comment

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

I would like to go forward with this for now. We will have an easier time iterating then.

@fabriziopandini
Copy link
Member

+1 to get this moving.
Please squash commits

Rebased and fix version pkg path

Remove zap logger

Remove .gitignore, Dockerfile and modules files

Add context to reconciler arguments

Add test tasks for operator

Add binary building tasks for operator

Add linting tasks for operator

Add generate tasks for operator

Add Docker tasks for operator

Add release command for operator

Add cleanup tasks for operator

Make operator more consistent with other projects
@MarcelMue
Copy link
Contributor

Good to go from my side

/LGTM

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 12, 2021
@CecileRobertMichon
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

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 Mar 12, 2021
@k8s-ci-robot k8s-ci-robot merged commit 337ea36 into kubernetes-sigs:operator-0.4 Mar 12, 2021
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create make commands for the operator
8 participants