Skip to content

feat: add parameter to force HTTP #638

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

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 cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func main() {
metricsAddr string
healthProbeAddr string
openShiftEnabled bool
forceHTTP bool

setupLog = ctrl.Log.WithName("setup")
)
Expand All @@ -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,
Expand All @@ -107,6 +109,7 @@ func main() {
"metrics-bind-address", metricsAddr,
"images", images,
"openshift.enabled", openShiftEnabled,
"forceHTTP", forceHTTP,
)

imgMap, err := validateImages(images)
Expand All @@ -133,6 +136,7 @@ func main() {
Enabled: openShiftEnabled,
},
}),
operator.WithForceHTTP(forceHTTP),
))
if err != nil {
setupLog.Error(err, "cannot create a new operator")
Expand Down
9 changes: 8 additions & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type OperatorConfiguration struct {
ThanosQuerier tqctrl.ThanosConfiguration
UIPlugins uictrl.UIPluginsConfiguration
FeatureGates FeatureGates
ForceHTTP bool
}

func WithNamespace(ns string) func(*OperatorConfiguration) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
Expand Down