Commit f4f37d7
committed
pkg/cvo/metrics: Add a new --serving-client-certificate-authorities-file option
In 313f8fb (CVO protects /metrics with authorization, 2025-07-22, openshift#1215) and
833a491 (CVO protects /metrics with authorization, 2025-07-22, openshift#1215), the
/metrics endpoint began requiring client auth. The only
authentication system was Bearer tokens, and the only authorization
system was validating that the token belonged to
system:serviceaccount:openshift-monitoring:prometheus-k8s.
That worked well for standalone clusters, where the ServiceMonitor
scraper is the Prometheus from the openshift-monitoring namespace.
But it broke scraping on HyperShift [1], where the ServiceMonitor does
not request any client authorization [2]. Getting ServiceAccount
tokens (and keeping them fresh [3]) from the hosted cluster into a
Prometheus scraper running on the management cluster is hard. But for
other ServiceMonitors, HyperShift configures keySecret [4] asking the
scraper to get its client certificate from a metrics-client Secret
that the HostedControlPlane controller maintains in the management
cluster namespace [5].
This commit adds a new --serving-client-certificate-authorities-file
option, which HyperShift can set when it configures the CVO Deployment
[6], while mounting the root CA ConfigMap into the Pod.
Now that there are three files (serving key, serving cert, client CAs)
that we might be watching for changes, I've taken the opportunity to
refactor the checksumming and change-tracking to use a map from
filename to checksum. That way we can extend more easily if further
configuration files are added in the future, without having to pass
around a series of paths and checksums as distinct arguments.
I'm a bit sad about AppendCertsFromPEM only returning a boolean [7],
leaving us unsure about whether all the certificates in the file were
parsed, or, if there were parsing issues, what those issues were. But
with HyperShift hopefully reliably setting up CA Secrets that do not
cause parsing issues, I'm ok not coding that defensively. If the
standard library grows a parser that is more transparent about parsing
issues, we can pivot to that once it exists.
[1]: https://issues.redhat.com/browse/OCPBUGS-62858
[2]: https://github.com/openshift/hypershift/blob/2728a4e2899ee58690e3d4e58b319eb5e78643af/control-plane-operator/controllers/hostedcontrolplane/v2/assets/cluster-version-operator/servicemonitor.yaml#L18
[3]: https://kubernetes.io/docs/concepts/configuration/secret/#serviceaccount-token-secrets
[4]: https://github.com/openshift/hypershift/blob/2728a4e2899ee58690e3d4e58b319eb5e78643af/control-plane-operator/controllers/hostedcontrolplane/v2/assets/kube-apiserver/servicemonitor.yaml#L24-L26
[5]: https://github.com/openshift/hypershift/blob/2728a4e2899ee58690e3d4e58b319eb5e78643af/control-plane-operator/controllers/hostedcontrolplane/pki/sa.go#L35-L36
[6]: https://github.com/openshift/hypershift/blob/2728a4e2899ee58690e3d4e58b319eb5e78643af/control-plane-operator/controllers/hostedcontrolplane/v2/assets/cluster-version-operator/deployment.yaml#L25-L35
[7]: https://pkg.go.dev/crypto/x509#CertPool.AppendCertsFromPEM1 parent 95685e0 commit f4f37d7
File tree
3 files changed
+93
-77
lines changed- cmd/cluster-version-operator
- pkg
- cvo
- start
3 files changed
+93
-77
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
249 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
250 | 265 | | |
251 | 266 | | |
252 | 267 | | |
253 | | - | |
| 268 | + | |
254 | 269 | | |
255 | 270 | | |
256 | 271 | | |
| |||
270 | 285 | | |
271 | 286 | | |
272 | 287 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
283 | 291 | | |
284 | 292 | | |
285 | 293 | | |
| |||
288 | 296 | | |
289 | 297 | | |
290 | 298 | | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
297 | 302 | | |
298 | 303 | | |
299 | 304 | | |
| |||
326 | 331 | | |
327 | 332 | | |
328 | 333 | | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
| 334 | + | |
| 335 | + | |
345 | 336 | | |
| 337 | + | |
346 | 338 | | |
347 | 339 | | |
348 | 340 | | |
| |||
712 | 704 | | |
713 | 705 | | |
714 | 706 | | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
733 | 713 | | |
734 | 714 | | |
735 | | - | |
| 715 | + | |
736 | 716 | | |
737 | | - | |
| 717 | + | |
738 | 718 | | |
739 | 719 | | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
744 | 726 | | |
745 | | - | |
746 | | - | |
| 727 | + | |
747 | 728 | | |
748 | 729 | | |
749 | | - | |
| 730 | + | |
750 | 731 | | |
751 | 732 | | |
752 | 733 | | |
| |||
761 | 742 | | |
762 | 743 | | |
763 | 744 | | |
764 | | - | |
| 745 | + | |
765 | 746 | | |
766 | 747 | | |
767 | 748 | | |
768 | | - | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
769 | 765 | | |
770 | 766 | | |
771 | 767 | | |
| |||
785 | 781 | | |
786 | 782 | | |
787 | 783 | | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
798 | 803 | | |
| 804 | + | |
799 | 805 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
147 | 151 | | |
148 | 152 | | |
149 | 153 | | |
| |||
350 | 354 | | |
351 | 355 | | |
352 | 356 | | |
353 | | - | |
| 357 | + | |
354 | 358 | | |
355 | 359 | | |
356 | 360 | | |
| |||
0 commit comments