Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/openshift-install/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ var (
&manifests.AgentManifests{},
&mirror.RegistriesConf{},
&mirror.CaBundle{},
// Persist PKI config to the state file so that signer certs
// generated in a subsequent agent create image use the correct
// key algorithm after install-config.yaml has been consumed.
&tls.SignerKeyParams{},
},
}

Expand Down Expand Up @@ -129,6 +133,10 @@ var (
&tls.KubeAPIServerServiceNetworkSignerCertKey{},
&tls.AdminKubeConfigSignerCertKey{},
&image.AgentPassword{},
// Persist PKI config to the state file so that signer certs
// generated in a subsequent agent create image use the correct
// key algorithm after install-config.yaml has been consumed.
&tls.SignerKeyParams{},
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ func TestArbiterIgnitionCustomizationsGenerate(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
rootCAParents := asset.Parents{}
rootCAParents.Add(&tls.SignerKeyParams{})
rootCA := &tls.RootCA{}
err := rootCA.Generate(context.Background(), nil)
err := rootCA.Generate(context.Background(), rootCAParents)
assert.NoError(t, err, "unexpected error generating root CA")

parents := asset.Parents{}
Expand Down
4 changes: 3 additions & 1 deletion pkg/asset/ignition/machine/arbiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ func TestArbiterGenerate(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
rootCAParents := asset.Parents{}
rootCAParents.Add(&tls.SignerKeyParams{})
rootCA := &tls.RootCA{}
err := rootCA.Generate(context.Background(), nil)
err := rootCA.Generate(context.Background(), rootCAParents)
assert.NoError(t, err, "unexpected error generating root CA")

parents := asset.Parents{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ func TestMasterIgnitionCustomizationsGenerate(t *testing.T) {
},
})

rootCAParents := asset.Parents{}
rootCAParents.Add(&tls.SignerKeyParams{})
rootCA := &tls.RootCA{}
err := rootCA.Generate(context.Background(), nil)
err := rootCA.Generate(context.Background(), rootCAParents)
assert.NoError(t, err, "unexpected error generating root CA")

parents := asset.Parents{}
Expand Down
4 changes: 3 additions & 1 deletion pkg/asset/ignition/machine/master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func TestMasterGenerate(t *testing.T) {
},
})

rootCAParents := asset.Parents{}
rootCAParents.Add(&tls.SignerKeyParams{})
rootCA := &tls.RootCA{}
err := rootCA.Generate(context.Background(), nil)
err := rootCA.Generate(context.Background(), rootCAParents)
assert.NoError(t, err, "unexpected error generating root CA")

parents := asset.Parents{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ func TestWorkerIgnitionCustomizationsGenerate(t *testing.T) {
},
})

rootCAParents := asset.Parents{}
rootCAParents.Add(&tls.SignerKeyParams{})
rootCA := &tls.RootCA{}
err := rootCA.Generate(context.Background(), nil)
err := rootCA.Generate(context.Background(), rootCAParents)
assert.NoError(t, err, "unexpected error generating root CA")

parents := asset.Parents{}
Expand Down
4 changes: 3 additions & 1 deletion pkg/asset/ignition/machine/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ func TestWorkerGenerate(t *testing.T) {
},
})

rootCAParents := asset.Parents{}
rootCAParents.Add(&tls.SignerKeyParams{})
rootCA := &tls.RootCA{}
err := rootCA.Generate(context.Background(), nil)
err := rootCA.Generate(context.Background(), rootCAParents)
assert.NoError(t, err, "unexpected error generating root CA")

parents := asset.Parents{}
Expand Down
1 change: 1 addition & 0 deletions pkg/asset/store/assetcreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func TestCreatedAssetsAreNotDirty(t *testing.T) {
"Kubeadmin Password": true, // read-only
"InternalReleaseImageTLSSecret": true, // no files when NoRegistryClusterInstall feature gate is not set
"InternalReleaseImageRegistryAuthSecret": true, // no files when NoRegistryClusterInstall feature gate is not set
"Signer Key Parameters": true, // no on-disk files; persisted via state file only
}
for _, a := range tc.targets {
name := a.Name()
Expand Down
4 changes: 4 additions & 0 deletions pkg/asset/targets/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ var (
&manifests.Manifests{},
&manifests.Openshift{},
&clusterapi.Cluster{},
// Persist PKI config to the state file so that signer certs
// generated in a subsequent create cluster use the correct
// key algorithm after install-config.yaml has been consumed.
&tls.SignerKeyParams{},
}

// ManifestTemplates are the manifest-templates targeted assets.
Expand Down
13 changes: 10 additions & 3 deletions pkg/asset/tls/adminkubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@ type AdminKubeConfigSignerCertKey struct {

var _ asset.WritableAsset = (*AdminKubeConfigSignerCertKey)(nil)

// Dependencies returns the dependency of the root-ca, which is empty.
// Dependencies returns SignerKeyParams. Configurable PKI requires
// reading the PKI config from InstallConfig, but adding InstallConfig
// as a dependency here would break codepaths that generate signer certs
// without an install-config on disk (e.g. agent create certificates,
// node-joiner). SignerKeyParams reads the config directly from disk
// without triggering InstallConfig validation.
func (c *AdminKubeConfigSignerCertKey) Dependencies() []asset.Asset {
return []asset.Asset{}
return []asset.Asset{&SignerKeyParams{}}
}

// Generate generates the root-ca key and cert pair.
func (c *AdminKubeConfigSignerCertKey) Generate(ctx context.Context, parents asset.Parents) error {
signerKeyParams := &SignerKeyParams{}
parents.Get(signerKeyParams)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "admin-kubeconfig-signer", OrganizationalUnit: []string{"openshift"}},
// KeyUsages is set by GenerateSelfSignedCertificate based on the key algorithm.
Validity: ValidityTenYears(),
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "admin-kubeconfig-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "admin-kubeconfig-signer", signerKeyParams.PKIConfig)
}

// Load reads the asset files from disk.
Expand Down
5 changes: 3 additions & 2 deletions pkg/asset/tls/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
pkidefaults "github.com/openshift/installer/pkg/types/pki"
)

// AggregatorCA is the asset that generates the aggregator-ca key/cert pair.
Expand Down Expand Up @@ -38,7 +39,7 @@ func (a *AggregatorCA) Generate(ctx context.Context, dependencies asset.Parents)
IsCA: true,
}

return a.SelfSignedCertKey.Generate(ctx, cfg, "aggregator-ca", nil)
return a.SelfSignedCertKey.Generate(ctx, cfg, "aggregator-ca", pkidefaults.EffectiveSignerPKIConfig(installConfig.Config))
}

// Name returns the human-friendly name of the asset.
Expand Down Expand Up @@ -108,7 +109,7 @@ func (c *AggregatorSignerCertKey) Generate(ctx context.Context, parents asset.Pa
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "aggregator-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "aggregator-signer", pkidefaults.EffectiveSignerPKIConfig(installConfig.Config))
}

// Name returns the human-friendly name of the asset.
Expand Down
42 changes: 32 additions & 10 deletions pkg/asset/tls/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
pkidefaults "github.com/openshift/installer/pkg/types/pki"
)

// KubeAPIServerToKubeletSignerCertKey is a key/cert pair that signs the kube-apiserver to kubelet client certs.
Expand All @@ -35,7 +36,7 @@ func (c *KubeAPIServerToKubeletSignerCertKey) Generate(ctx context.Context, pare
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-to-kubelet-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-to-kubelet-signer", pkidefaults.EffectiveSignerPKIConfig(installConfig.Config))
}

// Name returns the human-friendly name of the asset.
Expand Down Expand Up @@ -116,21 +117,28 @@ type KubeAPIServerLocalhostSignerCertKey struct {

var _ asset.WritableAsset = (*KubeAPIServerLocalhostSignerCertKey)(nil)

// Dependencies returns the dependency of the root-ca, which is empty.
// Dependencies returns SignerKeyParams. Configurable PKI requires
// reading the PKI config from InstallConfig, but adding InstallConfig
// as a dependency here would break codepaths that generate signer certs
// without an install-config on disk (e.g. agent create certificates,
// node-joiner). SignerKeyParams reads the config directly from disk
// without triggering InstallConfig validation.
func (c *KubeAPIServerLocalhostSignerCertKey) Dependencies() []asset.Asset {
return []asset.Asset{}
return []asset.Asset{&SignerKeyParams{}}
}

// Generate generates the root-ca key and cert pair.
func (c *KubeAPIServerLocalhostSignerCertKey) Generate(ctx context.Context, parents asset.Parents) error {
signerKeyParams := &SignerKeyParams{}
parents.Get(signerKeyParams)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "kube-apiserver-localhost-signer", OrganizationalUnit: []string{"openshift"}},
// KeyUsages is set by GenerateSelfSignedCertificate based on the key algorithm.
Validity: ValidityTenYears(),
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-localhost-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-localhost-signer", signerKeyParams.PKIConfig)
}

// Load reads the asset files from disk.
Expand Down Expand Up @@ -220,21 +228,28 @@ type KubeAPIServerServiceNetworkSignerCertKey struct {

var _ asset.WritableAsset = (*KubeAPIServerServiceNetworkSignerCertKey)(nil)

// Dependencies returns the dependency of the root-ca, which is empty.
// Dependencies returns SignerKeyParams. Configurable PKI requires
// reading the PKI config from InstallConfig, but adding InstallConfig
// as a dependency here would break codepaths that generate signer certs
// without an install-config on disk (e.g. agent create certificates,
// node-joiner). SignerKeyParams reads the config directly from disk
// without triggering InstallConfig validation.
func (c *KubeAPIServerServiceNetworkSignerCertKey) Dependencies() []asset.Asset {
return []asset.Asset{}
return []asset.Asset{&SignerKeyParams{}}
}

// Generate generates the root-ca key and cert pair.
func (c *KubeAPIServerServiceNetworkSignerCertKey) Generate(ctx context.Context, parents asset.Parents) error {
signerKeyParams := &SignerKeyParams{}
parents.Get(signerKeyParams)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "kube-apiserver-service-network-signer", OrganizationalUnit: []string{"openshift"}},
// KeyUsages is set by GenerateSelfSignedCertificate based on the key algorithm.
Validity: ValidityTenYears(),
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-service-network-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-service-network-signer", signerKeyParams.PKIConfig)
}

// Load reads the asset files from disk.
Expand Down Expand Up @@ -333,21 +348,28 @@ type KubeAPIServerLBSignerCertKey struct {

var _ asset.WritableAsset = (*KubeAPIServerLBSignerCertKey)(nil)

// Dependencies returns the dependency of the root-ca, which is empty.
// Dependencies returns SignerKeyParams. Configurable PKI requires
// reading the PKI config from InstallConfig, but adding InstallConfig
// as a dependency here would break codepaths that generate signer certs
// without an install-config on disk (e.g. agent create certificates,
// node-joiner). SignerKeyParams reads the config directly from disk
// without triggering InstallConfig validation.
func (c *KubeAPIServerLBSignerCertKey) Dependencies() []asset.Asset {
return []asset.Asset{}
return []asset.Asset{&SignerKeyParams{}}
}

// Generate generates the root-ca key and cert pair.
func (c *KubeAPIServerLBSignerCertKey) Generate(ctx context.Context, parents asset.Parents) error {
signerKeyParams := &SignerKeyParams{}
parents.Get(signerKeyParams)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "kube-apiserver-lb-signer", OrganizationalUnit: []string{"openshift"}},
// KeyUsages is set by GenerateSelfSignedCertificate based on the key algorithm.
Validity: ValidityTenYears(),
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-lb-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-apiserver-lb-signer", signerKeyParams.PKIConfig)
}

// Load reads the asset files from disk.
Expand Down
3 changes: 2 additions & 1 deletion pkg/asset/tls/kubecontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
pkidefaults "github.com/openshift/installer/pkg/types/pki"
)

// KubeControlPlaneSignerCertKey is a key/cert pair that signs the kube control-plane client certs.
Expand All @@ -32,7 +33,7 @@ func (c *KubeControlPlaneSignerCertKey) Generate(ctx context.Context, parents as
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-control-plane-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "kube-control-plane-signer", pkidefaults.EffectiveSignerPKIConfig(installConfig.Config))
}

// Name returns the human-friendly name of the asset.
Expand Down
16 changes: 12 additions & 4 deletions pkg/asset/tls/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
pkidefaults "github.com/openshift/installer/pkg/types/pki"
)

// KubeletCSRSignerCertKey is a key/cert pair that signs the kubelet client certs.
Expand All @@ -32,7 +33,7 @@ func (c *KubeletCSRSignerCertKey) Generate(ctx context.Context, parents asset.Pa
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "kubelet-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "kubelet-signer", pkidefaults.EffectiveSignerPKIConfig(installConfig.Config))
}

// Name returns the human-friendly name of the asset.
Expand Down Expand Up @@ -108,21 +109,28 @@ type KubeletBootstrapCertSigner struct {

var _ asset.WritableAsset = (*KubeletBootstrapCertSigner)(nil)

// Dependencies returns the dependency of the root-ca, which is empty.
// Dependencies returns SignerKeyParams. Configurable PKI requires
// reading the PKI config from InstallConfig, but adding InstallConfig
// as a dependency here would break codepaths that generate signer certs
// without an install-config on disk (e.g. agent create certificates,
// node-joiner). SignerKeyParams reads the config directly from disk
// without triggering InstallConfig validation.
func (c *KubeletBootstrapCertSigner) Dependencies() []asset.Asset {
return []asset.Asset{}
return []asset.Asset{&SignerKeyParams{}}
}

// Generate generates the root-ca key and cert pair.
func (c *KubeletBootstrapCertSigner) Generate(ctx context.Context, parents asset.Parents) error {
signerKeyParams := &SignerKeyParams{}
parents.Get(signerKeyParams)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "kubelet-bootstrap-kubeconfig-signer", OrganizationalUnit: []string{"openshift"}},
// KeyUsages is set by GenerateSelfSignedCertificate based on the key algorithm.
Validity: ValidityTenYears(),
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "kubelet-bootstrap-kubeconfig-signer", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "kubelet-bootstrap-kubeconfig-signer", signerKeyParams.PKIConfig)
}

// Name returns the human-friendly name of the asset.
Expand Down
13 changes: 10 additions & 3 deletions pkg/asset/tls/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,28 @@ type RootCA struct {

var _ asset.WritableAsset = (*RootCA)(nil)

// Dependencies returns nothing.
// Dependencies returns SignerKeyParams. Configurable PKI requires
// reading the PKI config from InstallConfig, but adding InstallConfig
// as a dependency here would break codepaths that generate signer certs
// without an install-config on disk (e.g. agent create certificates,
// node-joiner). SignerKeyParams reads the config directly from disk
// without triggering InstallConfig validation.
func (c *RootCA) Dependencies() []asset.Asset {
return []asset.Asset{}
return []asset.Asset{&SignerKeyParams{}}
}

// Generate generates the MCS/Ignition CA.
func (c *RootCA) Generate(ctx context.Context, parents asset.Parents) error {
signerKeyParams := &SignerKeyParams{}
parents.Get(signerKeyParams)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "root-ca", OrganizationalUnit: []string{"openshift"}},
// KeyUsages is set by GenerateSelfSignedCertificate based on the key algorithm.
Validity: ValidityTenYears(),
IsCA: true,
}

return c.SelfSignedCertKey.Generate(ctx, cfg, "root-ca", nil)
return c.SelfSignedCertKey.Generate(ctx, cfg, "root-ca", signerKeyParams.PKIConfig)
}

// Name returns the human-friendly name of the asset.
Expand Down
Loading