Skip to content

Commit 0b38a1c

Browse files
nightkrsbernauer
andauthored
Revert to preferring IP addresses for Node listeners by default (#244)
* Revert to preferring IP addresses for Node listeners by default * Changelog * Docs * Use op-rs release. Also fix tests * docs: Add newline --------- Co-authored-by: Sebastian Bernauer <[email protected]>
1 parent 7adc686 commit 0b38a1c

File tree

15 files changed

+100
-74
lines changed

15 files changed

+100
-74
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ All notable changes to this project will be documented in this file.
66

77
### Added
88

9-
- `Listener.status.addresses` can now be configured to prefer either IP addresses or DNS hostnames ([#233]).
9+
- `Listener.status.addresses` can now be configured to prefer either IP addresses or DNS hostnames ([#233], [#244]).
1010
- The operator can now run on Kubernetes clusters using a non-default cluster domain.
1111
Use the env var `KUBERNETES_CLUSTER_DOMAIN` or the operator Helm chart property `kubernetesClusterDomain` to set a non-default cluster domain ([#237]).
1212

1313
### Changed
1414

1515
- `Listener.status.addresses` for NodePort listeners now includes replicas that are currently unavailable ([#231]).
16-
- `Listener.status.addresses` now defaults to DNS hostnames for all service types (previously NodePort and ClusterIP would prefer IP addresses, [#233]).
16+
- BREAKING: `Listener.status.addresses` now defaults to DNS hostnames for ClusterIP services, rather than IP addresses ([#233], [#244]).
1717
- Stale Listener subobjects will now be deleted ([#232]).
1818
- Tagged Listener Services with the SDP labels ([#232]).
1919

@@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file.
3030
[#234]: https://github.com/stackabletech/listener-operator/pull/234
3131
[#237]: https://github.com/stackabletech/listener-operator/pull/237
3232
[#238]: https://github.com/stackabletech/listener-operator/pull/238
33+
[#244]: https://github.com/stackabletech/listener-operator/pull/244
3334

3435
## [24.7.0] - 2024-07-24
3536

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ prost = "0.13"
2121
prost-types = "0.13"
2222
serde = "1.0"
2323
snafu = "0.8"
24-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.80.0" }
24+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.81.0" }
2525
strum = { version = "0.26", features = ["derive"] }
2626
socket2 = { version = "0.5", features = ["all"] }
2727
tokio = { version = "1.40", features = ["full"] }

crate-hashes.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/helm/listener-operator/crds/crds.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ spec:
2525
description: Defines a policy for how [Listeners](https://docs.stackable.tech/home/nightly/listener-operator/listener) should be exposed. Read the [ListenerClass documentation](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass) for more information.
2626
properties:
2727
preferredAddressType:
28-
default: Hostname
28+
default: HostnameConservative
2929
description: |-
30-
Whether addresses should prefer using the IP address (`IP`) or the hostname (`Hostname`).
30+
Whether addresses should prefer using the IP address (`IP`) or the hostname (`Hostname`). Can also be set to `HostnameConservative`, which will use `IP` for `NodePort` service types, but `Hostname` for everything else.
3131
32-
The other type will be used if the preferred type is not available. By default `Hostname` is used.
32+
The other type will be used if the preferred type is not available.
33+
34+
Defaults to `HostnameConservative`.
3335
enum:
3436
- Hostname
3537
- IP
38+
- HostnameConservative
3639
type: string
3740
serviceAnnotations:
3841
additionalProperties:

docs/modules/listener-operator/pages/listenerclass.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Additionally, many cloud providers charge for load-balanced traffic.
6666
[#addresstype]
6767
== Address types
6868

69-
The Stackable Listener Operator supports both IP addresses and DNS hostnames. The preferred address type for a given ListenerClass can be configured using the `ListenerClass.spec.preferredAddressType` field. If no `preferredAddressType` is specified then it defaults to xref:#addresstype-hostname[].
69+
The Stackable Listener Operator supports both IP addresses and DNS hostnames. The preferred address type for a given ListenerClass can be configured using the `ListenerClass.spec.preferredAddressType` field. If no `preferredAddressType` is specified then it defaults to xref:#addresstype-hostname-conservative[].
7070

7171
NOTE: If the preferred address type is not supported for a given environment then another type will be used.
7272

@@ -81,6 +81,12 @@ but does not require any special client configuration (beyond what the xref:#ser
8181

8282
The DNS hostname of a resource. Clients must be able to resolve these addresses in order to connect, which may require special DNS configuration.
8383

84+
[#addresstype-hostname-conservative]
85+
=== HostnameConservative
86+
87+
A pseudo-addresstype that is equivalent to xref:#addresstype-ip[] for xref:#servicetype-nodeport[] services, and xref:#addresstype-hostname[] for all others.
88+
This means that we default to hostnames where "safe", but don't assume that nodes are resolvable by external clients.
89+
8490
== Default ListenerClasses
8591

8692
The Stackable Data Platform assumes the existence of a few predefined ListenerClasses, and will use them by default as appropriate:

rust/operator-binary/src/csi_server/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ async fn local_listener_addresses_for_pod(
464464
})?;
465465

466466
Ok(node_primary_addresses(&node)
467-
.pick(listener_class.spec.preferred_address_type)
467+
.pick(listener_class.spec.resolve_preferred_address_type())
468468
.map(|(address, address_type)| ListenerIngress {
469469
// nodes: Some(vec![node_name.to_string()]),
470470
address: address.to_string(),

rust/operator-binary/src/listener_controller.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ pub async fn reconcile(
364364
.add(&ctx.client, svc)
365365
.await
366366
.context(ApplyServiceSnafu { svc: svc_ref })?;
367+
let preferred_address_type = listener_class.spec.resolve_preferred_address_type();
367368

368369
let nodes: Vec<Node>;
369370
let kubernetes_service_fqdn: String;
@@ -384,9 +385,7 @@ pub async fn reconcile(
384385
.await?;
385386
addresses = nodes
386387
.iter()
387-
.flat_map(|node| {
388-
node_primary_addresses(node).pick(listener_class.spec.preferred_address_type)
389-
})
388+
.flat_map(|node| node_primary_addresses(node).pick(preferred_address_type))
390389
.collect::<Vec<_>>();
391390
ports = svc
392391
.spec
@@ -408,7 +407,7 @@ pub async fn reconcile(
408407
ip: ingress.ip.as_deref(),
409408
hostname: ingress.hostname.as_deref(),
410409
}
411-
.pick(listener_class.spec.preferred_address_type)
410+
.pick(preferred_address_type)
412411
})
413412
.collect();
414413
ports = svc
@@ -422,7 +421,7 @@ pub async fn reconcile(
422421
}
423422
ServiceType::ClusterIP => {
424423
let cluster_domain = &cluster_info.cluster_domain;
425-
addresses = match listener_class.spec.preferred_address_type {
424+
addresses = match preferred_address_type {
426425
AddressType::Ip => svc
427426
.spec
428427
.iter()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestStep
4+
commands:
5+
- script: envsubst '$NAMESPACE' < 05_listenerclass.yaml | kubectl apply -n $NAMESPACE -f -

0 commit comments

Comments
 (0)