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

Adopt controller-gen to generate crd manifests and adopt helm v3 way of managing crds #227

Merged
merged 7 commits into from
Aug 25, 2020

Conversation

jiayushe
Copy link
Contributor

@jiayushe jiayushe commented Aug 12, 2020

Change log description

Adopt controller-gen to generate crd manifests and adopt helm v3 way of managing crds

Purpose of the change

  • Clean up management of crd manifests
  • Prevent inconsistency of crd manifests in manual and helm deployments

What the code does

  • Fix minor typo in README and Makefile
  • Fix outdated pkg/apis/zookeeper/v1beta1/zz_generated.deepcopy.go using operator-sdk generate k8s
  • Adopt controller-gen to generate crd manifests, this prevents inconsistency of crd manifests in manual and helm deployments
  • Adopt helm v3 way of managing crds (https://helm.sh/docs/topics/charts/#custom-resource-definitions-crds)

How to verify it

Run make manifests to generate crd manifests in deploy/crds and charts/zookeeper-operator/crds

@jiayushe jiayushe force-pushed the master branch 4 times, most recently from 8350b24 to 5cf9870 Compare August 14, 2020 07:47
@anishakj
Copy link
Contributor

anishakj commented Aug 14, 2020

In the crd generated, all the optional params of the spec are made as required fields. So not able to deploy zookeeper with exitsing helm charts

@jiayushe
Copy link
Contributor Author

Hi @anishakj , thanks for reviewing. Whether a param is optional or required is inferred from the JSON tag in the definition. Since they are optional, I have tagged them as optional in the main code. The generated CRD will not mark them as required now. The test should be passing as well.

@codecov-commenter
Copy link

codecov-commenter commented Aug 21, 2020

Codecov Report

Merging #227 into master will decrease coverage by 1.79%.
The diff coverage is 12.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #227      +/-   ##
==========================================
- Coverage   83.60%   81.81%   -1.80%     
==========================================
  Files          11       11              
  Lines        1220     1248      +28     
==========================================
+ Hits         1020     1021       +1     
- Misses        137      162      +25     
- Partials       63       65       +2     
Impacted Files Coverage Δ
pkg/apis/zookeeper/v1beta1/status.go 100.00% <ø> (ø)
...g/apis/zookeeper/v1beta1/zookeepercluster_types.go 98.30% <ø> (ø)
...kg/apis/zookeeper/v1beta1/zz_generated.deepcopy.go 86.22% <12.90%> (-13.78%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e8f8a3...0be9f31. Read the comment docs.

@anishakj anishakj requested review from SrishT and Prabhaker24 August 21, 2020 11:49
## Whether to create the CRD.
crd:
create: true

## Specifies which namespace(s) the Operator should watch over.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this option is removed. Instead we can add in crd yaml
{{- if .Values.crd.create }}

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 reviewing. I have added back the option.

Ref: https://helm.sh/docs/chart_template_guide/accessing_files/

Copy link
Contributor

@Prabhaker24 Prabhaker24 left a comment

Choose a reason for hiding this comment

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

other than this minor comment this pr LGTM, Thanks @jiayushe for doing this.

@@ -188,8 +188,19 @@ func (s *ZookeeperClusterSpec) withDefaults(z *ZookeeperCluster) (changed bool)
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ZookeeperCluster is the Schema for the zookeeperclusters API
// +k8s:openapi-gen=true
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a comment here specifying below makers comments are for generating crd using kubebuilder ( as we use operator-sdk framework for other things I feel it would be better to mention that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for reviewing.

Copy link
Contributor

@SrishT SrishT left a comment

Choose a reason for hiding this comment

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

Also remove the following section from the values.yaml section of the zookeeper-operator charts, as you had previously done.

crd:	
  create: true

@@ -1,47 +1,6 @@
{{- if .Values.crd.create }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This file addition is unnecessary. I feel u should revert this to your previous change and remove the option for user to specify whether the crd needs to be created from the values.yaml. As per my understanding from this PR :

If a CRD is already found in the cluster, Helm will skip installing that CRD and will log this to the debug log. It will neither error out nor see if there are any differences between its version and the existing version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I will remove it then. I was thinking that this could be used for backward compatibility with helm v2.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have migrated to helm 3 now, and don't plan to support helm 2

Copy link
Contributor

@anishakj anishakj left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@SrishT SrishT left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants