Aleksei Sviridkin 6444b66881 fix(tcp-balancer): render the kubernetes and talos Service ports only with kubernetesAndTalos (#4965)
## What this PR does

The tcp-balancer Service renders ports 6443 and 50000 inside a second
`with .Values.httpAndHttps` block. The Deployment declares the
`kubernetes` and `talos` container ports, and the HAProxy config binds
the `kubernetes` and `talos` frontends, only under `with
.Values.kubernetesAndTalos`. This PR gates those two Service ports on
`kubernetesAndTalos` as well, a one-word change in
`templates/service.yaml`.

So with the default `httpAndHttps` every Service has four ports, two of
them point at targetPort names no container declares, and the
EndpointSlice has no port for them. With `external: true` the
LoadBalancer Service carries them as well. The other way round, a
release with `kubernetesAndTalos` and `httpAndHttps: null` gets no
Service port for those frontends, while HAProxy listens on them. The
block has been like this since the chart was added.

Found while testing tcp-balancer on a v1.6.5 cluster. A TCPBalancer with
`httpAndHttps` set and no `kubernetesAndTalos` got a ClusterIP Service
with the ports `http:80`, `https:443`, `kubernetes:6443` and
`talos:50000`, and its EndpointSlice listed only `http:8080` and
`https:8443`.

`kubernetesAndTalos` is not in `values.yaml`, `values.schema.json` or
the README, so before choosing between gating the block and dropping it
I checked whether the key can be set at all. The tcp-balancer
`openAPISchema` declares no top-level `additionalProperties`, so
`patchSpec` in `pkg/cmd/server/openapi.go` publishes `spec` with
`x-kubernetes-preserve-unknown-fields`, and
`convertApplicationToHelmRelease` passes `app.Spec` to the HelmRelease
as its values. So the key reaches the chart through the apps API, and
the Deployment, the ConfigMap and the existing `haproxy-config` suite
already treat it as an input. Dropping the block would leave HAProxy
listening on 6443 and 50000 with no Service port in front of them.
Whether to document the key is a separate question and not part of this
PR.

On upgrade, a release on the default values loses the two ports that had
no endpoints, and a release with `kubernetesAndTalos` alone gains them.
The Deployment and the ConfigMap render the same as before, so the pods
do not roll. A release that sets both keys renders exactly as before.

`tests/service_test.yaml` has three cases, and each pins the whole
`spec.ports` list of the Service together with the container ports of
the Deployment, so every `targetPort` is checked against a port the
Deployment declares. The default values give only 80 and 443,
`kubernetesAndTalos` with `httpAndHttps: null` gives only 6443 and
50000, and both keys together give all four. Against the template on
main the first two cases fail and the third passes, 2 failed and 10
passed in total. Dropping the block instead of gating it fails the
second and the third case, and moving the Deployment's kubernetes and
talos ports under `httpAndHttps` fails the first two on the Deployment
side. `helm unittest` passes 12 of 12 tests in 3 suites, against 9 in 2
suites on main, with helm-unittest 1.1.2 as CI pins it. `helm template`
renders the whole chart for the default values, `external: true`,
`kubernetesAndTalos` alone and both keys, and the only difference from
main is in the Service ports. I have not run the change on a live
cluster.

The template is the same on release-1.6 and release-1.7. The commit
cherry-picks onto release-1.6 without conflicts, and that backport is a
separate PR.

### Screenshots

Not a UI change.

### Downstream repositories

One template line and a test suite in `packages/apps/tcp-balancer`. No
values, schema, README, defaults, Service name or
`ApplicationDefinition` change, and neither the website nor the
Terraform provider mentions `kubernetesAndTalos`, so no trigger map
entry applies.

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(tcp-balancer): the Service now publishes ports 6443 and 50000 only when kubernetesAndTalos is set, like the Deployment and the HAProxy config. Before, every tcp-balancer Service carried both ports with no container port behind them, on the LoadBalancer too when external was enabled, and a release with kubernetesAndTalos but without httpAndHttps had no Service port for them.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Kubernetes and Talos service ports are now rendered when their
configuration is enabled, independently of the HTTP/HTTPS configuration.

* **Tests**
* Added coverage for default HTTP/HTTPS ports, Kubernetes/Talos ports
configured alone, and all four ports configured together.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 18:24:54 +03:00
2025-10-08 09:43:34 +05:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

GitHub Release Apache-2.0 License Commit activity OpenSSF Best Practices OpenSSF Scorecard CLOMonitor Support

Cozystack

Cozystack is a free and open-source platform and framework for building clouds.

Cozystack is a CNCF Sandbox project that was originally built and sponsored by Ænix.

With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.

Use Cozystack to build your own cloud or provide a cost-effective development environment.

Cozystack user interface

Use-Cases

Documentation

The documentation is located on the cozystack.io website.

Read the Getting Started section for a quick start.

If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.

Versioning

Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.

Contributions

Contributions are highly appreciated and very welcomed!

In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.

You are welcome to take on the fix yourself. Commits are used to generate the changelog, and their author will be referenced in it.

If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.

Community

You are welcome to join us in #cozystack, on either CNCF Slack (get an invite) or Kubernetes Slack (get an invite), in our Telegram group, and at our community meetings. Add them to your Google Calendar or iCal for convenience.

Project documents

Document What it covers
Governance How decisions are made and who makes them
Contributor Ladder How to grow from contributor to maintainer
Maintainers Who maintains the project
Code of Conduct What we expect of each other
Security Policy Reporting a vulnerability, and which releases get fixes
Adopters Who runs Cozystack in production
Roadmap Where the project is going

License

Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.

Commercial Support

A list of companies providing commercial support for this project can be found on official site.

Languages
Go 52%
Shell 34%
TypeScript 6.8%
Go Template 4.7%
Makefile 1.3%
Other 1.1%