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

chore(*) make kumactl install control plane leverage the Helm Charts #989

Merged
merged 24 commits into from
Sep 15, 2020

Conversation

nickolaev
Copy link
Contributor

Summary

Make the kumactl instal control-plane generate the manifests based in rendering the Helm Charts.

Documentation

Internal

@nickolaev nickolaev force-pushed the chore/kumactl_with_helm branch 2 times, most recently from 82036d4 to 1553876 Compare August 24, 2020 13:34
Nikolay Nikolaev added 12 commits August 24, 2020 16:45
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev force-pushed the chore/kumactl_with_helm branch from 1553876 to 0b14db1 Compare August 25, 2020 20:12
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev marked this pull request as ready for review August 26, 2020 05:51
@nickolaev nickolaev requested a review from a team as a code owner August 26, 2020 05:51
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev force-pushed the chore/kumactl_with_helm branch from d52ac67 to 04ee5f7 Compare August 26, 2020 08:08
@nickolaev
Copy link
Contributor Author

@austince please check this one

Copy link
Contributor

@austince austince left a comment

Choose a reason for hiding this comment

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

overall looks great, a few nits, ideas, and suggestions

@@ -5472,7 +5513,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: install-cni
image: lobkovilya/install-cni:0.0.1
image: kong-docker-kuma-docker.bintray.io/lobkovilya/install-cni:0.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will be fixed with the "kuma.formatImage" comment below

Comment on lines 55 to 59
//kumaCPImage = kumaImageRegistry + "/" + kumaCPImageRepo
kumaDPImageRepo = "kuma-dp"
kumaDPImage = kumaImageRegistry + "/" + kumaDPImageRepo
kumaInitImageRepo = "kuma-init"
kumaInitImage = kumaImageRegistry + "/" + kumaInitImageRepo
//kumaInitImage = kumaImageRegistry + "/" + kumaInitImageRepo
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these comments be removed?


// strip Helm Chart specific labels
for _, label := range stripLabels {
re := regexp.MustCompile("(?m)[\r\n]+^.*" + label + ".*$")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - might want to compile these all ahead of time instead of for each file.

func labelRegex(label string) *regexp.Regexp {
	return regexp.MustCompile("(?m)[\r\n]+^.*" + label + ".*$")
}

var stripLabelsRegexps = []*regexp.Regexp{
	labelRegex("app.kubernetes.io/managed-by"),
	labelRegex("helm.sh/chart"),
	labelRegex("app.kubernetes.io/version"),
}

Comment on lines 82 to 88
for _, t := range loadedTemplates {
if !strings.HasPrefix(t.Name, "templates/pre-") {
loadedChart.Templates = append(loadedChart.Templates, &chart.File{
Name: t.Name,
Data: t.Data,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes a lot of sense, though we might want to document the pre- convention for hooks. What about post hooks?

value := v.FieldByName(name).Interface()

splitName := strings.Split(name, "_")
len := len(splitName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
len := len(splitName)
nameLen := len(splitName)

nit to avoid conflict w/ len() builtin

Comment on lines 108 to 116
for i := 1; i < len-1; i++ {
n := splitName[i]

if _, ok := root[n]; !ok {
root[n] = map[string]interface{}{}
}
root = root[n].(map[string]interface{})
}
root[splitName[len-1]] = value
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this map generation a bit hard to follow. Not surehow difficult something like this would be to implement, but would be nicer to have the arg-to-helm-value mapping tagged on the struct fields instead of using reflection.

type InstallControlPlaneArgs struct {
	controlPlaneImagePullPolicy             string `helm:"controlPlane.image.pullPolicy"`
	// ...

Nikolay Nikolaev and others added 5 commits August 27, 2020 18:46
Co-authored-by: Austin Cawley-Edwards <austin.cawley@gmail.com>
Co-authored-by: Austin Cawley-Edwards <austin.cawley@gmail.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@@ -5499,7 +5548,7 @@ webhooks:
- meshes
sideEffects: None
- name: owner-reference.kuma-admission.kuma.io
failurePolicy: Fail
failurePolicy: Ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should stay as Fail. This helps us set owner references to resources. Without this, if we add TrafficPermission to some Mesh and we delete this some Mesh, TrafficPermission won't be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh this probably means the Helm charts are wrong.

}

func renderHelmFiles(templates []data.File, args interface{}) ([]data.File, error) {
loadedChart, err := loadCharts(templates)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: loadedChart, err := loadCharts(templates) -> chart, err := loadChart(templates)

## Note to Chart developers

The charts are used internally in `kumactl install`, therefore the following rules apply when developing new chat features:
* all templates that start with `pre-` and `post-` are omitted when processing in `kumactl install`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a note that you need to run make generate... to have consistent HELM and kumactl install?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, but I think there is still this verification part of make test

Nikolay Nikolaev added 2 commits September 14, 2020 12:16
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Nikolay Nikolaev added 2 commits September 14, 2020 16:55
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Copy link
Contributor

@austince austince left a comment

Choose a reason for hiding this comment

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

looks great to me too!

@nickolaev nickolaev merged commit ef62c04 into master Sep 15, 2020
@nickolaev nickolaev deleted the chore/kumactl_with_helm branch September 17, 2020 05:45
@nickolaev nickolaev mentioned this pull request Sep 17, 2020
1 task
nickolaev pushed a commit that referenced this pull request Oct 7, 2020
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
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.

3 participants