@@ -17,10 +17,12 @@ limitations under the License.
17
17
package v1alpha1
18
18
19
19
import (
20
+ "time"
21
+
20
22
corev1 "k8s.io/api/core/v1"
21
23
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24
+ configv1alpha1 "k8s.io/component-base/config/v1alpha1"
22
25
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23
- ctrlconfigv1 "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
24
26
)
25
27
26
28
const (
@@ -84,8 +86,8 @@ type ConfigmapReference struct {
84
86
85
87
// ManagerSpec defines the properties that can be enabled on the controller manager for the provider.
86
88
type ManagerSpec struct {
87
- // ControllerManagerConfigurationSpec defines the desired state of GenericControllerManagerConfiguration.
88
- ctrlconfigv1. ControllerManagerConfigurationSpec `json:",inline"`
89
+ // ControllerManager returns the configurations for controllers
90
+ ControllerManager `json:",inline"`
89
91
90
92
// ProfilerAddress defines the bind address to expose the pprof profiler (e.g. localhost:6060).
91
93
// Default empty, meaning the profiler is disabled.
@@ -112,6 +114,127 @@ type ManagerSpec struct {
112
114
FeatureGates map [string ]bool `json:"featureGates,omitempty"`
113
115
}
114
116
117
+ type ControllerManager struct {
118
+ // Webhook contains the controllers webhook configuration
119
+ // +optional
120
+ Webhook ControllerWebhook `json:"webhook,omitempty"`
121
+
122
+ // SyncPeriod determines the minimum frequency at which watched resources are
123
+ // reconciled. A lower period will correct entropy more quickly, but reduce
124
+ // responsiveness to change if there are many watched resources. Change this
125
+ // value only if you know what you are doing. Defaults to 10 hours if unset.
126
+ // there will a 10 percent jitter between the SyncPeriod of all controllers
127
+ // so that all controllers will not send list requests simultaneously.
128
+ // +optional
129
+ SyncPeriod * metav1.Duration `json:"syncPeriod,omitempty"`
130
+
131
+ // LeaderElection is the LeaderElection config to be used when configuring
132
+ // the manager.Manager leader election
133
+ // +optional
134
+ LeaderElection * configv1alpha1.LeaderElectionConfiguration `json:"leaderElection,omitempty"`
135
+
136
+ // Metrics contains thw controller metrics configuration
137
+ // +optional
138
+ Metrics ControllerMetrics `json:"metrics,omitempty"`
139
+
140
+ // CacheNamespace if specified restricts the manager's cache to watch objects in
141
+ // the desired namespace Defaults to all namespaces
142
+ //
143
+ // Note: If a namespace is specified, controllers can still Watch for a
144
+ // cluster-scoped resource (e.g Node). For namespaced resources the cache
145
+ // will only hold objects from the desired namespace.
146
+ // +optional
147
+ CacheNamespace string `json:"cacheNamespace,omitempty"`
148
+
149
+ // GracefulShutdownTimeout is the duration given to runnable to stop before the manager actually returns on stop.
150
+ // To disable graceful shutdown, set to time.Duration(0)
151
+ // To use graceful shutdown without timeout, set to a negative duration, e.G. time.Duration(-1)
152
+ // The graceful shutdown is skipped for safety reasons in case the leader election lease is lost.
153
+ GracefulShutdownTimeout * metav1.Duration `json:"gracefulShutDown,omitempty"`
154
+
155
+ // Health contains the controller health configuration
156
+ // +optional
157
+ Health ControllerHealth `json:"health,omitempty"`
158
+
159
+ // Controller contains global configuration options for controllers
160
+ // registered within this manager.
161
+ // +optional
162
+ Controller * ControllerConfigurationSpec `json:"controller,omitempty"`
163
+ }
164
+
165
+ // ControllerWebhook defines the webhook server for the controller.
166
+ type ControllerWebhook struct {
167
+ // Port is the port that the webhook server serves at.
168
+ // It is used to set webhook.Server.Port.
169
+ // +optional
170
+ Port * int `json:"port,omitempty"`
171
+
172
+ // Host is the hostname that the webhook server binds to.
173
+ // It is used to set webhook.Server.Host.
174
+ // +optional
175
+ Host string `json:"host,omitempty"`
176
+
177
+ // CertDir is the directory that contains the server key and certificate.
178
+ // if not set, webhook server would look up the server key and certificate in
179
+ // {TempDir}/k8s-webhook-server/serving-certs. The server key and certificate
180
+ // must be named tls.key and tls.crt, respectively.
181
+ // +optional
182
+ CertDir string `json:"certDir,omitempty"`
183
+ }
184
+
185
+ // ControllerMetrics defines the metrics configs.
186
+ type ControllerMetrics struct {
187
+ // BindAddress is the TCP address that the controller should bind to
188
+ // for serving prometheus metrics.
189
+ // It can be set to "0" to disable the metrics serving.
190
+ // +optional
191
+ BindAddress string `json:"bindAddress,omitempty"`
192
+ }
193
+
194
+ // ControllerHealth defines the health configs.
195
+ type ControllerHealth struct {
196
+ // HealthProbeBindAddress is the TCP address that the controller should bind to
197
+ // for serving health probes
198
+ // It can be set to "0" or "" to disable serving the health probe.
199
+ // +optional
200
+ HealthProbeBindAddress string `json:"healthProbeBindAddress,omitempty"`
201
+
202
+ // ReadinessEndpointName, defaults to "readyz"
203
+ // +optional
204
+ ReadinessEndpointName string `json:"readinessEndpointName,omitempty"`
205
+
206
+ // LivenessEndpointName, defaults to "healthz"
207
+ // +optional
208
+ LivenessEndpointName string `json:"livenessEndpointName,omitempty"`
209
+ }
210
+
211
+ // ControllerConfigurationSpec defines the global configuration for
212
+ // controllers registered with the manager.
213
+ type ControllerConfigurationSpec struct {
214
+ // GroupKindConcurrency is a map from a Kind to the number of concurrent reconciliation
215
+ // allowed for that controller.
216
+ //
217
+ // When a controller is registered within this manager using the builder utilities,
218
+ // users have to specify the type the controller reconciles in the For(...) call.
219
+ // If the object's kind passed matches one of the keys in this map, the concurrency
220
+ // for that controller is set to the number specified.
221
+ //
222
+ // The key is expected to be consistent in form with GroupKind.String(),
223
+ // e.g. ReplicaSet in apps group (regardless of version) would be `ReplicaSet.apps`.
224
+ //
225
+ // +optional
226
+ GroupKindConcurrency map [string ]int `json:"groupKindConcurrency,omitempty"`
227
+
228
+ // CacheSyncTimeout refers to the time limit set to wait for syncing caches.
229
+ // Defaults to 2 minutes if not set.
230
+ // +optional
231
+ CacheSyncTimeout * time.Duration `json:"cacheSyncTimeout,omitempty"`
232
+
233
+ // RecoverPanic indicates if panics should be recovered.
234
+ // +optional
235
+ RecoverPanic * bool `json:"recoverPanic,omitempty"`
236
+ }
237
+
115
238
// DeploymentSpec defines the properties that can be enabled on the Deployment for the provider.
116
239
type DeploymentSpec struct {
117
240
// Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.
0 commit comments