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

Policy controller should index services by clusterIPs #12420

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 16 additions & 12 deletions policy-controller/k8s/index/src/outbound/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,26 @@ impl kubert::index::IndexNamespacedResource<Service> for Index {
ports_annotation(service.annotations(), "config.linkerd.io/opaque-ports")
.unwrap_or_else(|| self.namespaces.cluster_info.default_opaque_ports.clone());

if let Some(cluster_ip) = service
if let Some(cluster_ips) = service
.spec
.as_ref()
.and_then(|spec| spec.cluster_ip.as_deref())
.filter(|ip| !ip.is_empty() && *ip != "None")
.and_then(|spec| spec.cluster_ips.as_deref())
{
match cluster_ip.parse() {
Ok(addr) => {
let service_ref = ServiceRef {
name,
namespace: ns.clone(),
};
self.services_by_ip.insert(addr, service_ref);
for cluster_ip in cluster_ips {
if cluster_ip == "None" {
continue;
}
Err(error) => {
tracing::error!(%error, service=name, cluster_ip, "invalid cluster ip");
match cluster_ip.parse() {
Ok(addr) => {
let service_ref = ServiceRef {
name: name.clone(),
namespace: ns.clone(),
};
self.services_by_ip.insert(addr, service_ref);
}
Err(error) => {
tracing::error!(%error, service=name, cluster_ip, "invalid cluster ip");
}
}
}
}
Expand Down