Skip to content

Commit

Permalink
Update service status when reconciling
Browse files Browse the repository at this point in the history
  • Loading branch information
UnstoppableMango committed Jan 8, 2024
1 parent c685e37 commit c7ed1c5
Show file tree
Hide file tree
Showing 2 changed files with 352 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/controller/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func FromIngressToExposure(ctx context.Context, logger logr.Logger, kubeClient c
}

hostname := rule.Host

scheme := "http"

if backendProtocol, ok := getAnnotation(ingress.Annotations, AnnotationBackendProtocol); ok {
Expand Down Expand Up @@ -96,15 +95,26 @@ func FromIngressToExposure(ctx context.Context, logger logr.Logger, kubeClient c
return nil, errors.Errorf("path type in ingress %s/%s is %s, which is not supported", ingress.GetNamespace(), ingress.GetName(), *path.PathType)
}

pathPrefix := path.Path

result = append(result, exposure.Exposure{
Hostname: hostname,
ServiceTarget: fmt.Sprintf("%s://%s:%d", scheme, host, port),
PathPrefix: pathPrefix,
PathPrefix: path.Path,
IsDeleted: isDeleted,
ProxySSLVerifyEnabled: proxySSLVerifyEnabled,
})

if service.Status.LoadBalancer.Ingress == nil {
service.Status.LoadBalancer.Ingress = []v1.LoadBalancerIngress{{Hostname: hostname}}
} else {
service.Status.LoadBalancer.Ingress = append(service.Status.LoadBalancer.Ingress, v1.LoadBalancerIngress{
Hostname: hostname,
})
}

err = kubeClient.Status().Update(ctx, &service)
if err != nil {
return nil, errors.Wrapf(err, "update service %s", service.Name)
}
}
}

Expand Down
Loading

0 comments on commit c7ed1c5

Please sign in to comment.