From fc536171f5c6a256776bb42d67d278809b65bfc7 Mon Sep 17 00:00:00 2001 From: Zhou Zhiqiang Date: Fri, 30 Jun 2023 13:56:46 +0800 Subject: [PATCH] Cloudflared metrics (#13) --- hack/dev/ingress-class.yaml | 2 ++ ...-cloudflared-connector-headless-service.yaml | 17 +++++++++++++++++ .../controlled-cloudflared-connector.go | 3 +++ skaffold.yaml | 1 + 4 files changed, 23 insertions(+) create mode 100644 helm/cloudflare-tunnel-ingress-controller/templates/controlled-cloudflared-connector-headless-service.yaml diff --git a/hack/dev/ingress-class.yaml b/hack/dev/ingress-class.yaml index cc95215..76f4ff4 100644 --- a/hack/dev/ingress-class.yaml +++ b/hack/dev/ingress-class.yaml @@ -3,5 +3,7 @@ apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: name: cloudflare-tunnel + annotations: + ingressclass.kubernetes.io/is-default-class: "true" spec: controller: strrl.dev/cloudflare-tunnel-ingress-controller diff --git a/helm/cloudflare-tunnel-ingress-controller/templates/controlled-cloudflared-connector-headless-service.yaml b/helm/cloudflare-tunnel-ingress-controller/templates/controlled-cloudflared-connector-headless-service.yaml new file mode 100644 index 0000000..ca12c57 --- /dev/null +++ b/helm/cloudflare-tunnel-ingress-controller/templates/controlled-cloudflared-connector-headless-service.yaml @@ -0,0 +1,17 @@ +# a headless service +appVersion: v1 +kind: Service +metadata: + name: controlled-cloudflared-connector-headless + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "44483" +spec: + ports: + - name: metrics + port: 44483 + protocol: TCP + clusterIP: None + selector: + "app": "controlled-cloudflared-connector" + "strrl.dev/cloudflare-tunnel-ingress-controller": "controlled-cloudflared-connector" diff --git a/pkg/controller/controlled-cloudflared-connector.go b/pkg/controller/controlled-cloudflared-connector.go index 8feaad4..123b503 100644 --- a/pkg/controller/controlled-cloudflared-connector.go +++ b/pkg/controller/controlled-cloudflared-connector.go @@ -2,6 +2,7 @@ package controller import ( "context" + cloudflarecontroller "github.com/STRRL/cloudflare-tunnel-ingress-controller/pkg/cloudflare-controller" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" @@ -81,6 +82,8 @@ func cloudflaredConnectDeploymentTemplating(token string, namespace string) *app "cloudflared", "--no-autoupdate", "tunnel", + "--metrics", + "0.0.0.0:44483", "run", "--token", token, diff --git a/skaffold.yaml b/skaffold.yaml index 4291516..6f5ba8b 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -17,3 +17,4 @@ manifests: - hack/dev/ns.yaml - hack/dev/cloudflare-api.yaml - hack/dev/deployment.yaml + - hack/dev/ingress-class.yaml