@@ -28,7 +28,7 @@ import (
28
28
"k8s.io/kubernetes/cmd/kubeadm/app/util/pkiutil"
29
29
)
30
30
31
- type configMutatorsFunc func (* kubeadmapi.InitConfiguration , * certutil. Config ) error
31
+ type configMutatorsFunc func (* kubeadmapi.InitConfiguration , * pkiutil. CertConfig ) error
32
32
33
33
// KubeadmCert represents a certificate that Kubeadm will create to function properly.
34
34
type KubeadmCert struct {
@@ -39,17 +39,18 @@ type KubeadmCert struct {
39
39
// Some attributes will depend on the InitConfiguration, only known at runtime.
40
40
// These functions will be run in series, passed both the InitConfiguration and a cert Config.
41
41
configMutators []configMutatorsFunc
42
- config certutil. Config
42
+ config pkiutil. CertConfig
43
43
}
44
44
45
45
// GetConfig returns the definition for the given cert given the provided InitConfiguration
46
- func (k * KubeadmCert ) GetConfig (ic * kubeadmapi.InitConfiguration ) (* certutil. Config , error ) {
46
+ func (k * KubeadmCert ) GetConfig (ic * kubeadmapi.InitConfiguration ) (* pkiutil. CertConfig , error ) {
47
47
for _ , f := range k .configMutators {
48
48
if err := f (ic , & k .config ); err != nil {
49
49
return nil , err
50
50
}
51
51
}
52
52
53
+ k .config .PublicKeyAlgorithm = ic .ClusterConfiguration .PublicKeyAlgorithm ()
53
54
return & k .config , nil
54
55
}
55
56
@@ -239,8 +240,10 @@ var (
239
240
Name : "ca" ,
240
241
LongName : "self-signed Kubernetes CA to provision identities for other Kubernetes components" ,
241
242
BaseName : kubeadmconstants .CACertAndKeyBaseName ,
242
- config : certutil.Config {
243
- CommonName : "kubernetes" ,
243
+ config : pkiutil.CertConfig {
244
+ Config : certutil.Config {
245
+ CommonName : "kubernetes" ,
246
+ },
244
247
},
245
248
}
246
249
// KubeadmCertAPIServer is the definition of the cert used to serve the Kubernetes API.
@@ -249,9 +252,11 @@ var (
249
252
LongName : "certificate for serving the Kubernetes API" ,
250
253
BaseName : kubeadmconstants .APIServerCertAndKeyBaseName ,
251
254
CAName : "ca" ,
252
- config : certutil.Config {
253
- CommonName : kubeadmconstants .APIServerCertCommonName ,
254
- Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageServerAuth },
255
+ config : pkiutil.CertConfig {
256
+ Config : certutil.Config {
257
+ CommonName : kubeadmconstants .APIServerCertCommonName ,
258
+ Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageServerAuth },
259
+ },
255
260
},
256
261
configMutators : []configMutatorsFunc {
257
262
makeAltNamesMutator (pkiutil .GetAPIServerAltNames ),
@@ -263,10 +268,12 @@ var (
263
268
LongName : "certificate for the API server to connect to kubelet" ,
264
269
BaseName : kubeadmconstants .APIServerKubeletClientCertAndKeyBaseName ,
265
270
CAName : "ca" ,
266
- config : certutil.Config {
267
- CommonName : kubeadmconstants .APIServerKubeletClientCertCommonName ,
268
- Organization : []string {kubeadmconstants .SystemPrivilegedGroup },
269
- Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
271
+ config : pkiutil.CertConfig {
272
+ Config : certutil.Config {
273
+ CommonName : kubeadmconstants .APIServerKubeletClientCertCommonName ,
274
+ Organization : []string {kubeadmconstants .SystemPrivilegedGroup },
275
+ Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
276
+ },
270
277
},
271
278
}
272
279
@@ -275,8 +282,10 @@ var (
275
282
Name : "front-proxy-ca" ,
276
283
LongName : "self-signed CA to provision identities for front proxy" ,
277
284
BaseName : kubeadmconstants .FrontProxyCACertAndKeyBaseName ,
278
- config : certutil.Config {
279
- CommonName : "front-proxy-ca" ,
285
+ config : pkiutil.CertConfig {
286
+ Config : certutil.Config {
287
+ CommonName : "front-proxy-ca" ,
288
+ },
280
289
},
281
290
}
282
291
@@ -286,9 +295,11 @@ var (
286
295
BaseName : kubeadmconstants .FrontProxyClientCertAndKeyBaseName ,
287
296
LongName : "certificate for the front proxy client" ,
288
297
CAName : "front-proxy-ca" ,
289
- config : certutil.Config {
290
- CommonName : kubeadmconstants .FrontProxyClientCertCommonName ,
291
- Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
298
+ config : pkiutil.CertConfig {
299
+ Config : certutil.Config {
300
+ CommonName : kubeadmconstants .FrontProxyClientCertCommonName ,
301
+ Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
302
+ },
292
303
},
293
304
}
294
305
@@ -297,8 +308,10 @@ var (
297
308
Name : "etcd-ca" ,
298
309
LongName : "self-signed CA to provision identities for etcd" ,
299
310
BaseName : kubeadmconstants .EtcdCACertAndKeyBaseName ,
300
- config : certutil.Config {
301
- CommonName : "etcd-ca" ,
311
+ config : pkiutil.CertConfig {
312
+ Config : certutil.Config {
313
+ CommonName : "etcd-ca" ,
314
+ },
302
315
},
303
316
}
304
317
// KubeadmCertEtcdServer is the definition of the cert used to serve etcd to clients.
@@ -307,12 +320,14 @@ var (
307
320
LongName : "certificate for serving etcd" ,
308
321
BaseName : kubeadmconstants .EtcdServerCertAndKeyBaseName ,
309
322
CAName : "etcd-ca" ,
310
- config : certutil.Config {
311
- // TODO: etcd 3.2 introduced an undocumented requirement for ClientAuth usage on the
312
- // server cert: https://github.com/coreos/etcd/issues/9785#issuecomment-396715692
313
- // Once the upstream issue is resolved, this should be returned to only allowing
314
- // ServerAuth usage.
315
- Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageServerAuth , x509 .ExtKeyUsageClientAuth },
323
+ config : pkiutil.CertConfig {
324
+ Config : certutil.Config {
325
+ // TODO: etcd 3.2 introduced an undocumented requirement for ClientAuth usage on the
326
+ // server cert: https://github.com/coreos/etcd/issues/9785#issuecomment-396715692
327
+ // Once the upstream issue is resolved, this should be returned to only allowing
328
+ // ServerAuth usage.
329
+ Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageServerAuth , x509 .ExtKeyUsageClientAuth },
330
+ },
316
331
},
317
332
configMutators : []configMutatorsFunc {
318
333
makeAltNamesMutator (pkiutil .GetEtcdAltNames ),
@@ -325,8 +340,10 @@ var (
325
340
LongName : "certificate for etcd nodes to communicate with each other" ,
326
341
BaseName : kubeadmconstants .EtcdPeerCertAndKeyBaseName ,
327
342
CAName : "etcd-ca" ,
328
- config : certutil.Config {
329
- Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageServerAuth , x509 .ExtKeyUsageClientAuth },
343
+ config : pkiutil.CertConfig {
344
+ Config : certutil.Config {
345
+ Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageServerAuth , x509 .ExtKeyUsageClientAuth },
346
+ },
330
347
},
331
348
configMutators : []configMutatorsFunc {
332
349
makeAltNamesMutator (pkiutil .GetEtcdPeerAltNames ),
@@ -339,10 +356,12 @@ var (
339
356
LongName : "certificate for liveness probes to healthcheck etcd" ,
340
357
BaseName : kubeadmconstants .EtcdHealthcheckClientCertAndKeyBaseName ,
341
358
CAName : "etcd-ca" ,
342
- config : certutil.Config {
343
- CommonName : kubeadmconstants .EtcdHealthcheckClientCertCommonName ,
344
- Organization : []string {kubeadmconstants .SystemPrivilegedGroup },
345
- Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
359
+ config : pkiutil.CertConfig {
360
+ Config : certutil.Config {
361
+ CommonName : kubeadmconstants .EtcdHealthcheckClientCertCommonName ,
362
+ Organization : []string {kubeadmconstants .SystemPrivilegedGroup },
363
+ Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
364
+ },
346
365
},
347
366
}
348
367
// KubeadmCertEtcdAPIClient is the definition of the cert used by the API server to access etcd.
@@ -351,16 +370,18 @@ var (
351
370
LongName : "certificate the apiserver uses to access etcd" ,
352
371
BaseName : kubeadmconstants .APIServerEtcdClientCertAndKeyBaseName ,
353
372
CAName : "etcd-ca" ,
354
- config : certutil.Config {
355
- CommonName : kubeadmconstants .APIServerEtcdClientCertCommonName ,
356
- Organization : []string {kubeadmconstants .SystemPrivilegedGroup },
357
- Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
373
+ config : pkiutil.CertConfig {
374
+ Config : certutil.Config {
375
+ CommonName : kubeadmconstants .APIServerEtcdClientCertCommonName ,
376
+ Organization : []string {kubeadmconstants .SystemPrivilegedGroup },
377
+ Usages : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
378
+ },
358
379
},
359
380
}
360
381
)
361
382
362
383
func makeAltNamesMutator (f func (* kubeadmapi.InitConfiguration ) (* certutil.AltNames , error )) configMutatorsFunc {
363
- return func (mc * kubeadmapi.InitConfiguration , cc * certutil. Config ) error {
384
+ return func (mc * kubeadmapi.InitConfiguration , cc * pkiutil. CertConfig ) error {
364
385
altNames , err := f (mc )
365
386
if err != nil {
366
387
return err
@@ -371,7 +392,7 @@ func makeAltNamesMutator(f func(*kubeadmapi.InitConfiguration) (*certutil.AltNam
371
392
}
372
393
373
394
func setCommonNameToNodeName () configMutatorsFunc {
374
- return func (mc * kubeadmapi.InitConfiguration , cc * certutil. Config ) error {
395
+ return func (mc * kubeadmapi.InitConfiguration , cc * pkiutil. CertConfig ) error {
375
396
cc .CommonName = mc .NodeRegistration .Name
376
397
return nil
377
398
}
0 commit comments