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 more helm custom fields #5622

Merged
merged 43 commits into from
Dec 20, 2022

Conversation

antgamdia
Copy link
Contributor

@antgamdia antgamdia commented Nov 8, 2022

Description of the change

This PR brings more custom fields to the Helm plugin (repos API). Specifically, I've mimicked the currently customizable values through the values.yaml file. That is: tolerations, nodeSelector, securityContext and proxyOptions.
Notwithstanding, users were able to set their custom PodTemplateSpec for the sync job in the old fashion way, but there's too much information to be included as a custom value in the repos API. But why?

Well, since we are generating code from the grpc messages, if we define a pod_template_spec field of type PodTemplateSpec in the grpc proto file.... we need to have the corresponding type defined.
In doing so, there's two alternatives: 1) using an existing definition and importing it using Buf (via BSR) or 2) maintaining ourselves the grpc messages definition.

  • Option 1: almost not viable. There is no official definition in BSR, just one coming from a private company with no guarantees whatsoever. I've explored that way, but I don't feel we should go in this direction. Too risky.
  • Option 2: if we are to maintain the messages, we have two options: 2.1) using the one from Kubernetes or 2.2) defining our own model.
    • Option 2.1: the autogenerated file is huge (=every k8s API object model...) and we would have to ensure we're in sync when a new k8s version is out.
    • Option 2.2: it would require copying a subset of messages from the k8s API, but keeping just those ones we want.

I've gone with option 2.2, but simplifying the fields we support. Just 1 or 2 objects having simple types like string or bool.
I'm adding some PR review messages to highlight what I mean.

That said, I'm open to any other better ideas you may have.

On the other hand, there's a separate issue: what should we display in the Repos UI?
Well, in this case, I've opted for just showing the proxy options. The rest of the fields are just related to the PodTemplateSpec and I feel they are too complex for even advanced users. If someone really wants to tune them up, they can just go an invoke the API.

Benefits

Users will be able to customize the proxy options (along with a few other options) via the repos API instead of just using the chart initialRepos field.

Possible drawbacks

Not every custom field is available through the UI, but I don't really think we want to.

Applicable issues

Additional information

N/A

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
@netlify
Copy link

netlify bot commented Nov 8, 2022

Deploy Preview for kubeapps-dev canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 3f62412
🔍 Latest deploy log https://app.netlify.com/sites/kubeapps-dev/deploys/63a1332056a5920009bfb49b

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Comment on lines 198 to 209

// TODO
ProxyOptions proxy_options = 5;

// TODO
map<string, string> node_selector = 6;

// TODO
repeated Toleration tolerations = 7;

// TODO
PodSecurityContext security_context = 8;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New options for the Helm plugin (repos API)
[will add the description soon, I just wanted to share my approach with you ASAP]

Comment on lines +257 to +272
// Extracted from the K8s API to avoid a dependency on the K8s API
// https://github.com/kubernetes/api/blob/master/core/v1/generated.proto
message PodSecurityContext {
optional int64 run_as_user = 1;
optional int64 run_as_group = 6;
optional bool run_as_non_root = 3;
repeated int64 supplemental_groups = 4;
optional int64 f_s_group = 5;

// TODO(agamez): more complex fields are not supported yet
// optional SELinuxOptions seLinuxOptions = 1;
// optional WindowsSecurityContextOptions windowsOptions = 8;
// repeated Sysctl sysctls = 7;
// optional string fsGroupChangePolicy = 9;
// optional SeccompProfile seccompProfile = 10;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I said in the PR description, I only kept the most simple fields. This is preventing us from importing the whole proto document from k8s.

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

Conflicts:
	cmd/kubeapps-apis/docs/kubeapps-apis.swagger.json
	cmd/kubeapps-apis/gen/plugins/helm/packages/v1alpha1/helm.pb.gw.go
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

Conflicts:
	cmd/kubeapps-apis/docs/kubeapps-apis.swagger.json
	cmd/kubeapps-apis/gen/plugins/helm/packages/v1alpha1/helm.pb.go
	cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/repositories.go
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
@antgamdia antgamdia marked this pull request as ready for review November 21, 2022 17:38
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

LGTM, after a rebase/resolve. Thanks Antonio!

antgamdia and others added 3 commits December 14, 2022 18:06
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

Conflicts:
	chart/kubeapps/README.md
	cmd/kubeapps-apis/docs/kubeapps-apis.swagger.json
Co-authored-by: Michael Nelson <absoludity@gmail.com>
Signed-off-by: Antonio Gámez, PhD <antgamdia@gmail.com>
@absoludity
Copy link
Contributor

I've just merged main again and fixed the conflict. Should be good to land once tests pass.

Signed-off-by: Michael Nelson <minelson@vmware.com>
@absoludity absoludity merged commit 5202eb6 into vmware-tanzu:main Dec 20, 2022
@antgamdia antgamdia deleted the 5128-addMoreHelmFields branch December 18, 2023 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repos API/Helm - Analyze and migrate the former SyncJobTemplate options to the API
3 participants