Add .create and .name to serviceAccount config, and decouple rbac.enable from the service accounts#2736
Conversation
|
Thanks for submitting your first pull request! You are awesome! 🤗 |
|
So seems the CI pipeline adds some commits, but I think a squash merge of this PR should fix that. Please let me know if you'd prefer I rebase+force push the branch with the auto-fixes squashed into one commit. |
|
Wiee hey @dingobar, thanks for working on this topic! You can pull and manually fixup/squash the formatting commits if you want, but you can also leave them in. I use pre-commit locally to ensure my commits are formatted locally overall, for notes on how to do that see the notes in the .pre-commit-config.yaml file. I've added a lengthier note about the kind of changes I think makes sense to bundle in a single PR in #2691 (comment). What do you think about expanding this PR a bit to include what's described there? |
| {{- $autoHTTPS := (and $HTTPS (eq .Values.proxy.https.type "letsencrypt")) }} | ||
| {{- if (and $autoHTTPS .Values.rbac.enabled) -}} | ||
| {{- if $autoHTTPS -}} | ||
| {{- if .Values.proxy.traefik.serviceAccount.create }} |
There was a problem hiding this comment.
The - to the right and left of the {{ and }} are related to "whitespace chomping".
A rule of thumb to avoid rendering surplus new lines etc we've tried to follow is:
- Always whitespace chomp left
- Never whitespace chomp right, except for when it's before any previous content has been rendered in the template, then always whitespace chomp right as well.
For this line, we should also whitespace chomp right to follow that rule. It is not going to make things break etc, but it makes the output contain less surplus new lines when rendering it.
There was a problem hiding this comment.
I've implemented this across all rbac.yaml and serviceaccount.yaml files.
84f6f20 to
63112f4
Compare
|
@consideRatio I've implemented the changes now, so that a custom
Known limitations/considerations:
Turned out that quite a few changes were necessary to get this far so will pause here for some feedback. |
|
Thanks for documenting your work so clearly @dingobar!! Various config combinations seems okI'm considering various combinations of these configurations. I was a bit surprised about the idea of creating a SA with a specified name, but yeah - that is probably reasonable. Those that wants to specify an existing SA, which is something I think people have wanted historically, can would then set
These options seems fine to me. I considered if we should add logic to error loudly if this is configured to the broken configuration state, but I think such validation logic in the schema.yaml file, or having a conditional Change request 1Users will need to be allowed to specify a SA without the helm chart creating one. Due to that, I suggest that the following changes are made. # from pod specifications where we specify serviceAccountName
- {{- if .Values.hub.serviceAccount.create }}
- serviceAccountName: {{ include "jupyterhub.hub-serviceaccount.fullname" . }}
+ {{- with include "jupyterhub.hub-serviceaccount.fullname" . }}
+ serviceAccountName: {{ . }}
{{- end }}# from _helpers-names.tpl
{{- define "jupyterhub.hub-serviceaccount.fullname" -}}
- {{- .Values.hub.serviceAccount.name | default (include "jupyterhub.hub.fullname" .) }}
+ {{- if .Values.hub.serviceAccount.name }}
+ {{- .Values.hub.serviceAccount.name }}
+ {{- else if .Values.hub.serviceAccount.create }}
+ {{- include "jupyterhub.hub.fullname" . }}
+ {{- end }}
{{- end }}Change request 2There is a section you can find by searching for Change request 3All resources in this helm chart skip the leading |
desaintmartin
left a comment
There was a problem hiding this comment.
We collided on this one, I've just made #2737 that has just been closed, here are my comments from the work I've done.
|
|
||
| {{- /* hub-serviceaccount ServiceAccount */}} | ||
| {{- define "jupyterhub.hub-serviceaccount.fullname" -}} | ||
| {{- .Values.hub.serviceAccount.name | default (include "jupyterhub.hub.fullname" .) }} |
There was a problem hiding this comment.
| {{- .Values.hub.serviceAccount.name | default (include "jupyterhub.hub.fullname" .) }} | |
| {{- if .Values.hub.serviceAccount.create -}} | |
| {{ default (include "jupyterhub.hub.fullname" .) .Values.hub.serviceAccount.name }} | |
| {{- else -}} | |
| {{ default "default" .Values.hub.serviceAccount.name }} | |
| {{- end -}} |
As it is done in helm boilerplate?
There was a problem hiding this comment.
This change includes two parts of relevance:
- serviceAccountName is always set, even when
.createis false and.nameis unspecified. - Style change, writing
default <default value> <primary value>instead of<primary value> | default <default value>. - Style change, whitespace chomping practices
I don't want to accept the style changes as they are consistent across the Helm chart in a manner, but I think its acceptable to agree on the change 1 as it reduces the complexity of our template logic, making it easier to read.
@dingobar I'll let you decide about 1 as you also would be the person to do the work and I find both options fine.
There was a problem hiding this comment.
While I see the original functionality good and easy to understand, I buy the argument that since the default helm-chart base also sets "default" as the serviceAccount in the pods we should also do it.
This feature introduces a new `.serviceAccount.create` for all `ServiceAccount` resources, which defaults to `true`. BREAKING CHANGE: This is a breaking change for all users with `rbac.enabled` set to `false`.
63112f4 to
8ebe8bc
Compare
I believe these changes are implemented now. @desaintmartin I'm not able to re-request a review from you but feel free. |
This allows the user to set the name of the serviceAccounts that are created If no name is given, the default is the deployment (or job) name for the respective account
…count.name is provided
8ebe8bc to
cd68204
Compare
|
I've included the last CRs now. Hopefully we can merge this now. |
|
Thank you @dingobar and @desaintmartin for your work on this!!!!!! ❤️ 🎉 🌻 |
jupyterhub/zero-to-jupyterhub-k8s#2736 Merge pull request #2736 from dingobar/feature/allow-creating-service-account-and-not-roles
serviceAccount.create.create and .name to serviceAccount config, and decouple rbac.enable from the service accounts


This feature introduces a new
.serviceAccount.createfor allServiceAccountresources, which defaults totrue. This is a breakingchange for all users with
rbac.enabledset tofalse, as these users will get some ServiceAccount resources created where they previously ran as the default user.For context, please see the discussion at #2691 .
The use-case for this feature is to allow users who use
rbac.enabled=falseto provisionserviceAccountswithout rbac resources likeRoleandRoleBinding. It also limits therbac.enabledto only refer to resources that relate to the actual rbac API in kubernetes.