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

Support to override helm release name #1682

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Support to override helm release name #1682

merged 1 commit into from
Jun 6, 2019

Conversation

lcostea
Copy link
Member

@lcostea lcostea commented Jun 4, 2019

Description of the change

Field releaseName added to the application crd under helm
On the cli the flag is release-name
Unit tests to check release name is overriden

Benefits

When working with a centralised ArgoCD, the application names will have names based on cluster names and this will make the resources deployed not to be identical in different clusters. For example a redis service will have different names on different clusters because of different release names which will make it hard to be identified. This feature allows the release name to be overridden, so it will not be connected to the application name.

Closes #1066

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

This looks good, great unit tests.

I'd like to understand what happens when you change the name of the release. I think that @jessesuen mentions this in the original issue.

Can I ask for an e2e test (test/e2e/helm_test.go)?

Alex

@@ -113,6 +113,8 @@ type ApplicationSourceHelm struct {
ValueFiles []string `json:"valueFiles,omitempty" protobuf:"bytes,1,opt,name=valueFiles"`
// Parameters are parameters to the helm template
Parameters []HelmParameter `json:"parameters,omitempty" protobuf:"bytes,2,opt,name=parameters"`
// The Helm release name. If omitted it will use the application name
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@@ -124,7 +126,7 @@ type HelmParameter struct {
}

func (h *ApplicationSourceHelm) IsZero() bool {
return len(h.ValueFiles) == 0 && len(h.Parameters) == 0
return (h.ReleaseName == "") && len(h.ValueFiles) == 0 && len(h.Parameters) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

good work - easy to overlook

@lcostea
Copy link
Member Author

lcostea commented Jun 4, 2019

@alexec Regarding the change of the release name, because argo-cd now injects the label: app.kubernetes.io/instance=<<application_name>> this would cause a problem when application name will be different than release name (if we override it) and the chart uses this label for a selector.

An example would be the sealed-secret chart from helm/stable. Their deployment uses the app.kubernetes.io/instance: {{ .Release.Name }} as a selector for pods, while if argo-cd will overwrite it with the application name, when the application name will be different than the release name then the selector will stop working. And of course this can lead to big problems, like when upgrading.

A possible fix would be to use a different label for argo-cd, like it was used before the PR 857.
Another one would be not to allow to override release name when the chart uses the app.kubernetes.io/instance and to write some warning - that's what @jessesuen was mentioning.

So I can add the e2e test, but I guess we need to decide for the additional fix first.

@alexec
Copy link
Contributor

alexec commented Jun 5, 2019

I've approved, but you need to resolve the merge conflict.

I think users would appreciate a paragraph or tow /docs/user-guide-helm.md to document this behavior and how to use it with the flag @jessesuen mention.

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

Needs git merge master. Also docs.

@jessesuen
Copy link
Member

Please read my comments about the error detection here:
#1066 (comment)

Basically, I think we either need to have chart dependent erroring, or we don't error at all.

Field releaseName added to the application crd
On the cli the flag is release-name
Unit tests to check release name is overriden
@lcostea
Copy link
Member Author

lcostea commented Jun 6, 2019

@alexec
I solved the conflicts and added docs to the /docs/user-guide/helm.md including how to change the tracking label.
No additional error handling was added.

@lcostea
Copy link
Member Author

lcostea commented Jun 6, 2019

Is the fact that codegen is failing a problem? I did add the releaseName under helm, so there are changes to the crds and protobuf. But I also saw some additional changes after I ran make codegen to the yaml, that weren't affected by the releaseName addition.

I checked the contributing guide, but that didn't mention if we should run the codegen part on PRs or not.

```

```diff
- Important notice on overriding the release name
Copy link
Contributor

Choose a reason for hiding this comment

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

minor - you can use a !!! warning admonition block here, see https://squidfunk.github.io/mkdocs-material/extensions/admonition/

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure admonition extension works on Github, I just tried on a separate repo to display an warning and it didn't work. Maybe I am missing something?

```diff
- Important notice on overriding the release name
```
Please not that overriding the Helm release name might cause problems when the chart you are deploying is using the `app.kubernetes.io/instance` label.
Copy link
Contributor

Choose a reason for hiding this comment

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

great stuff

@@ -123,3 +123,39 @@ func TestHelmDependencyBuild(t *testing.T) {
_, err = h.Template("wordpress", "", nil)
assert.NoError(t, err)
}

func TestHelmTemplateReleaseNameOverwrite(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

excellent

@alexec
Copy link
Contributor

alexec commented Jun 6, 2019

I should update the PR template.

You should run make pre-commit before push (ok it should probably be called pre-push :) ) . That runs code-gen, tests, and linting. One problem can be that you need the exact correct versions of the various tools. These are printed in the CircleCI job.

This has been a pain for other people, so let me know that' the, and I'll take 15m to sort it out for you.

@lcostea
Copy link
Member Author

lcostea commented Jun 6, 2019

Yes, it could be the versions of those tools.

On the other hand I was looking at that codegen step that fails and it is somehow normal because I did add the releaseName parameter that went into assets/swagger.json

What is not normal and I don't understand yet is why both yaml crd have so many changes and this might be because of tool versions. Here I am still checking the versions in the CI and compare with what I have.

On the pkg/apis/api-rules/violation_exceptions.list seems that it should not be modified, so I will revert that.

@alexec alexec merged commit 8275200 into argoproj:master Jun 6, 2019
@alexec
Copy link
Contributor

alexec commented Jun 6, 2019

I've merged and I'll fix quickly locally.

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.

Make it possible to set release name different from argcd app name.
3 participants