Repository navigation
Enhance Helm chart and apply best practices - #229
Conversation
|
Hi @unguiculus. Thanks for your PR. I'm waiting for a jetstack member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. DetailsInstructions 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. |
|
Do you have any plans to move the chart to kubernetes/charts? I could create a PR over there or help you get it in quickly if you like (I'm a charts maintainer). I have some questions:
|
|
Hey - thanks for the work on this! Awesome to see. So to answer your questions:
Regarding moving to kubernetes/charts - yes I've been planning on doing it any day now, but need(ed) to clean up the chart first. Once this is cleaned up and up to date, I think we can go ahead and PR it upstream. I'll then update this repo to point to kubernetes/charts for the helm chart. I'll follow up with a review on this PR shortly 😄 |
| apiVersion: v1 | ||
| description: A Helm chart for Kubernetes | ||
| name: cert-manager | ||
| version: 0.1.0 |
There was a problem hiding this comment.
Although we've not properly bumped versions for the chart previously, we definitely should (#223). Maybe this should be 0.2.0? We have made a breaking change to the values.yaml file.
| @@ -1,36 +1,41 @@ | |||
| apiVersion: extensions/v1beta1 | |||
| apiVersion: apps/v1beta1 | |||
There was a problem hiding this comment.
I think we may need another switch here to check if apps/v1beta1 exists before we try and create a resource (in order to support 1.6 deployments)
There was a problem hiding this comment.
| spec: | ||
| serviceAccount: {{ template "fullname" . }} | ||
| serviceAccountName: {{ template "fullname" . }} | ||
| serviceAccountName: {{ if .Values.rbac.create }}{{ template "cert-manager.fullname" . }}{{ else }}"{{ .Values.rbac.serviceAccountName }}"{{ end }} |
There was a problem hiding this comment.
Can we replace "{{ .Values.rbac.serviceAccountName }}" with {{ .Values.rbac.serviceAccountName | quote }}?
There was a problem hiding this comment.
Or alternatively move the quotes to the outside of the if/else/end block?
There was a problem hiding this comment.
Yeah, kinda looks ugly.
| cpu: 10m | ||
| memory: 32Mi | ||
|
|
||
| nodeSelector: {} |
There was a problem hiding this comment.
This isn't used in the actual templates from what I can see
There was a problem hiding this comment.
It is. I was actually there before. That's why you don't see it in the diff. I just added the empty default to values.yaml.
|
|
||
| # Optional additional arguments | ||
| extraArgs: [] | ||
| # - --cluster-resource-namespace=ingress |
There was a problem hiding this comment.
Can we change 'ingress' to 'kube-system'? That is currently our default for this field, and introducing 'new' namespaces could cause confusion 😄
There was a problem hiding this comment.
This was meant as an example. Wouldn't you only set this if you want a different namespace? Maybe we should add a comment making that clear?
| rbac: | ||
| enabled: true | ||
| create: true | ||
| serviceAccountName: default |
There was a problem hiding this comment.
Not sure on best practice here, but are we better off setting this to empty (i.e. whole line commented out) and using the default function within the templates instead to set it to 'default' if not set?
There was a problem hiding this comment.
This is our best practice in the charts repo. We require new charts to do it like this. I think it makes sense. It's always better to have a default in values.yaml, if just for the sake of documentation. The default function should only be used if its not possible to add defaults to values.yaml.
There was a problem hiding this comment.
@unguiculus isn't it better to create a new ServiceAccount for {{ template "cert-manager.fullname" . }} by default rather than apply extra permissions to the default ServiceAccount. The is potentially a permission leak risk to other pods in the same namespace. Hence this should be blank as @munnerz suggests and default to the 'fullname' in the template.
There was a problem hiding this comment.
@whereisaaron This is actually what happens. If rbac.create=true a new servive account {{ template "cert-manager.fullname" . }} is created that gets all the permissions. If you don't use RBAC or want to manage RBAC resources outside the chart, set rbac.create=false. Then by default, the default service acount is used which is fine if you don't use RBAC. You may specify another service account with rbac.serviceAccountName. As mentioned in the readme, rbac.serviceAccountName is ignored if rbac.create=false.
There was a problem hiding this comment.
Thanks for the explanation @unguiculus, according to the Helm best practices documentation rbac.serviceAccountName must not be ignored. Chart authors are supposed to also support the situation where the user has externally managed RBAC resources. For example, let's say in my cluster I have created a Service Account 'foo' associated with the required RBAC roles for cert-manager. I should be able to deploy the chart with:
rbac.create=false
rbac.serviceAccountName="foo"
In this case the chart should not create RBAC resources (Roles etc.), but the Pod resources must be associated with the "foo" Service Account.
rbac.serviceAccountNameshould set the name of the ServiceAccount to be used by access-controlled resources created by the chart. Ifrbac.createis true, then a ServiceAccount with this name should be created. Ifrbac.createis false, then it should not be created, but it should still be associated with the same resources so that manually-created RBAC resources created later that reference it will function correctly. (Note that this effectively makes rbac.serviceAccountName a required value in these charts.)
There was a problem hiding this comment.
Yep I think I agree with @whereisaaron on this one - rbac and serviceAccounts are separate things and it does confuse things when they are conflated. Right now, if rbac.create=true and rbac.serviceAccountName=foo, I would expect no RBAC resources to be created and a service account named foo to not be created and instead used as the serviceAccountName on pods. Namely because I see create as a sort of toggle for the entire block (akin to enabled).
Splitting these two concepts out in the YAML does make this far clearer and disambiguates the two, and with sane defaults the UX is preserved (i.e. rbac.create=true/false behaves in a similar fashion to the current best practices).
There was a problem hiding this comment.
That said, I am keen to follow whatever is decided as best practice. This discussion is basically the blocker for merge now.
From what I can see, if this is accepted #232 can be closed?
There was a problem hiding this comment.
I think we should avoid automatically associating chart-created resources with the default service account as a best practice (basically defaulting to more secure rather than less). It makes it hard to grant permissions to things without granting them to a whole hodgepodge of other things that don't need them. If people want the default service account to be used, they should specify it explicitly.
I guess the remaining question is, is it worth adding the complexity of a new top-level key for service accounts to cover the case of "create RBAC resources that use an existing service account"? Pro: My inner control-freak sysadmin says "yes, that's exactly what you'd do", and it allows creating and using multiple service accounts in a chart. Con: it introduces new failure surface for syntax errors in the values file.
I'll start a discussion over in the Helm project and reference this thread, since this is really a "Helm chart best practices" discussion.
There was a problem hiding this comment.
@omkensey Let's discuss this in the next charts call.
There was a problem hiding this comment.
I think I'd add a layer of key-value abstraction to support multiple service accounts, e.g.:
serviceAccounts:
client:
serviceAccountName: client-account
create: false
server:
serviceAccountName: server-account
create: true
|
@munnerz Not for us - we just want one global one per cluster. |
|
I updated RBAC as discussed in this week's charts call and based on @omkensey's proposal (helm/helm#3320). |
|
@unguiculus PR needs rebase |
* Update Chart.yaml * Make templates namespaced * Update config table in README.md * Apply best practices for RBAC (see https://github.com/kubernetes/helm/blob/master/docs/chart_best_practices/rbac.md) * Add extra args for cert-manager container * Make list indentation consistent * Apply standard labels on all resources * Add some content to NOTES.txt
52f2c90 to
417c428
Compare
417c428 to
8a38db9
Compare
|
@unguiculus I've rebased your PR on the latest changes since we switched our CI. I've also edited your initial PR body with a release note. @whereisaaron does this look okay to you now? If so, I'm going to merge this. It'll go out in the 0.3 release series as it's a breaking change to how cert-manager is deployed for some users. |
|
Thanks @munnerz |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: munnerz The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
|
/test all [submit-queue is verifying that this PR is safe to merge] |
|
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
(see
https://github.com/kubernetes/helm/blob/master/docs/chart_best_practices/rbac.md)