mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
## 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 -->
How to test packages local
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd