Skip to content

Commit e29086e

Browse files
committed
Address review comments
1 parent 1a13048 commit e29086e

File tree

23 files changed

+240
-178
lines changed

23 files changed

+240
-178
lines changed

api/bootstrap/kubeadm/v1beta2/kubeadm_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ type ClusterConfiguration struct {
217217
// +kubebuilder:validation:Maximum=36500
218218
CACertificateValidityPeriodDays int32 `json:"caCertificateValidityPeriodDays,omitempty"`
219219

220-
// EncryptionAlgorithm holds the type of asymmetric encryption algorithm used for keys and certificates.
220+
// encryptionAlgorithm holds the type of asymmetric encryption algorithm used for keys and certificates.
221221
// Can be one of "RSA-2048", "RSA-3072", "RSA-4096", "ECDSA-P256" or "ECDSA-P384".
222222
// If not specified, Cluster API will use RSA-2048 as default.
223-
// This field is only supported with Kubernetes v1.34 or above.
223+
// This field is only supported with Kubernetes v1.31 or above.
224224
// +optional
225225
EncryptionAlgorithm EncryptionAlgorithmType `json:"encryptionAlgorithm,omitempty"`
226226
}

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

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

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml

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

bootstrap/kubeadm/types/upstreamv1beta4/conversion.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ func Convert_upstreamv1beta4_ClusterConfiguration_To_v1beta2_ClusterConfiguratio
7272
}
7373
out.CertificateValidityPeriodDays = convertToDays(in.CertificateValidityPeriod)
7474
out.CACertificateValidityPeriodDays = convertToDays(in.CACertificateValidityPeriod)
75-
out.EncryptionAlgorithm = bootstrapv1.EncryptionAlgorithmType(in.EncryptionAlgorithm)
7675
return nil
7776
}
7877

@@ -83,7 +82,6 @@ func Convert_v1beta2_ClusterConfiguration_To_upstreamv1beta4_ClusterConfiguratio
8382
}
8483
out.CertificateValidityPeriod = convertFromDays(in.CertificateValidityPeriodDays)
8584
out.CACertificateValidityPeriod = convertFromDays(in.CACertificateValidityPeriodDays)
86-
out.EncryptionAlgorithm = EncryptionAlgorithmType(in.EncryptionAlgorithm)
8785
return nil
8886
}
8987

controllers/clustercache/cluster_accessor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (ca *clusterAccessor) Connect(ctx context.Context) (retErr error) {
286286
// private key generation fails because we check Connected above.
287287
if ca.lockedState.clientCertificatePrivateKey == nil {
288288
log.V(6).Info("Generating client certificate private key")
289-
clientCertificatePrivateKey, err := certs.NewPrivateKey("")
289+
clientCertificatePrivateKey, err := certs.NewPrivateKey()
290290
if err != nil {
291291
return errors.Wrapf(err, "error creating client certificate private key")
292292
}

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml

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

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml

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

controlplane/kubeadm/internal/cluster_test.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package internal
1818

1919
import (
2020
"context"
21-
"crypto"
2221
"crypto/rand"
22+
"crypto/rsa"
2323
"crypto/x509"
2424
"crypto/x509/pkix"
2525
"fmt"
@@ -90,15 +90,10 @@ func TestGetWorkloadCluster(t *testing.T) {
9090
}()
9191

9292
// Create an etcd secret with valid certs
93-
key, err := certs.NewPrivateKey("")
93+
key, err := certs.NewPrivateKey()
9494
g.Expect(err).ToNot(HaveOccurred())
95-
9695
cert, err := getTestCACert(key)
9796
g.Expect(err).ToNot(HaveOccurred())
98-
99-
encodedKey, err := certs.EncodePrivateKeyPEM(key)
100-
g.Expect(err).ToNot(HaveOccurred())
101-
10297
etcdSecret := &corev1.Secret{
10398
ObjectMeta: metav1.ObjectMeta{
10499
Name: "my-cluster-etcd",
@@ -109,7 +104,7 @@ func TestGetWorkloadCluster(t *testing.T) {
109104
},
110105
Data: map[string][]byte{
111106
secret.TLSCrtDataName: certs.EncodeCertPEM(cert),
112-
secret.TLSKeyDataName: encodedKey,
107+
secret.TLSKeyDataName: certs.EncodePrivateKeyPEM(key),
113108
},
114109
}
115110
emptyCrtEtcdSecret := etcdSecret.DeepCopy()
@@ -266,7 +261,7 @@ func TestGetWorkloadCluster(t *testing.T) {
266261
}
267262
}
268263

269-
func getTestCACert(key crypto.Signer) (*x509.Certificate, error) {
264+
func getTestCACert(key *rsa.PrivateKey) (*x509.Certificate, error) {
270265
cfg := certs.Config{
271266
CommonName: "kubernetes",
272267
}

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, controlPl
429429
}
430430

431431
// Generate Cluster Kubeconfig if needed
432-
if result, err := r.reconcileKubeconfig(ctx, controlPlane); err != nil || !result.IsZero() {
432+
if result, err := r.reconcileKubeconfig(ctx, controlPlane); !result.IsZero() || err != nil {
433433
if err != nil {
434434
log.Error(err, "Failed to reconcile Kubeconfig")
435435
}

controlplane/kubeadm/internal/controllers/controller_test.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package controllers
1818

1919
import (
2020
"context"
21-
"crypto"
2221
"crypto/rand"
22+
"crypto/rsa"
2323
"crypto/x509"
2424
"crypto/x509/pkix"
2525
"fmt"
@@ -813,16 +813,11 @@ func TestKubeadmControlPlaneReconciler_ensureOwnerReferences(t *testing.T) {
813813
cluster.Spec.ControlPlaneEndpoint.Port = 6443
814814
cluster.Status.Initialization.InfrastructureProvisioned = ptr.To(true)
815815
kcp.Spec.Version = "v1.21.0"
816-
817-
key, err := certs.NewPrivateKey("")
816+
key, err := certs.NewPrivateKey()
818817
g.Expect(err).ToNot(HaveOccurred())
819-
820818
crt, err := getTestCACert(key)
821819
g.Expect(err).ToNot(HaveOccurred())
822820

823-
encodedKey, err := certs.EncodePrivateKeyPEM(key)
824-
g.Expect(err).ToNot(HaveOccurred())
825-
826821
clusterSecret := &corev1.Secret{
827822
// The Secret's Type is used by KCP to determine whether it is user-provided.
828823
// clusterv1.ClusterSecretType signals that the Secret is CAPI-provided.
@@ -836,7 +831,7 @@ func TestKubeadmControlPlaneReconciler_ensureOwnerReferences(t *testing.T) {
836831
},
837832
Data: map[string][]byte{
838833
secret.TLSCrtDataName: certs.EncodeCertPEM(crt),
839-
secret.TLSKeyDataName: encodedKey,
834+
secret.TLSKeyDataName: certs.EncodePrivateKeyPEM(key),
840835
},
841836
}
842837

@@ -4113,7 +4108,7 @@ func newCluster(namespacedName *types.NamespacedName) *clusterv1.Cluster {
41134108
}
41144109
}
41154110

4116-
func getTestCACert(key crypto.Signer) (*x509.Certificate, error) {
4111+
func getTestCACert(key *rsa.PrivateKey) (*x509.Certificate, error) {
41174112
cfg := certs.Config{
41184113
CommonName: "kubernetes",
41194114
}

0 commit comments

Comments
 (0)