fix: updating ingress status with provided loadbalancer ip

This commit is contained in:
Dario Tranchitella
2023-04-13 14:39:20 +02:00
parent 27f598fbfc
commit 8dc0672718
2 changed files with 22 additions and 17 deletions

View File

@@ -1,22 +1,22 @@
apiVersion: kamaji.clastix.io/v1alpha1
kind: TenantControlPlane
metadata:
name: test
name: k8s-126
spec:
controlPlane:
deployment:
replicas: 1
replicas: 2
service:
serviceType: LoadBalancer
kubernetes:
version: "v1.25.4"
version: "v1.26.0"
kubelet:
cgroupfs: cgroupfs
admissionControllers:
- ResourceQuota
- LimitRanger
cgroupfs: systemd
networkProfile:
port: 6443
addons:
coreDNS: {}
kubeProxy: {}
konnectivity:
server:
port: 8132

View File

@@ -26,20 +26,25 @@ type KubernetesIngressResource struct {
}
func (r *KubernetesIngressResource) ShouldStatusBeUpdated(_ context.Context, tcp *kamajiv1alpha1.TenantControlPlane) bool {
// No update in case of no ingress in spec, neither in status.
if tcp.Spec.ControlPlane.Ingress == nil && tcp.Status.Kubernetes.Ingress == nil {
switch {
case tcp.Spec.ControlPlane.Ingress == nil && tcp.Status.Kubernetes.Ingress == nil:
// No update in case of no ingress in spec, neither in status.
return false
}
// Must be updated when TCP is using an Ingress, and status is not tracking it.
if tcp.Spec.ControlPlane.Ingress != nil && tcp.Status.Kubernetes.Ingress == nil {
case tcp.Spec.ControlPlane.Ingress != nil && tcp.Status.Kubernetes.Ingress == nil,
// Must be updated when TCP is using an Ingress, and status is not tracking it
// or
// Must be updated when the status is referring to an Ingress, although spec doesn't.
tcp.Spec.ControlPlane.Ingress == nil && tcp.Status.Kubernetes.Ingress != nil:
return true
}
// Must be updated when the status is referring to an Ingress, although spec doesn't.
if tcp.Spec.ControlPlane.Ingress == nil && tcp.Status.Kubernetes.Ingress != nil {
case len(r.resource.Status.LoadBalancer.Ingress) > 0 && tcp.Status.Kubernetes.Ingress == nil || tcp.Status.Kubernetes.Ingress.LoadBalancer.Ingress == nil:
// Must be updated since missing the Ingress status
return true
case r.resource.Status.LoadBalancer.Ingress[0].IP != tcp.Status.Kubernetes.Ingress.LoadBalancer.Ingress[0].IP:
// Must bne updated, Ingress load balancer IP is slightly different
return true
default:
return tcp.Status.Kubernetes.Ingress.Name != r.resource.GetName() || tcp.Status.Kubernetes.Ingress.Namespace != r.resource.GetNamespace()
}
// In case of status skew, update it.
return tcp.Status.Kubernetes.Ingress.Name != r.resource.GetName() || tcp.Status.Kubernetes.Ingress.Namespace != r.resource.GetNamespace()
}
func (r *KubernetesIngressResource) ShouldCleanup(tcp *kamajiv1alpha1.TenantControlPlane) bool {