diff --git a/cmd/operator/main.go b/cmd/operator/main.go index 1fb59facf..079db03b9 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -82,6 +82,7 @@ func main() { metricsAddr string healthProbeAddr string openShiftEnabled bool + forceHTTP bool setupLog = ctrl.Log.WithName("setup") ) @@ -92,6 +93,7 @@ func main() { flag.StringVar(&healthProbeAddr, "health-probe-bind-address", ":8081", "The address the health probe endpoint binds to.") flag.Var(images, "images", fmt.Sprintf("Full images refs to use for containers managed by the operator. E.g thanos=quay.io/thanos/thanos:v0.33.0. Images used are %v", imagesUsed())) flag.BoolVar(&openShiftEnabled, "openshift.enabled", false, "Enable OpenShift specific features such as Console Plugins.") + flag.BoolVar(&forceHTTP, "force-http", false, "Use HTTP instead of HTTPS to expose metrics.") opts := zap.Options{ Development: true, @@ -107,6 +109,7 @@ func main() { "metrics-bind-address", metricsAddr, "images", images, "openshift.enabled", openShiftEnabled, + "forceHTTP", forceHTTP, ) imgMap, err := validateImages(images) @@ -133,6 +136,7 @@ func main() { Enabled: openShiftEnabled, }, }), + operator.WithForceHTTP(forceHTTP), )) if err != nil { setupLog.Error(err, "cannot create a new operator") diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index 2bf18fe24..af9669582 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -62,6 +62,7 @@ type OperatorConfiguration struct { ThanosQuerier tqctrl.ThanosConfiguration UIPlugins uictrl.UIPluginsConfiguration FeatureGates FeatureGates + ForceHTTP bool } func WithNamespace(ns string) func(*OperatorConfiguration) { @@ -119,6 +120,12 @@ func WithFeatureGates(featureGates FeatureGates) func(*OperatorConfiguration) { } } +func WithForceHTTP(forceHTTP bool) func(*OperatorConfiguration) { + return func(oc *OperatorConfiguration) { + oc.ForceHTTP = forceHTTP + } +} + func NewOperatorConfiguration(opts ...func(*OperatorConfiguration)) *OperatorConfiguration { cfg := &OperatorConfiguration{} for _, o := range opts { @@ -139,7 +146,7 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) { clientCAController *dynamiccertificates.ConfigMapCAController servingCertController *dynamiccertificates.DynamicServingCertificateController ) - if cfg.FeatureGates.OpenShift.Enabled { + if cfg.FeatureGates.OpenShift.Enabled && !cfg.ForceHTTP { // When running in OpenShift, the server uses HTTPS thanks to the // service CA operator. certFile := filepath.Join(tlsMountPath, "tls.crt")