@@ -388,6 +388,27 @@ func generateSecretsConfig(cfg *RouterConfig, namespace string, defaultCert []by
388
388
secrets = append (secrets , secret )
389
389
}
390
390
391
+ if cfg .Type == "haproxy-router" && cfg .StatsPort != 0 {
392
+ metricsCertName := "router-metrics-tls"
393
+ if len (defaultCert ) == 0 {
394
+ // when we are generating a serving cert, we need to reuse the existing cert
395
+ metricsCertName = certName
396
+ }
397
+ volumes = append (volumes , kapi.Volume {
398
+ Name : "metrics-server-certificate" ,
399
+ VolumeSource : kapi.VolumeSource {
400
+ Secret : & kapi.SecretVolumeSource {
401
+ SecretName : metricsCertName ,
402
+ },
403
+ },
404
+ })
405
+ mounts = append (mounts , kapi.VolumeMount {
406
+ Name : "metrics-server-certificate" ,
407
+ ReadOnly : true ,
408
+ MountPath : "/etc/pki/tls/metrics/" ,
409
+ })
410
+ }
411
+
391
412
// The secret in this volume is either the one created for the
392
413
// user supplied default cert (pem format) or the secret generated
393
414
// by the service anotation (cert only format).
@@ -685,6 +706,8 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
685
706
if cfg .Type == "haproxy-router" && cfg .StatsPort != 0 {
686
707
env ["ROUTER_LISTEN_ADDR" ] = fmt .Sprintf ("0.0.0.0:%d" , cfg .StatsPort )
687
708
env ["ROUTER_METRICS_TYPE" ] = "haproxy"
709
+ env ["ROUTER_METRICS_TLS_CERT_FILE" ] = "/etc/pki/tls/metrics/tls.crt"
710
+ env ["ROUTER_METRICS_TLS_KEY_FILE" ] = "/etc/pki/tls/metrics/tls.key"
688
711
}
689
712
env .Add (secretEnv )
690
713
if len (defaultCert ) > 0 {
@@ -730,13 +753,6 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
730
753
},
731
754
}
732
755
733
- if cfg .StatsPort > 0 && cfg .ExposeMetrics {
734
- pc := generateMetricsExporterContainer (cfg , env )
735
- if pc != nil {
736
- containers = append (containers , * pc )
737
- }
738
- }
739
-
740
756
objects := []runtime.Object {}
741
757
for _ , s := range secrets {
742
758
objects = append (objects , s )
@@ -815,6 +831,9 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
815
831
// The secret generated by the service annotaion contains a tls.crt and tls.key
816
832
// which ultimately need to be combined into a pem
817
833
t .Annotations ["service.alpha.openshift.io/serving-cert-secret-name" ] = certName
834
+ } else if cfg .Type == "haproxy-router" && cfg .StatsPort != 0 {
835
+ // Generate a serving cert for metrics only
836
+ t .Annotations ["service.alpha.openshift.io/serving-cert-secret-name" ] = "router-metrics-tls"
818
837
}
819
838
}
820
839
}
0 commit comments