UPSTREAM: <carry>: OCPBUGS-90506: replace kube-rbac-proxy with native metrics auth - #200
UPSTREAM: <carry>: OCPBUGS-90506: replace kube-rbac-proxy with native metrics auth#200Thealisyed wants to merge 1 commit into
Conversation
|
@Thealisyed: This pull request references Jira Issue OCPBUGS-90506, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
cb3ef99 to
84286dd
Compare
|
/jira refresh |
|
@Thealisyed: This pull request references Jira Issue OCPBUGS-90506, which is invalid:
Comment DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@Thealisyed: This pull request references Jira Issue OCPBUGS-90506, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
… metrics auth Replace the kube-rbac-proxy sidecar with inline TokenReview/SAR authentication served directly by the external-dns binary. Adds --metrics-tls-cert-dir flag (default empty = plain HTTP, backward compatible) and authMiddleware using k8s.io/client-go only — no new dependencies. Assisted with Claude.
84286dd to
729bf5d
Compare
|
@Thealisyed: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Expose ExternalDNS operand metrics to cluster Prometheus without using a kube-rbac-proxy sidecar. The operand now serves its own metrics over HTTPS with Kubernetes TokenReview/SAR auth via --metrics-tls-cert-dir (added in openshift/external-dns#200). - Add --metrics-tls-cert-dir arg and service-ca cert volume mount to each ExternalDNS container - Change --metrics-address from 127.0.0.1 to 0.0.0.0 so metrics are reachable outside the pod - Create a Service with serving-cert annotation for auto TLS - Create a ServiceMonitor for Prometheus discovery (HTTPS, port 7979+) - Add tokenreviews/subjectaccessreviews RBAC for the operand service account Depends on openshift/external-dns#200 for the operand-side auth layer. Assisted with Claude.
Expose ExternalDNS operand metrics to cluster Prometheus without using a kube-rbac-proxy sidecar. The operand now serves its own metrics over HTTPS with Kubernetes TokenReview/SAR auth via --metrics-tls-cert-dir (added in openshift/external-dns#200). - Add --metrics-tls-cert-dir arg and service-ca cert volume mount to each ExternalDNS container - Change --metrics-address from 127.0.0.1 to 0.0.0.0 so metrics are reachable outside the pod - Create a Service with serving-cert annotation for auto TLS - Create a ServiceMonitor for Prometheus discovery (HTTPS, port 7979+) - Add tokenreviews/subjectaccessreviews RBAC for the operand service account Depends on openshift/external-dns#200 for the operand-side auth layer. Assisted with Claude.
Expose ExternalDNS operand metrics to cluster Prometheus without using a kube-rbac-proxy sidecar. The operand now serves its own metrics over HTTPS with Kubernetes TokenReview/SAR auth via --metrics-tls-cert-dir (added in openshift/external-dns#200). - Add --metrics-tls-cert-dir arg and service-ca cert volume mount to each ExternalDNS container - Change --metrics-address from 127.0.0.1 to 0.0.0.0 so metrics are reachable outside the pod - Create a Service with serving-cert annotation for auto TLS - Create a ServiceMonitor for Prometheus discovery (HTTPS, port 7979+) - Add tokenreviews/subjectaccessreviews RBAC for the operand service account Depends on openshift/external-dns#200 for the operand-side auth layer. Assisted with Claude.
|
/assign |
alebedev87
left a comment
There was a problem hiding this comment.
The main approach LGTM, some remarks about minimizing the impact of the carrying the patch. Also, about the commit message and PR title - kube-rbac-proxy doesn't figure in external-dns context, it's something we add in the operator. Something like add secure metrics serving with TokenReview/SAR authentication would be more fitting into the context.
| server := &http.Server{Addr: address, Handler: newMetricsMux(kubeClient, tlsCertDir)} | ||
| log.Fatal(server.ListenAndServeTLS( | ||
| filepath.Join(tlsCertDir, "tls.crt"), | ||
| filepath.Join(tlsCertDir, "tls.key"), | ||
| )) |
There was a problem hiding this comment.
This means both healthz and metrics endpoints will be over HTTPS for EDO. Can this be handled in the operator logic? Is simple switching scheme for the probes be enough?
| ctx, cancel := context.WithCancel(context.Background()) | ||
|
|
||
| go serveMetrics(cfg.MetricsAddress) | ||
| go serveMetrics(cfg.MetricsAddress, cfg.MetricsTLSCertDir, cfg.KubeConfig, cfg.APIServerURL) |
There was a problem hiding this comment.
I'm thinking about how we can ease the task of carrying this patch for the future rebases. WDYT about this approach?
| go serveMetrics(cfg.MetricsAddress, cfg.MetricsTLSCertDir, cfg.KubeConfig, cfg.APIServerURL) | |
| if cfg.MetricsTLSCertDir != "" { | |
| go serveSecureMetrics(cfg) | |
| } else { | |
| go serveMetrics(cfg.MetricsAddress) | |
| } |
Then serveSecureMetrics() can be moved into a dedicated file (e.g. metrics_openshift.go) and it handles the creation of kubeclient, new mux server and changing the metrics handler do the token review and authorization.
This way 1) main.go changes will remain very minimal, 2) all new code (including imported packages) is in a dedicated file which is easy to carry, 3) new unit tests are in a dedicated new file too, easy to carry and recongnise (openshift in the name).
| return mux | ||
| } | ||
|
|
||
| func authMiddleware(kubeClient kubernetes.Interface, next http.Handler) http.Handler { |
There was a problem hiding this comment.
authMiddleware seems a little vague, wdyt about something like this?
| func authMiddleware(kubeClient kubernetes.Interface, next http.Handler) http.Handler { | |
| func withMetricsAuth(kubeClient kubernetes.Interface, next http.Handler) http.Handler { |
Summary
--metrics-tls-cert-dirflag (directory containingtls.crtandtls.keyprovisioned by service-ca); defaults to empty string (plain HTTP) for backward compatibilityauthMiddlewareusingk8s.io/client-godirectly — zero new dependencies/healthzremains unauthenticated for kubelet liveness/readiness probesNote: