-
Notifications
You must be signed in to change notification settings - Fork 473
/
defaults.go
352 lines (318 loc) · 13.1 KB
/
defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
// Copyright 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package v1alpha1
import (
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1"
"k8s.io/utils/ptr"
)
// SetDefaults_ControllerManagerConfiguration sets defaults for the configuration of the Gardener controller manager.
func SetDefaults_ControllerManagerConfiguration(obj *ControllerManagerConfiguration) {
if obj.LogLevel == "" {
obj.LogLevel = LogLevelInfo
}
if obj.LogFormat == "" {
obj.LogFormat = LogFormatJSON
}
if obj.LeaderElection == nil {
obj.LeaderElection = &componentbaseconfigv1alpha1.LeaderElectionConfiguration{}
}
}
// SetDefaults_ClientConnectionConfiguration sets defaults for the garden client connection.
func SetDefaults_ClientConnectionConfiguration(obj *componentbaseconfigv1alpha1.ClientConnectionConfiguration) {
if obj.QPS == 0.0 {
obj.QPS = 50.0
}
if obj.Burst == 0 {
obj.Burst = 100
}
}
// SetDefaults_LeaderElectionConfiguration sets defaults for the leader election of the Gardener controller manager.
func SetDefaults_LeaderElectionConfiguration(obj *componentbaseconfigv1alpha1.LeaderElectionConfiguration) {
if obj.ResourceLock == "" {
// Don't use a constant from the client-go resourcelock package here (resourcelock is not an API package, pulls
// in some other dependencies and is thereby not suitable to be used in this API package).
obj.ResourceLock = "leases"
}
componentbaseconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(obj)
if obj.ResourceNamespace == "" {
obj.ResourceNamespace = ControllerManagerDefaultLockObjectNamespace
}
if obj.ResourceName == "" {
obj.ResourceName = ControllerManagerDefaultLockObjectName
}
}
// SetDefaults_ShootRetryControllerConfiguration sets defaults for the ShootRetryControllerConfiguration.
func SetDefaults_ShootRetryControllerConfiguration(obj *ShootRetryControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.RetryPeriod == nil {
obj.RetryPeriod = &metav1.Duration{Duration: 10 * time.Minute}
}
if obj.RetryJitterPeriod == nil {
obj.RetryJitterPeriod = &metav1.Duration{Duration: 5 * time.Minute}
}
}
// SetDefaults_SeedControllerConfiguration sets defaults for the given SeedControllerConfiguration.
func SetDefaults_SeedControllerConfiguration(obj *SeedControllerConfiguration) {
if obj.SyncPeriod == nil {
obj.SyncPeriod = &metav1.Duration{Duration: 10 * time.Second}
}
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.MonitorPeriod == nil {
obj.MonitorPeriod = &metav1.Duration{Duration: 40 * time.Second}
}
if obj.ShootMonitorPeriod == nil {
obj.ShootMonitorPeriod = &metav1.Duration{Duration: 5 * obj.MonitorPeriod.Duration}
}
}
// SetDefaults_ProjectControllerConfiguration sets defaults for the ProjectControllerConfiguration.
func SetDefaults_ProjectControllerConfiguration(obj *ProjectControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.MinimumLifetimeDays == nil {
obj.MinimumLifetimeDays = ptr.To(30)
}
if obj.StaleGracePeriodDays == nil {
obj.StaleGracePeriodDays = ptr.To(14)
}
if obj.StaleExpirationTimeDays == nil {
obj.StaleExpirationTimeDays = ptr.To(90)
}
if obj.StaleSyncPeriod == nil {
obj.StaleSyncPeriod = &metav1.Duration{
Duration: 12 * time.Hour,
}
}
for i, quota := range obj.Quotas {
if quota.ProjectSelector == nil {
obj.Quotas[i].ProjectSelector = &metav1.LabelSelector{}
}
}
}
// SetDefaults_ServerConfiguration sets defaults for the ServerConfiguration.
func SetDefaults_ServerConfiguration(obj *ServerConfiguration) {
if obj.HealthProbes == nil {
obj.HealthProbes = &Server{}
}
if obj.HealthProbes.Port == 0 {
obj.HealthProbes.Port = 2718
}
if obj.Metrics == nil {
obj.Metrics = &Server{}
}
if obj.Metrics.Port == 0 {
obj.Metrics.Port = 2719
}
}
// SetDefaults_BastionControllerConfiguration sets defaults for the BastionControllerConfiguration.
func SetDefaults_BastionControllerConfiguration(obj *BastionControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.MaxLifetime == nil {
obj.MaxLifetime = &metav1.Duration{Duration: 24 * time.Hour}
}
}
// SetDefaults_CertificateSigningRequestControllerConfiguration sets defaults for the CertificateSigningRequestControllerConfiguration.
func SetDefaults_CertificateSigningRequestControllerConfiguration(obj *CertificateSigningRequestControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_CloudProfileControllerConfiguration sets defaults for the CloudProfileControllerConfiguration.
func SetDefaults_CloudProfileControllerConfiguration(obj *CloudProfileControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_ControllerDeploymentControllerConfiguration sets defaults for the ControllerDeploymentControllerConfiguration.
func SetDefaults_ControllerDeploymentControllerConfiguration(obj *ControllerDeploymentControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_ControllerRegistrationControllerConfiguration sets defaults for the ControllerRegistrationControllerConfiguration.
func SetDefaults_ControllerRegistrationControllerConfiguration(obj *ControllerRegistrationControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_ExposureClassControllerConfiguration sets defaults for the ExposureClassControllerConfiguration.
func SetDefaults_ExposureClassControllerConfiguration(obj *ExposureClassControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_QuotaControllerConfiguration sets defaults for the QuotaControllerConfiguration.
func SetDefaults_QuotaControllerConfiguration(obj *QuotaControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_SecretBindingControllerConfiguration sets defaults for the SecretBindingControllerConfiguration.
func SetDefaults_SecretBindingControllerConfiguration(obj *SecretBindingControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_SeedExtensionsCheckControllerConfiguration sets defaults for the SeedExtensionsCheckControllerConfiguration.
func SetDefaults_SeedExtensionsCheckControllerConfiguration(obj *SeedExtensionsCheckControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.SyncPeriod == nil {
obj.SyncPeriod = &metav1.Duration{Duration: 30 * time.Second}
}
}
// SetDefaults_SeedBackupBucketsCheckControllerConfiguration sets defaults for the SeedBackupBucketsCheckControllerConfiguration.
func SetDefaults_SeedBackupBucketsCheckControllerConfiguration(obj *SeedBackupBucketsCheckControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.SyncPeriod == nil {
obj.SyncPeriod = &metav1.Duration{Duration: 30 * time.Second}
}
}
// SetDefaults_ShootHibernationControllerConfiguration sets defaults for the ShootHibernationControllerConfiguration.
func SetDefaults_ShootHibernationControllerConfiguration(obj *ShootHibernationControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.TriggerDeadlineDuration == nil {
obj.TriggerDeadlineDuration = &metav1.Duration{Duration: 2 * time.Hour}
}
}
// SetDefaults_ShootMaintenanceControllerConfiguration sets defaults for the ShootMaintenanceControllerConfiguration.
func SetDefaults_ShootMaintenanceControllerConfiguration(obj *ShootMaintenanceControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.EnableShootControlPlaneRestarter == nil {
obj.EnableShootControlPlaneRestarter = ptr.To(true)
}
}
// SetDefaults_ShootQuotaControllerConfiguration sets defaults for the ShootQuotaControllerConfiguration.
func SetDefaults_ShootQuotaControllerConfiguration(obj *ShootQuotaControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.SyncPeriod == nil {
obj.SyncPeriod = &metav1.Duration{
Duration: 60 * time.Minute,
}
}
}
// SetDefaults_ShootReferenceControllerConfiguration sets defaults for the ShootReferenceControllerConfiguration.
func SetDefaults_ShootReferenceControllerConfiguration(obj *ShootReferenceControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_ShootConditionsControllerConfiguration sets defaults for the ShootConditionsControllerConfiguration.
func SetDefaults_ShootConditionsControllerConfiguration(obj *ShootConditionsControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_EventControllerConfiguration sets defaults for the EventControllerConfiguration.
func SetDefaults_EventControllerConfiguration(obj *EventControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.TTLNonShootEvents == nil {
obj.TTLNonShootEvents = &metav1.Duration{Duration: 1 * time.Hour}
}
}
// SetDefaults_ShootStatusLabelControllerConfiguration sets defaults for the ShootStatusLabelControllerConfiguration.
func SetDefaults_ShootStatusLabelControllerConfiguration(obj *ShootStatusLabelControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
}
// SetDefaults_ManagedSeedSetControllerConfiguration sets defaults for the ManagedSeedSetControllerConfiguration.
func SetDefaults_ManagedSeedSetControllerConfiguration(obj *ManagedSeedSetControllerConfiguration) {
if obj.ConcurrentSyncs == nil {
obj.ConcurrentSyncs = ptr.To(DefaultControllerConcurrentSyncs)
}
if obj.MaxShootRetries == nil {
obj.MaxShootRetries = ptr.To(3)
}
}
// SetDefaults_ControllerManagerControllerConfiguration sets defaults for the ControllerManagerControllerConfiguration.
func SetDefaults_ControllerManagerControllerConfiguration(obj *ControllerManagerControllerConfiguration) {
if obj.Bastion == nil {
obj.Bastion = &BastionControllerConfiguration{}
}
if obj.CertificateSigningRequest == nil {
obj.CertificateSigningRequest = &CertificateSigningRequestControllerConfiguration{}
}
if obj.CloudProfile == nil {
obj.CloudProfile = &CloudProfileControllerConfiguration{}
}
if obj.ControllerDeployment == nil {
obj.ControllerDeployment = &ControllerDeploymentControllerConfiguration{}
}
if obj.ControllerRegistration == nil {
obj.ControllerRegistration = &ControllerRegistrationControllerConfiguration{}
}
if obj.ExposureClass == nil {
obj.ExposureClass = &ExposureClassControllerConfiguration{}
}
if obj.Project == nil {
obj.Project = &ProjectControllerConfiguration{}
}
if obj.Quota == nil {
obj.Quota = &QuotaControllerConfiguration{}
}
if obj.SecretBinding == nil {
obj.SecretBinding = &SecretBindingControllerConfiguration{}
}
if obj.Seed == nil {
obj.Seed = &SeedControllerConfiguration{}
}
if obj.SeedExtensionsCheck == nil {
obj.SeedExtensionsCheck = &SeedExtensionsCheckControllerConfiguration{}
}
if obj.SeedBackupBucketsCheck == nil {
obj.SeedBackupBucketsCheck = &SeedBackupBucketsCheckControllerConfiguration{}
}
if obj.ShootQuota == nil {
obj.ShootQuota = &ShootQuotaControllerConfiguration{}
}
if obj.ShootReference == nil {
obj.ShootReference = &ShootReferenceControllerConfiguration{}
}
if obj.ShootRetry == nil {
obj.ShootRetry = &ShootRetryControllerConfiguration{}
}
if obj.ShootConditions == nil {
obj.ShootConditions = &ShootConditionsControllerConfiguration{}
}
if obj.ShootStatusLabel == nil {
obj.ShootStatusLabel = &ShootStatusLabelControllerConfiguration{}
}
if obj.ManagedSeedSet == nil {
obj.ManagedSeedSet = &ManagedSeedSetControllerConfiguration{
SyncPeriod: metav1.Duration{
Duration: 30 * time.Minute,
},
}
}
}