8
8
9
9
corev1 "k8s.io/api/core/v1"
10
10
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
+ "k8s.io/utils/ptr"
11
12
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
12
13
13
14
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/openapi/patterns"
@@ -89,6 +90,9 @@ type GenericClusterConfig struct {
89
90
// +optional
90
91
ImageRegistries ImageRegistries `json:"imageRegistries,omitempty"`
91
92
93
+ // +optional
94
+ GlobalImageRegistryMirror * GlobalImageRegistryMirror `json:"globalImageRegistryMirror,omitempty"`
95
+
92
96
// +optional
93
97
Addons * Addons `json:"addons,omitempty"`
94
98
}
@@ -107,7 +111,8 @@ func (s GenericClusterConfig) VariableSchema() clusterv1.VariableSchema { //noli
107
111
"" ,
108
112
).VariableSchema ().
109
113
OpenAPIV3Schema ,
110
- "imageRegistries" : ImageRegistries {}.VariableSchema ().OpenAPIV3Schema ,
114
+ "imageRegistries" : ImageRegistries {}.VariableSchema ().OpenAPIV3Schema ,
115
+ "globalImageRegistryMirror" : GlobalImageRegistryMirror {}.VariableSchema ().OpenAPIV3Schema ,
111
116
},
112
117
},
113
118
}
@@ -237,84 +242,111 @@ func (ExtraAPIServerCertSANs) VariableSchema() clusterv1.VariableSchema {
237
242
}
238
243
}
239
244
240
- type ImageRegistries struct {
245
+ type RegistryCredentials struct {
246
+ // The Secret containing the registry credentials and optional CA certificate
247
+ // using the keys `username`, `password` and `ca.crt`.
248
+ // This credentials Secret is not required for some registries, e.g. ECR.
241
249
// +optional
242
- ImageRegistryCredentials ImageRegistryCredentials `json:"credentials ,omitempty"`
250
+ SecretRef * corev1. ObjectReference `json:"secretRef ,omitempty"`
243
251
}
244
252
245
- func (ImageRegistries ) VariableSchema () clusterv1.VariableSchema {
253
+ func (RegistryCredentials ) VariableSchema () clusterv1.VariableSchema {
246
254
return clusterv1.VariableSchema {
247
255
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
248
- Description : "Configuration for image registries." ,
249
- Type : "object" ,
256
+ Type : "object" ,
250
257
Properties : map [string ]clusterv1.JSONSchemaProps {
251
- "credentials" : ImageRegistryCredentials {}.VariableSchema ().OpenAPIV3Schema ,
258
+ "secretRef" : {
259
+ Description : "A reference to the Secret containing the registry credentials. " +
260
+ "The Secret should have keys 'username', 'password' and optional 'ca.crt'. " +
261
+ "This credentials Secret is not required for some registries, e.g. ECR." ,
262
+ Type : "object" ,
263
+ Properties : map [string ]clusterv1.JSONSchemaProps {
264
+ "name" : {
265
+ Description : "The name of the Secret containing the registry credentials." ,
266
+ Type : "string" ,
267
+ },
268
+ "namespace" : {
269
+ Description : "The namespace of the Secret containing the registry credentials. " +
270
+ "Defaults to the namespace of the Cluster. " +
271
+ "that reference this variable." ,
272
+ Type : "string" ,
273
+ },
274
+ },
275
+ Required : []string {"name" },
276
+ },
252
277
},
253
278
},
254
279
}
255
280
}
256
281
257
- type ImageRegistryCredentials []ImageRegistryCredentialsResource
282
+ // GlobalImageRegistryMirror sets default mirror configuration for all the image registries.
283
+ type GlobalImageRegistryMirror struct {
284
+ // Registry URL.
285
+ URL string `json:"url"`
258
286
259
- func (ImageRegistryCredentials ) VariableSchema () clusterv1.VariableSchema {
260
- resourceSchema := ImageRegistryCredentialsResource {}.VariableSchema ().OpenAPIV3Schema
287
+ // Credentials and CA certificate for the image registry mirror
288
+ // +optional
289
+ Credentials * RegistryCredentials `json:"credentials,omitempty"`
290
+ }
261
291
292
+ func (GlobalImageRegistryMirror ) VariableSchema () clusterv1.VariableSchema {
262
293
return clusterv1.VariableSchema {
263
294
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
264
- Description : "Image registry credentials to set up on all Nodes in the cluster. " +
265
- "Enabling this will configure the Kubelets with " +
266
- "https://kubernetes.io/docs/tasks/administer-cluster/kubelet-credential-provider/." ,
267
- Type : "array" ,
268
- Items : & resourceSchema ,
295
+ Type : "object" ,
296
+ Properties : map [string ]clusterv1.JSONSchemaProps {
297
+ "url" : {
298
+ Description : "Registry mirror URL." ,
299
+ Type : "string" ,
300
+ Format : "uri" ,
301
+ Pattern : "^https?://" ,
302
+ },
303
+ "credentials" : RegistryCredentials {}.VariableSchema ().OpenAPIV3Schema ,
304
+ },
305
+ Required : []string {"url" },
269
306
},
270
307
}
271
308
}
272
309
273
- // ImageRegistryCredentialsResource required for providing credentials for an image registry URL.
274
- type ImageRegistryCredentialsResource struct {
310
+ type ImageRegistry struct {
275
311
// Registry URL.
276
312
URL string `json:"url"`
277
313
278
- // The Secret containing the registry credentials.
279
- // The Secret should have keys 'username' and 'password'.
280
- // This credentials Secret is not required for some registries, e.g. ECR.
314
+ // Credentials and CA certificate for the image registry
281
315
// +optional
282
- Secret * corev1. ObjectReference `json:"secretRef ,omitempty"`
316
+ Credentials * RegistryCredentials `json:"credentials ,omitempty"`
283
317
}
284
318
285
- func (ImageRegistryCredentialsResource ) VariableSchema () clusterv1.VariableSchema {
319
+ func (ImageRegistry ) VariableSchema () clusterv1.VariableSchema {
286
320
return clusterv1.VariableSchema {
287
321
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
288
322
Type : "object" ,
289
323
Properties : map [string ]clusterv1.JSONSchemaProps {
290
324
"url" : {
291
325
Description : "Registry URL." ,
292
326
Type : "string" ,
327
+ Format : "uri" ,
328
+ Pattern : "^https?://" ,
293
329
},
294
- "secretRef" : {
295
- Description : "The Secret containing the registry credentials. " +
296
- "The Secret should have keys 'username' and 'password'. " +
297
- "This credentials Secret is not required for some registries, e.g. ECR." ,
298
- Type : "object" ,
299
- Properties : map [string ]clusterv1.JSONSchemaProps {
300
- "name" : {
301
- Description : "The name of the Secret containing the registry credentials." ,
302
- Type : "string" ,
303
- },
304
- "namespace" : {
305
- Description : "The namespace of the Secret containing the registry credentials. " +
306
- "Defaults to the namespace of the KubeadmControlPlaneTemplate and KubeadmConfigTemplate" +
307
- " that reference this variable." ,
308
- Type : "string" ,
309
- },
310
- },
311
- },
330
+ "credentials" : RegistryCredentials {}.VariableSchema ().OpenAPIV3Schema ,
312
331
},
313
332
Required : []string {"url" },
314
333
},
315
334
}
316
335
}
317
336
337
+ type ImageRegistries []ImageRegistry
338
+
339
+ func (ImageRegistries ) VariableSchema () clusterv1.VariableSchema {
340
+ return clusterv1.VariableSchema {
341
+ OpenAPIV3Schema : clusterv1.JSONSchemaProps {
342
+ Description : "Configuration for image registries." ,
343
+ Type : "array" ,
344
+ Items : ptr .To (ImageRegistry {}.VariableSchema ().OpenAPIV3Schema ),
345
+ MaxItems : ptr.To [int64 ](1 ),
346
+ },
347
+ }
348
+ }
349
+
318
350
func init () {
319
351
SchemeBuilder .Register (& ClusterConfig {})
320
352
}
0 commit comments