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

Bumping up controller-runtime@v0.15.0 #4582

Merged
merged 6 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ New deprecation(s):

- **Azure Data Explorer**: Deprecate `metadata.clientSecret` ([#4514](https://github.com/kedacore/keda/issues/4514))


### Breaking Changes

- TODO ([#XXX](https://github.com/kedacore/keda/issue/XXX))
Expand All @@ -96,6 +95,7 @@ New deprecation(s):
- **General**: Automatically scale test clusters in/out to reduce environmental footprint & improve cost-efficiency ([#4456](https://github.com/kedacore/keda/pull/4456))
- **General**: Use default metrics provider from sigs.k8s.io/custom-metrics-apiserver ([#4473](https://github.com/kedacore/keda/pull/4473))
- **General**: Refactor several functions for Status & Conditions handling into pkg util functions ([#2906](https://github.com/kedacore/keda/pull/2906))
- **General**: Bump `kubernetes-sigs/controller-runtime` to v0.15.0 and code alignment ([#4582](https://github.com/kedacore/keda/pull/4582))

## v2.10.1

Expand Down
11 changes: 7 additions & 4 deletions cmd/adapter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
ctrl "sigs.k8s.io/controller-runtime"
ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache"
basecmd "sigs.k8s.io/custom-metrics-apiserver/pkg/cmd"
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"

Expand Down Expand Up @@ -111,10 +112,12 @@ func (a *Adapter) makeProvider(ctx context.Context, globalHTTPTimeout time.Durat
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
MetricsBindAddress: metricsBindAddress,
Scheme: scheme,
Namespace: namespace,
LeaseDuration: leaseDuration,
RenewDeadline: renewDeadline,
RetryPeriod: retryPeriod,
Cache: ctrlcache.Options{
Namespaces: []string{namespace},
},
LeaseDuration: leaseDuration,
RenewDeadline: renewDeadline,
RetryPeriod: retryPeriod,
})
if err != nil {
logger.Error(err, "failed to setup manager")
Expand Down
25 changes: 14 additions & 11 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/cache"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/config"
ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/webhook"

kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
kedacontrollers "github.com/kedacore/keda/v2/controllers/keda"
Expand Down Expand Up @@ -136,16 +137,20 @@ func main() {
cfg.DisableCompression = disableCompression

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
MetricsBindAddress: metricsAddr,
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
}),
Cache: ctrlcache.Options{
Namespaces: []string{namespace},
},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "operator.keda.sh",
LeaseDuration: leaseDuration,
RenewDeadline: renewDeadline,
RetryPeriod: retryPeriod,
Namespace: namespace,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down Expand Up @@ -204,9 +209,8 @@ func main() {
ScaleClient: scaleClient,
ScaleHandler: scaledHandler,
}).SetupWithManager(mgr, controller.Options{
Controller: config.Controller{
MaxConcurrentReconciles: scaledObjectMaxReconciles,
}}); err != nil {
MaxConcurrentReconciles: scaledObjectMaxReconciles,
}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ScaledObject")
os.Exit(1)
}
Expand All @@ -218,9 +222,8 @@ func main() {
SecretsLister: secretInformer.Lister(),
SecretsSynced: secretInformer.Informer().HasSynced,
}).SetupWithManager(mgr, controller.Options{
Controller: config.Controller{
MaxConcurrentReconciles: scaledJobMaxReconciles,
}}); err != nil {
MaxConcurrentReconciles: scaledJobMaxReconciles,
}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ScaledJob")
os.Exit(1)
}
Expand Down
30 changes: 17 additions & 13 deletions cmd/webhooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"crypto/tls"
"flag"
"os"

Expand All @@ -29,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/webhook"

kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
"github.com/kedacore/keda/v2/pkg/k8s"
Expand All @@ -54,13 +56,12 @@ func main() {
var webhooksClientRequestQPS float32
var webhooksClientRequestBurst int
var certDir string
var tlsMinVersion string

pflag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
pflag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
pflag.Float32Var(&webhooksClientRequestQPS, "kube-api-qps", 20.0, "Set the QPS rate for throttling requests sent to the apiserver")
pflag.IntVar(&webhooksClientRequestBurst, "kube-api-burst", 30, "Set the burst for throttling requests sent to the apiserver")
pflag.StringVar(&certDir, "cert-dir", "/certs", "Webhook certificates dir to use. Defaults to /certs")
pflag.StringVar(&tlsMinVersion, "tls-min-version", "1.3", "Minimum TLS version")

opts := zap.Options{}
opts.BindFlags(flag.CommandLine)
Expand All @@ -76,12 +77,19 @@ func main() {
cfg.Burst = webhooksClientRequestBurst

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
LeaderElection: false,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
LeaderElection: false,
MetricsBindAddress: metricsAddr,
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
CertDir: certDir,
TLSOpts: []func(tlsConfig *tls.Config){
func(tlsConfig *tls.Config) {
tlsConfig.MinVersion = kedautil.GetMinTLSVersion()
},
},
}),
HealthProbeBindAddress: probeAddr,
CertDir: certDir,
})
if err != nil {
setupLog.Error(err, "unable to start admission webhooks")
Expand All @@ -98,7 +106,7 @@ func main() {

kedautil.PrintWelcome(setupLog, kubeVersion, "admission webhooks")

setupWebhook(mgr, tlsMinVersion)
setupWebhook(mgr)

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
Expand All @@ -115,14 +123,10 @@ func main() {
}
}

func setupWebhook(mgr manager.Manager, tlsMinVersion string) {
func setupWebhook(mgr manager.Manager) {
// setup webhooks
if err := (&kedav1alpha1.ScaledObject{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "ScaledObject")
os.Exit(1)
}

setupLog.V(1).Info("setting up webhook server")
hookServer := mgr.GetWebhookServer()
hookServer.TLSMinVersion = tlsMinVersion
}
79 changes: 62 additions & 17 deletions config/crd/bases/keda.sh_scaledjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ spec:
pods, represented by the jobs's .status.failed field, is incremented
and it is checked against the backoffLimit. This field cannot
be used in combination with restartPolicy=OnFailure. \n This
field is alpha-level. To use this field, you must enable the
`JobPodFailurePolicy` feature gate (disabled by default)."
field is beta-level. It can be used when the `JobPodFailurePolicy`
feature gate is enabled (enabled by default)."
properties:
rules:
description: A list of pod failure policy rules. The rules
Expand Down Expand Up @@ -1575,7 +1575,10 @@ spec:
properties:
name:
description: The header field
name
name. This will be canonicalized
upon output, so case-variant
names will be understood as
the same header.
type: string
value:
description: The header field
Expand Down Expand Up @@ -1688,7 +1691,10 @@ spec:
properties:
name:
description: The header field
name
name. This will be canonicalized
upon output, so case-variant
names will be understood as
the same header.
type: string
value:
description: The header field
Expand Down Expand Up @@ -1811,7 +1817,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -2030,7 +2039,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -2473,7 +2485,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -3036,7 +3051,10 @@ spec:
properties:
name:
description: The header field
name
name. This will be canonicalized
upon output, so case-variant
names will be understood as
the same header.
type: string
value:
description: The header field
Expand Down Expand Up @@ -3149,7 +3167,10 @@ spec:
properties:
name:
description: The header field
name
name. This will be canonicalized
upon output, so case-variant
names will be understood as
the same header.
type: string
value:
description: The header field
Expand Down Expand Up @@ -3271,7 +3292,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -3483,7 +3507,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -3919,7 +3946,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -4518,7 +4548,10 @@ spec:
properties:
name:
description: The header field
name
name. This will be canonicalized
upon output, so case-variant
names will be understood as
the same header.
type: string
value:
description: The header field
Expand Down Expand Up @@ -4631,7 +4664,10 @@ spec:
properties:
name:
description: The header field
name
name. This will be canonicalized
upon output, so case-variant
names will be understood as
the same header.
type: string
value:
description: The header field
Expand Down Expand Up @@ -4754,7 +4790,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -4973,7 +5012,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down Expand Up @@ -5416,7 +5458,10 @@ spec:
header to be used in HTTP probes
properties:
name:
description: The header field name
description: The header field name.
This will be canonicalized upon
output, so case-variant names will
be understood as the same header.
type: string
value:
description: The header field value
Expand Down