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

✨ Allow FQDN as the control plane endpoint host #108

Merged
merged 2 commits into from
May 2, 2024

Conversation

piepmatz
Copy link
Contributor

@piepmatz piepmatz commented Apr 30, 2024

What is the purpose of this pull request/Why do we need it?

Until now, we assumed the control plane endpoint host to be an IP, but that's an unnecessary restriction.

Description of changes:

The template now consumes a new environment variable: CONTROL_PLANE_ENDPOINT_HOST
It's optional and defaults to the value of the existing CONTROL_PLANE_ENDPOINT_IP environment variable.

As the host is required to resolve to that IP, we'd actually not need it anymore to be given explicitly. However, as we still render the kube-vip manifest in the template and don't have anything nice there to do the translation automatically, we keep the explicit IP for now.

The controller code is not aware of the CONTROL_PLANE_ENDPOINT_IP value, though. It only sees the control plane endpoint host, which can now be either an IP or an FQDN, so the controller must be able to resolve the name to use the corresponding IP to find the matching IP block and to find the correct IP failover group.

Special notes for your reviewer:

Unit tests for DNS resolving were not as convenient as I expected. The stdlib tests don't provide any means to mock it, they even rely on external network reachability to resolve some Google domain names. They pointed to golang/go#12503, though. There's an interesting link to https://github.com/ncruces/go-dns, showing how to inject custom behavior using a custom dialer, enabling things such as caching. It's overkill for us, though, so our used approach for unit testing is simpler.

Checklist:

  • Documentation updated
  • Unit Tests added
  • E2E Tests added
  • Includes emojis

Until now, we assumed the control plane endpoint host to be an IP, but
that's an unnecessary restriction.

The template now consumes a new environment variable:
`CONTROL_PLANE_ENDPOINT_HOST`
It's optional and defaults to the value of the existing
`CONTROL_PLANE_ENDPOINT_IP` environment variable.

As the host is required to resolve to that IP, we'd actually not need it
anymore to be given explicitly. However, as we still render the kube-vip
manifest in the template and don't have anything nice there to do the
translation automatically, we keep the explicit IP for now.

The controller code is not aware of the `CONTROL_PLANE_ENDPOINT_IP`
value, though. It only sees the control plane endpoint host, which can
now be either an IP or an FQDN, so the controller must be able to
resolve the name to use the corresponding IP to find the matching
IP block and to find the correct IP failover group.

Unit tests for DNS resolving were not as convenient as I expected.
The stdlib tests don't provide any means to mock it, they even rely on
external network reachability to resolve some Google domain names.
They pointed to golang/go#12503, though.
There's an interesting link to https://github.com/ncruces/go-dns,
showing how to inject custom behavior using a custom dialer, enabling
things such as caching. It's overkill for us, though, so our used
approach for unit testing is simpler.
@piepmatz piepmatz changed the title Allow FQDN as the control plane endpoint host ✨ Allow FQDN as the control plane endpoint host Apr 30, 2024
docs/quickstart.md Show resolved Hide resolved
envfile.example Show resolved Hide resolved
internal/service/cloud/ipblock.go Show resolved Hide resolved
internal/service/cloud/network.go Show resolved Hide resolved
scope/cluster.go Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented May 2, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

internal/service/cloud/ipblock.go Show resolved Hide resolved
@piepmatz piepmatz merged commit dd3f67e into main May 2, 2024
8 checks passed
@piepmatz piepmatz deleted the CAPI-108-fqdn-endpoint branch May 2, 2024 14:19
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.

2 participants