-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a42d14
commit bc223b3
Showing
9 changed files
with
201 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ import ( | |
|
||
"github.com/uselagoon/remote-controller/internal/harbor" | ||
"github.com/uselagoon/remote-controller/internal/helpers" | ||
"github.com/uselagoon/remote-controller/internal/metrics" | ||
"github.com/uselagoon/remote-controller/internal/utilities/deletions" | ||
"github.com/uselagoon/remote-controller/internal/utilities/pruner" | ||
|
||
|
@@ -185,10 +184,10 @@ func main() { | |
|
||
var unauthenticatedRegistry string | ||
|
||
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", | ||
"The address the metric endpoint binds to.") | ||
flag.BoolVar(&secureMetrics, "metrics-secure", false, | ||
"If set the metrics endpoint is served securely") | ||
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+ | ||
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.") | ||
flag.BoolVar(&secureMetrics, "metrics-secure", true, | ||
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.") | ||
flag.BoolVar(&enableHTTP2, "enable-http2", false, | ||
"If set, HTTP/2 will be enabled for the metrics and webhook servers") | ||
|
||
|
@@ -489,10 +488,16 @@ func main() { | |
tlsOpts = append(tlsOpts, disableHTTP2) | ||
} | ||
metricsServerOptions := metricsserver.Options{ | ||
BindAddress: metricsAddr, | ||
SecureServing: secureMetrics, | ||
TLSOpts: tlsOpts, | ||
FilterProvider: filters.WithAuthenticationAndAuthorization, | ||
BindAddress: metricsAddr, | ||
SecureServing: secureMetrics, | ||
TLSOpts: tlsOpts, | ||
} | ||
if secureMetrics { | ||
// FilterProvider is used to protect the metrics endpoint with authn/authz. | ||
// These configurations ensure that only authorized users and service accounts | ||
// can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info: | ||
// https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/filters#WithAuthenticationAndAuthorization | ||
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization | ||
} | ||
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ | ||
Scheme: scheme, | ||
|
@@ -1012,10 +1017,6 @@ func main() { | |
} | ||
// +kubebuilder:scaffold:builder | ||
|
||
setupLog.Info("starting lagoon metrics server") | ||
m := metrics.NewServer(setupLog, ":9912") | ||
defer m.Shutdown(context.Background()) | ||
|
||
setupLog.Info("starting manager") | ||
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { | ||
setupLog.Error(err, "problem running manager") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: metrics-reader-rolebinding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: metrics-reader | ||
subjects: | ||
- kind: ServiceAccount | ||
name: controller-manager | ||
namespace: system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.