Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

feat(helm): initial try at making a helm chart #62

Closed
wants to merge 5 commits into from

Conversation

hutchic
Copy link

@hutchic hutchic commented Jul 15, 2021

related to #46

This is a rough draft of adding a helm chart. Opening as a draft as it will require changes:

  • add a Makefile target that sed's the appVersion and generates hack/templates/hnc-manager.yaml
  • adjust cloudbuild.yml to release the helm chart
  • someone should check my usage of helm hooks is sensible
  • open question -- should hnc-manager.yaml have helm templating forced onto it

@k8s-ci-robot
Copy link
Contributor

Welcome @hutchic!

It looks like this is your first PR to kubernetes-sigs/hierarchical-namespaces 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/hierarchical-namespaces has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @hutchic. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions 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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 15, 2021
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

Instructions 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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 15, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hutchic
To complete the pull request process, please assign srampal after the PR has been reviewed.
You can assign the PR to them by writing /assign @srampal in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 15, 2021
@hutchic hutchic marked this pull request as draft July 15, 2021 17:05
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2021
@hutchic
Copy link
Author

hutchic commented Jul 15, 2021

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 15, 2021
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Thanks for this change! Can you please update the docs/releasing.md file as well to describe what we should do when we're releasing a new version (minor or patch)?

@@ -0,0 +1,62 @@
{{/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of interest, is there a canonical version of this file? If so, it might be useful to link to it in a comment.

Copy link
Author

Choose a reason for hiding this comment

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

this is the current latest that gets generated by helm create chart

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah got it. Maybe add a "Generated by 'helm create chart'" comment unless that'll be overwritten in the future?

@@ -0,0 +1,15 @@
{{- if .Values.serviceAccount.create -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the default SA in the hnc-system directory? That would eliminate this and (I think) the cluster role binding.

Copy link
Author

Choose a reason for hiding this comment

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

that would work but my understanding of the hnc docs is we should/must apply the labels first before installing the controller right? If that's the case we need to pull some things out of band specifically

  • install the sa / rolebinging
  • run the job that adds the label
  • now install the controller et al

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. In that case, can we call it something like hnc-installer so that it's clear what this is for? Ditto for the cluster role binding.

Also, if it's essentially a mandatory part of installing HNC, why are we giving users the option to disable it?

As a side note, you actually can apply the labels after installing HNC, but that will mean that there's a period of time during which the namespaces are not actually excluded. Worse, while HNC is starting up, it may forbid changes to the namespaces, so it could take a while to add the labels. So it's definitely better to label them before installing HNC.

@@ -0,0 +1,721 @@
apiVersion: v1
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of just checking this in by hand, can you please update the makefile to regenerate it? It's ok to check this in (I think Helm requires that it's checked in, right?), but other than committing it, a developer shouldn't have to do something other than (say) make manifests. Otherwise this will quickly drift away from the regular version.

Also, can you please add a comment at the top of this file (automatically inserted, of course) saying something like "Do not edit this file by hand; run 'make manifests' [or whatever] to update."

Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

that's one of the todo items / why it's a draft PR. Wanted some initial feedback before proceeding down the wrong routes :)

Copy link
Author

Choose a reason for hiding this comment

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

So we should discuss what to generate and how.

  1. Helm standards / common practices for example is to split a file like this up such that there's a deployment.yaml file a serviceaccount.yaml file and so on. Is it feasible to do this / do we want this?

  2. Helm provides a mechanism for namespace creation and targetting. So in theory namespace creation shouldn't be part of the helm chart and anywhere there's a namespace defined it should be a variable namespace: {{ .Release.Namespace }}

  3. Helm provides a mechanism for label definition again how challenging will this be technically / how badly do we want or need it ie

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "temp.fullname" . }}
  labels:
    {{- include "temp.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "temp.selectorLabels" . | nindent 6 }}

I'm would prefer incremental improvement so a first pass of "an entire static yaml file is generated" with backlog tickets for further helm-ification would be my personal preference but worth discussing before assuming that route is suitable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! And yes, I'm just giving early feedback, I realize this is a draft.

I'd personally prioritize "ease of automation" over "following all the Helm guidelines" for now. I'd rather have something up-to-date and a little nonstandard than a perfect but obsolete chart.

For deployment.yaml vs serviceaccount.yaml - I think I'd say that if you can generate them from anything in config/ or from the output of kustomize, then go for it. We can also iterate on that - start as a monolithic file and then use something like the Gatekeeper tooling to split it up.

re namespace - I don't think we use the string hnc-system anywhere else, so you could totally add a sed command in the makefile to replace it with {{ .Release.Namespace }}. Note that there might be strings that include hnc-system but that should be pretty easy to check and/or exclude. But I'm totally ok with not doing any of that as well. I think the number of people who would object to hnc-system as well as the other names and labels inside that namespace should be vanishingly small, and I'd be very happy with never adding that flexibility unless someone asks for it and/or is willing to do it themselves.

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not clear on what this is supposed to be. E.g. if we update HNC from v0.8.0 to v0.9.0, should this go from v0.1.0 to v0.2.0?

Copy link
Author

Choose a reason for hiding this comment

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

my understanding which could be incorrect:

  • chart version changes when the helm chart itself changes
  • app version changes when the application itself changes

so appVersion should be part of the release process to auto bump it. I guess chart version bumps handled in the PR template as process(?)

Copy link
Contributor

@adrianludwin adrianludwin Jul 20, 2021

Choose a reason for hiding this comment

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

We don't really have an "auto bump" anywhere but it's fine to just document the process and expect the releaser to follow it. That's what we do for the version numbers in our docs.

As for when we increase the minor vs patch version of the chart, I'm happy to just explain it in the comments right here. E.g.: the chart major/minor/patch versions must increment whenever the corresponding app major/minor/patch version changes, but never needs to be the same as those numbers. For example, if we have chart=0.1.0 and app=0.8.0, and we change the app to 0.9.0, we should change the chart to 0.2.0. But if we change it to 0.8.1, we should change the chart to 0.1.1. In addition, we can increment that chart versions for any other reason at any time.

@@ -0,0 +1,15 @@
{{- if .Values.serviceAccount.create -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. In that case, can we call it something like hnc-installer so that it's clear what this is for? Ditto for the cluster role binding.

Also, if it's essentially a mandatory part of installing HNC, why are we giving users the option to disable it?

As a side note, you actually can apply the labels after installing HNC, but that will mean that there's a period of time during which the namespaces are not actually excluded. Worse, while HNC is starting up, it may forbid changes to the namespaces, so it could take a while to add the labels. So it's definitely better to label them before installing HNC.

Comment on lines 1 to 2
nameOverride: ""
fullnameOverride: ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment these, i.e. what are the default values ("hnc"?) and what do they control?

Copy link
Author

Choose a reason for hiding this comment

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

added a comment. This is the current default that get's provided when one does a helm create which I'll explain in more detail here and you can tell me if the comment is suitable.

helm install 123 . sensible defaults apply and objects get named hnc-123 which is a combination of Chart.yaml name and the release name
helm install --set nameOverride=foo 123 objects get named foo-123
helm install --set fullnameOverride=bar 123 objects get named bar

# If not set and create is true, a name is generated using the fullname template
name: ""

hncIgnoreNamespaces:
Copy link
Contributor

Choose a reason for hiding this comment

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

hncExcludeNamespaces would be better, and you can also point to the right part of the docs in a comment (as you can tell, I'm pretty big on comments!).

However, simply adding a namespace here will not actually exclude the namespace; you'd also have to add the ----excluded-namespace option to the HNC deployment. So maybe it's better to hardcode these for now, unless you want to somehow add it to the Deployment in a template?

Copy link
Author

Choose a reason for hiding this comment

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

renamed.

However, simply adding a namespace here will not actually exclude the namespace

Really? My understanding of the docs was labelling namespaces appropriately would tell the HNC controller to ignore them.

Copy link
Contributor

@adrianludwin adrianludwin Jul 20, 2021

Choose a reason for hiding this comment

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

No, it's a two-step process:

  • Why not just let people add the label to the namespace (after all, this is what Kubernetes itself cares about)? Because if we did, anyone who could edit a namespace could exempt themselves from HNC's oversight simply by adding the label, and we don't want to allow that. As a result, if you try to add this label to any normal namespace, HNC will stop you.
  • Why not just add the namespace to the --exclude-namespace flag, and ask HNC itself to label the namespace on our behalf? Because we don't want HNC to automatically be making changes to critical namespaces like kube-system, and users may not want to give it permission to do so anyway.

As a result, we require both. The admin of HNC needs to say --exclude-namespace, which (now that I think about it) probably should have been called --allow-namespace-exclusion, because it gives us permission to add the label to the namespace. And then, someone with edit access to that namespace needs to actually exclude it. Or, if you haven't installed HNC yet, you can do them in the reverse order.

Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

NB - this is no longer true in the next release. Simply updating --exclude-namespace will be enough.

kind: ""
plural: ""
conditions: []
storedVersions: []
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you drop status: part from CRDs as those make this chart incompatible with https://fleet.rancher.io as it update that part to contains data like:

status:
  acceptedNames:
    kind: HierarchyConfiguration
    listKind: HierarchyConfigurationList
    plural: hierarchyconfigurations
    singular: hierarchyconfiguration
  conditions:
  - lastTransitionTime: "2021-09-09T08:15:55Z"
    message: no conflicts found
    reason: NoConflicts
    status: "True"
    type: NamesAccepted
  - lastTransitionTime: "2021-09-09T08:15:55Z"
    message: the initial names have been accepted
    reason: InitialNamesAccepted
    status: "True"
    type: Established
  storedVersions:
  - v1alpha2

and deployments end up to "Modified" status.

kind: ""
plural: ""
conditions: []
storedVersions: []
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you drop status: from here too.

kind: ""
plural: ""
conditions: []
storedVersions: []
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you drop status: from here too.

@SydMusavi
Copy link

Hi @hutchic
Are you still working on this issue?

@hutchic
Copy link
Author

hutchic commented Nov 24, 2021

@SydMusavi I am not. It was mentioned somewhere on an issue that if someone wishes to take over to feel free.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 22, 2022
@rjbez17
Copy link
Contributor

rjbez17 commented Mar 23, 2022

@adrianludwin looks like this has also been dropped. Shall we close?

@erikgb
Copy link
Contributor

erikgb commented Mar 29, 2022

@adrianludwin looks like this has also been dropped. Shall we close?

I would like to see a Helm chart to install HNC! Any chance someone could pick this up?

@adrianludwin
Copy link
Contributor

adrianludwin commented Mar 29, 2022 via email

@adrianludwin
Copy link
Contributor

I'm going to close this PR, since with the new variant manifests, it's even more infeasible to follow this approach than it was when there was only one. If someone wants to revive the overall idea that's great, but it needs to be automated and based off of the output of make manifests.

/close

@k8s-ci-robot
Copy link
Contributor

@adrianludwin: Closed this PR.

In response to this:

I'm going to close this PR, since with the new variant manifests, it's even more infeasible to follow this approach than it was when there was only one. If someone wants to revive the overall idea that's great, but it needs to be automated and based off of the output of make manifests.

/close

Instructions 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.

@adrianludwin
Copy link
Contributor

adrianludwin commented Oct 11, 2022 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants