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

redpanda: convert service.loadbalancer.yaml to go #1347

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

chrisseto
Copy link
Contributor

Fixes #1215

Comment on lines 87 to 97
for name, listener := range values.Listeners.Admin.External {
if !ptr.Deref(listener.Enabled, values.External.Enabled) {
continue
}

fallbackPorts := append(listener.AdvertisedPorts, values.Listeners.Admin.Port)

ports = append(ports, corev1.ServicePort{
Name: fmt.Sprintf("admin-%s", name),
Protocol: corev1.ProtocolTCP,
// TODO this diverges from all the other cases that use
// listener.Port. Is this a bug in the original template?
TargetPort: intstr.FromInt32(values.Listeners.Admin.Port),
Port: ptr.Deref(listener.NodePort, fallbackPorts[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 wonder how values.Listeners.Admin.External could be deterministic with ranging and always returning the same port.

Would there be a case where running helm template in a loop without changing values input would generate different loadbalancer manifest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the value is a map and the keys are of basic type with a defined order, the elements will be visited in sorted key order.

But I should be ranging over the sorted keys to make sure the go implementation is working as expected and lining up with the helm version. Will change!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I'm actually going to punt on this change for now. The nodeport service works the same way and templates' ranges are actually deterministic.

Copy link
Contributor

@RafalKorepta RafalKorepta left a comment

Choose a reason for hiding this comment

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

LGTM

This commit implements the `tpl` or `Tpl` function for go and adds a few tests
thereof. Gotohelm's implementation of `tpl` is NOT fully featured in go nor
within our test harness.
This commit converts `service.loadbalancer.yaml` to go code.

It includes a small fix for a typo that seems to have gone unnoticed. In the
case of using a loadbalancer service, `listeners.admin.external[*].port` was
being ignored in favor of `listeners.admin.external.port`, which was divergent
from all other port mappings.

Fixes #1215
@chrisseto chrisseto force-pushed the chris/p/convert-loadbalancer branch from febd052 to 57dbee4 Compare June 13, 2024 18:06
@chrisseto chrisseto enabled auto-merge (rebase) June 13, 2024 18:07
@chrisseto chrisseto merged commit 98cef42 into main Jun 13, 2024
41 checks passed
@chrisseto chrisseto deleted the chris/p/convert-loadbalancer branch June 13, 2024 18:45
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.

redpanda: Convert service.loadbalancer.yaml to go code
2 participants