Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom certificates in metrics server #1218

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ type Config struct {
PprofEnabled bool `default:"false" desc:"is pprof enabled" split_words:"true"`
PprofListenOn string `default:"localhost:6060" desc:"pprof URL to ListenAndServe" split_words:"true"`
PrometheusListenOn string `default:":8081" desc:"Prometheus URL to ListenAndServe" split_words:"true"`
PrometheusCAFile string `default:"" desc:"Path to the CA file for the Prometheus server (by default the authentication will happen via TLS instead of mTLS)" split_words:"true"`
PrometheusKeyFile string `default:"" desc:"Path to the key file for the Prometheus server (by default it uses a SPIRE generated one)" split_words:"true"`
PrometheusCertFile string `default:"" desc:"Path to the certificate file for the Prometheus server (by default it uses a SPIRE generated one)" split_words:"true"`
PrometheusMonitorCertificate bool `default:"false" desc:"defines whether the custom certificate for Prometheus should be watched for updates" split_words:"true"`
PrometheusServerHeaderTimeout time.Duration `default:"5s" desc:"Timeout for how long the Prometheus server waits for complete request headers from the client" split_words:"true"`

TunnelIP net.IP `desc:"IP to use for tunnels" split_words:"true"`
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ func main() {
// Configure Prometheus
// ********************************************************************************
if prometheus.IsEnabled() {
go prometheus.ListenAndServe(ctx, cfg.PrometheusListenOn, cfg.PrometheusServerHeaderTimeout, cancel)
metricServer := prometheus.NewServer(
cfg.PrometheusListenOn,
prometheus.WithCustomCert(cfg.PrometheusCertFile, cfg.PrometheusKeyFile),
prometheus.WithCustomCA(cfg.PrometheusCAFile),
prometheus.WithHeaderTimeout(cfg.PrometheusServerHeaderTimeout),
prometheus.WithCertificateMonitoring(cfg.PrometheusMonitorCertificate))
go metricServer.ListenAndServe(ctx, cancel)
}

// ********************************************************************************
Expand Down
Loading