From 21925db9cc4be0c69208e58b19314b3f9f357117 Mon Sep 17 00:00:00 2001 From: Zhou Zhiqiang Date: Sun, 18 Jun 2023 07:09:29 +0800 Subject: [PATCH] fix: use best effort mode to extract exposure, ignore None ClusterIP (#3) Signed-off-by: STRRL --- pkg/controller/ingress-controller.go | 6 +++++- pkg/controller/transform.go | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/controller/ingress-controller.go b/pkg/controller/ingress-controller.go index bec250a..0b5cf62 100644 --- a/pkg/controller/ingress-controller.go +++ b/pkg/controller/ingress-controller.go @@ -2,6 +2,8 @@ package controller import ( "context" + "fmt" + cloudflarecontroller "github.com/STRRL/cloudflare-tunnel-ingress-controller/pkg/cloudflare-controller" "github.com/STRRL/cloudflare-tunnel-ingress-controller/pkg/exposure" "github.com/go-logr/logr" @@ -73,11 +75,13 @@ func (i *IngressController) Reconcile(ctx context.Context, request reconcile.Req if err != nil { return reconcile.Result{}, errors.Wrap(err, "list controlled ingresses") } + var allExposures []exposure.Exposure for _, ingress := range ingresses { + // best effort to extract exposures from all ingresses exposures, err := i.fromIngressToExposure(ctx, ingress) if err != nil { - return reconcile.Result{}, errors.Wrapf(err, "extract exposures from ingress %s", ingress.Name) + i.logger.Info("extract exposures from ingress, skipped", "triggered-by", request.NamespacedName, "ingress", fmt.Sprintf("%s/%s", ingress.Namespace, ingress.Name), "error", err) } allExposures = append(allExposures, exposures...) } diff --git a/pkg/controller/transform.go b/pkg/controller/transform.go index 0f6de5d..f1162fb 100644 --- a/pkg/controller/transform.go +++ b/pkg/controller/transform.go @@ -3,6 +3,7 @@ package controller import ( "context" "fmt" + "github.com/STRRL/cloudflare-tunnel-ingress-controller/pkg/exposure" "github.com/pkg/errors" v1 "k8s.io/api/core/v1" @@ -50,6 +51,10 @@ func (i *IngressController) fromIngressToExposure(ctx context.Context, ingress n return nil, errors.Errorf("service %s has no cluster ip", namespacedName) } + if service.Spec.ClusterIP == "None" { + return nil, errors.Errorf("service %s has None for cluster ip, headless service is not supported", namespacedName) + } + host := service.Spec.ClusterIP var port int32