From 48ce284603b1a258f1b511e4de4419acd63cf1d9 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Tue, 19 Nov 2024 10:21:12 +0100 Subject: [PATCH 1/2] Updated ingress update condition. --- src/main.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3543975..ab05903 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,11 +178,10 @@ pub async fn reconcile_load_balancer( .filter(|node| label_filter.check(node.labels())) .collect::>(); - let node_ip_type = svc - .annotations() - .get(consts::LB_NODE_IP_LABEL_NAME) - .map(String::as_str) - .unwrap_or(consts::DEFAULT_NODE_IP); + let mut node_ip_type = "InternalIP"; + if lb.network_name.is_none() { + node_ip_type = "ExternalIP"; + } for node in nodes { let Some(status) = node.status else { @@ -235,22 +234,24 @@ pub async fn reconcile_load_balancer( let ipv4 = hcloud_lb.public_net.ipv4.ip.flatten(); let dns_ipv6 = hcloud_lb.public_net.ipv6.dns_ptr.flatten(); let ipv6 = hcloud_lb.public_net.ipv6.ip.flatten(); - if ipv4.is_some() { + if let Some(ipv4) = &ipv4 { ingress.push(json!({ "ip": ipv4, "dns": dns_ipv4, "ip_mode": "VIP" })) } - if ipv6.is_some() && context.config.ipv6_ingress { - ingress.push(json!({ - "ip": ipv6, - "dns": dns_ipv6, - "ip_mode": "VIP" - })) + if context.config.ipv6_ingress { + if let Some(ipv6) = &ipv6 { + ingress.push(json!({ + "ip": ipv6, + "dns": dns_ipv6, + "ip_mode": "VIP" + })) + } } - if ipv4.is_some() { + if !ingress.is_empty() { svc_api .patch_status( svc.name_any().as_str(), From 21937ef9327d75740bb3c7cce882b29bf462abbe Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Tue, 19 Nov 2024 11:44:33 +0100 Subject: [PATCH 2/2] Updated default permissions for an operator. --- helm/Chart.yaml | 2 +- helm/values.yaml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 8e2b42b..9957629 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.1.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/helm/values.yaml b/helm/values.yaml index 2357e55..c85d059 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -31,8 +31,11 @@ serviceAccount: # By default it grants all permissions. permissions: - apiGroups: [""] - resources: ["services"] + resources: [services] verbs: [get, list, patch, update, watch] + - apiGroups: [""] + resources: [nodes] + verbs: [get, list, watch] # - apiGroups: ["apps/v1"] # resources: ["deployments"] # verbs: ["get", "list"]