Skip to content

Commit adf52a6

Browse files
fixup
Signed-off-by: Chris Hein <[email protected]>
1 parent 9842992 commit adf52a6

File tree

6 files changed

+73
-20
lines changed

6 files changed

+73
-20
lines changed

pkg/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var _ = Describe("config", func() {
4242

4343
Expect(*conf.LeaderElection.LeaderElect).To(Equal(true))
4444
Expect(conf.CacheNamespace).To(Equal("default"))
45-
Expect(conf.MetricsBindAddress).To(Equal(":8081"))
45+
Expect(conf.Metrics.BindAddress).To(Equal(":8081"))
4646
})
4747
})
4848
})

pkg/config/testdata/config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
22
kind: ControllerConfiguration
33
cacheNamespace: default
4-
metricsBindAddress: :8081
4+
metrics:
5+
BindAddress: :8081
56
leaderElection:
67
leaderElect: true

pkg/config/v1alpha1/types.go

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ import (
2424

2525
// ControllerConfigurationSpec defines the desired state of GenericControllerConfiguration
2626
type ControllerConfigurationSpec struct {
27-
// SyncPeriod returns the SyncPeriod
27+
// SyncPeriod determines the minimum frequency at which watched resources are
28+
// reconciled. A lower period will correct entropy more quickly, but reduce
29+
// responsiveness to change if there are many watched resources. Change this
30+
// value only if you know what you are doing. Defaults to 10 hours if unset.
31+
// there will a 10 percent jitter between the SyncPeriod of all controllers
32+
// so that all controllers will not send list requests simultaneously.
2833
// +optional
2934
SyncPeriod *metav1.Duration `json:"syncPeriod,omitempty"`
3035

31-
// LeaderElection returns the LeaderElection config
36+
// LeaderElection is the LeaderElection config to be used when configuring
37+
// the manager.Manager leader election
3238
// +optional
3339
LeaderElection *configv1alpha1.LeaderElectionConfiguration `json:"leaderElection,omitempty"`
3440

@@ -41,45 +47,66 @@ type ControllerConfigurationSpec struct {
4147
// +optional
4248
CacheNamespace string `json:"cacheNamespace,omitempty"`
4349

44-
// MetricsBindAddress returns the bind address for the metrics server
50+
// GracefulShutdownTimeout is the duration given to runnable to stop before the manager actually returns on stop.
51+
// To disable graceful shutdown, set to time.Duration(0)
52+
// To use graceful shutdown without timeout, set to a negative duration, e.G. time.Duration(-1)
53+
// The graceful shutdown is skipped for safety reasons in case the leadere election lease is lost.
54+
GracefulShutdownTimeout *metav1.Duration `json:"gracefulShutDown,omitempty"`
55+
56+
// Metrics contains thw controller metrics configuration
4557
// +optional
46-
MetricsBindAddress string `json:"metricsBindAddress,omitempty"`
58+
Metrics ControllerMetrics `json:"metrics,omitempty"`
4759

48-
// Health contains the controller health information
60+
// Health contains the controller health configuration
4961
// +optional
5062
Health ControllerHealth `json:"health,omitempty"`
5163

52-
// Webhook contains the controllers webhook information
64+
// Webhook contains the controllers webhook configuration
5365
// +optional
5466
Webhook ControllerWebhook `json:"webhook,omitempty"`
5567
}
5668

69+
// ControllerMetrics defines the metrics configs
70+
type ControllerMetrics struct {
71+
// BindAddress is the TCP address that the controller should bind to
72+
// for serving prometheus metrics.
73+
// It can be set to "0" to disable the metrics serving.
74+
// +optional
75+
BindAddress string `json:"BindAddress,omitempty"`
76+
}
77+
5778
// ControllerHealth defines the health configs
5879
type ControllerHealth struct {
59-
// HealthProbeBindAddress returns the bind address for the health probe
80+
// HealthProbeBindAddress is the TCP address that the controller should bind to
81+
// for serving health probes
6082
// +optional
6183
HealthProbeBindAddress string `json:"healthProbeBindAddress,omitempty"`
6284

63-
// ReadinessEndpointName returns the readiness endpoint name
85+
// ReadinessEndpointName, defaults to "readyz"
6486
// +optional
6587
ReadinessEndpointName string `json:"readinessEndpointName,omitempty"`
6688

67-
// LivenessEndpointName returns the liveness endpoint name
89+
// LivenessEndpointName, defaults to "healthz"
6890
// +optional
6991
LivenessEndpointName string `json:"livenessEndpointName,omitempty"`
7092
}
7193

7294
// ControllerWebhook defines the webhook server for the controller
7395
type ControllerWebhook struct {
74-
// Port returns the Port for the server
96+
// Port is the port that the webhook server serves at.
97+
// It is used to set webhook.Server.Port.
7598
// +optional
7699
Port *int `json:"port,omitempty"`
77100

78-
// Host returns the Host for the server
101+
// Host is the hostname that the webhook server binds to.
102+
// It is used to set webhook.Server.Host.
79103
// +optional
80104
Host string `json:"host,omitempty"`
81105

82-
// CertDir returns the CertDir
106+
// CertDir is the directory that contains the server key and certificate.
107+
// if not set, webhook server would look up the server key and certificate in
108+
// {TempDir}/k8s-webhook-server/serving-certs. The server key and certificate
109+
// must be named tls.key and tls.crt, respectively.
83110
// +optional
84111
CertDir string `json:"certDir,omitempty"`
85112
}

pkg/config/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/manager/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ func (o Options) AndFrom(loader config.DeferredFileLoader) (Options, error) {
426426
o.Namespace = newObj.CacheNamespace
427427
}
428428

429-
if o.MetricsBindAddress == "" && newObj.MetricsBindAddress != "" {
430-
o.MetricsBindAddress = newObj.MetricsBindAddress
429+
if o.MetricsBindAddress == "" && newObj.Metrics.BindAddress != "" {
430+
o.MetricsBindAddress = newObj.Metrics.BindAddress
431431
}
432432

433433
if o.HealthProbeBindAddress == "" && newObj.Health.HealthProbeBindAddress != "" {

pkg/manager/manager_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ var _ = Describe("manger.Manager", func() {
143143
RenewDeadline: duration,
144144
RetryPeriod: duration,
145145
},
146-
CacheNamespace: "default",
147-
MetricsBindAddress: ":6000",
146+
CacheNamespace: "default",
147+
Metrics: v1alpha1.ControllerMetrics{
148+
BindAddress: ":6000",
149+
},
148150
Health: v1alpha1.ControllerHealth{
149151
HealthProbeBindAddress: "6060",
150152
ReadinessEndpointName: "/readyz",
@@ -199,8 +201,10 @@ var _ = Describe("manger.Manager", func() {
199201
RenewDeadline: duration,
200202
RetryPeriod: duration,
201203
},
202-
CacheNamespace: "default",
203-
MetricsBindAddress: ":6000",
204+
CacheNamespace: "default",
205+
Metrics: v1alpha1.ControllerMetrics{
206+
BindAddress: ":6000",
207+
},
204208
Health: v1alpha1.ControllerHealth{
205209
HealthProbeBindAddress: "6060",
206210
ReadinessEndpointName: "/readyz",

0 commit comments

Comments
 (0)