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

Helm Chart for HNC installation #354

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

mochizuki875
Copy link
Member

@mochizuki875 mochizuki875 commented Jan 23, 2024

What type of PR is this?:

/kind feature

What this PR does / why we need it:

Provide HNC installation method via Helm.

Previously, it was disccussed in #46 and #62.
However, the problem that how to keep the chart up-to-date with changes in the config directory has not been resolved.
In this PR, I've added a mechanism to auto generate chart from manifest file generated from config directory using kustomize.

How to use:

Clone this repository.

$ git clone https://github.com/mochizuki875/hierarchical-namespaces.git -b feature_hnc_helm

Set environment variables.
They will be actually set in release process.

$ export HNC_REGISTRY=gcr.io/k8s-staging-multitenancy
$ export HNC_IMG_NAME=hnc-manager
$ export HNC_IMG_TAG=<HNC Version, eg v1.1.0>

Generate chart.

$ make charts

Install chart.
You can do any setting in charts/hnc/values.yaml before installation.
eg: setting hncExcludeNamespaces, enable HRQ, etc.

$ cd charts/hnc
$ helm install hnc ./.  --create-namespace -n hnc-system

Tested:

E2E tests has passed.

Related:

#46
#62

Special notes for your reviewer:

Packaging and publishing to chart repository are not included.
In many cases, charts are placed in gh-pages branch and published as Helm repository using GitHub Pages.

eg:
https://github.com/prometheus-community/helm-charts/tree/gh-pages

Onece gh-pages branch is created add published as GitHub Pages, I think we can include these process in cloudbuild.yaml.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 23, 2024
@mochizuki875
Copy link
Member Author

/cc @adrianludwin

Copy link
Contributor

@rjbez17 rjbez17 left a comment

Choose a reason for hiding this comment

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

So sorry, I started a review and got side tracked. Here are a few inital thoughts, I'll find some time soon to give it a closer look. I'm traveling the next few weeks so apologize in advanced.

# limitations under the License.

CURDIR=$(pwd)
YQ=${CURDIR}/bin/yq
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy Paste from makefile: I wouldn't expect yq to live in the CURDIR. Maybe add some logic like this instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@rjbez17
I may not have understood your comment sufficiently...
update-helm.sh wil be called from Makefile via make charts and yq will be installed in ${CURDIR}/bin before execution update-helm.sh.
Therefore, isn't it expected that yq exists in ${CURDIR}/bin?

.PHONY: yq
yq: ## Download yq locally if necessary.
@GOBIN=${CURDIR}/bin GO111MODULE=on go install github.com/mikefarah/yq/v4@v4.34.1
charts: yq manifests

# See the License for the specific language governing permissions and
# limitations under the License.

CURDIR=$(pwd)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a much safer way to achieve this (ROOTDIR or REPODIR is more descriptive I think):

ROOTDIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../"

Makefile Outdated

charts: yq manifests
# Generate CRDs template from manifests/crds.yaml
@rm -rf charts/hnc/crds
Copy link
Contributor

Choose a reason for hiding this comment

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

If you change this to @rm -rf charts/hnc/crds/* you can avoid the mkdir command following it

Makefile Outdated
cat ${MANIFESTDIR}/crds.yaml | ${YQ} -N -s '.metadata.name + ".yaml"'

# Generate helm templates from manifests
@rm -rf charts/hnc/templates
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@rjbez17
Copy link
Contributor

rjbez17 commented Feb 14, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Feb 14, 2024
@mochizuki875 mochizuki875 changed the title Helm Chart for HNC installation [WIP] Helm Chart for HNC installation Feb 22, 2024
@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 Feb 22, 2024
@mochizuki875 mochizuki875 force-pushed the feature_hnc_helm branch 3 times, most recently from 8c1ae69 to cc1ae7e Compare February 22, 2024 02:38
@mochizuki875
Copy link
Member Author

Thanks @rjbez17 !
I've addressed all feedback except one.

@mochizuki875 mochizuki875 changed the title [WIP] Helm Chart for HNC installation Helm Chart for HNC installation Feb 22, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 22, 2024
@@ -0,0 +1,42 @@
# Caution: Don't change namespaceOverride from hnc-system.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we don't just hardcode these in _helpers.tpl since the aren't supposed to be overriden?

Copy link
Member Author

Choose a reason for hiding this comment

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

@rjbez17
As you say, I think it good to hardcode them.
So I've fixed that.

@rjbez17
Copy link
Contributor

rjbez17 commented Mar 19, 2024

Sorry for the delay here. Finally found some time to pull the branch and play with the templating. The ONLY thing left that I can find is can you please make:

hrq:
  enabled: false

true by default?

Building the manifests (make manifests) shows we are enabling by default there and this would keep us inline. Thanks again for all the work here, I really appreciate it.

apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -789,21 +214,20 @@
     spec:
       containers:
       - args:
+        - --excluded-namespace=hnc-system
+        - --excluded-namespace=kube-system
+        - --excluded-namespace=kube-public
+        - --excluded-namespace=kube-node-lease
         - --webhook-server-port=9443
         - --metrics-addr=:8080
         - --max-reconciles=10
         - --apiserver-qps-throttle=50
-        - --excluded-namespace=kube-system
-        - --excluded-namespace=kube-public
-        - --excluded-namespace=hnc-system
-        - --excluded-namespace=kube-node-lease
         - --nopropagation-label=cattle.io/creator=norman
         - --enable-internal-cert-management
         - --cert-restart-on-secret-refresh
-        - --enable-hrq

@mochizuki875
Copy link
Member Author

@rjbez17
I recognize HRQ is beta status and not enabled by default(default.yaml) at v1.1.0.
As beta feature, it is enabled in hrq.yaml.
https://github.com/kubernetes-sigs/hierarchical-namespaces/releases/tag/v1.1.0

Of course, it's ok to set hrq.enabled: true as helm default value, should we do it?

@rjbez17
Copy link
Contributor

rjbez17 commented Mar 19, 2024

@rjbez17 I recognize HRQ is beta status and not enabled by default(default.yaml) at v1.1.0. As beta feature, it is enabled in hrq.yaml. https://github.com/kubernetes-sigs/hierarchical-namespaces/releases/tag/v1.1.0

Of course, it's ok to set hrq.enabled: true as helm default value, should we do it?

Yeah, I was on the fence with it, but it seems that current manifest generation turns it on by default so I was thinking we'd do the same. We can keep at as false for now since it is an easy change for users to override it on.

@rjbez17
Copy link
Contributor

rjbez17 commented Mar 19, 2024

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 19, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mochizuki875, rjbez17

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 19, 2024
@mochizuki875
Copy link
Member Author

@rjbez17 Thanks for your reviews and approve!

@k8s-ci-robot k8s-ci-robot merged commit a0351d2 into kubernetes-sigs:master Mar 19, 2024
3 checks passed
@mjozefcz
Copy link

Thanks guys, I'm really looking forward to see this helm chart as artefact hosted on github pages!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants