-
Notifications
You must be signed in to change notification settings - Fork 1.5k
CNTRLPLANE-2012: Add configurable PKI support for installer-generated signer certificates #10396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hasbro17
wants to merge
6
commits into
openshift:main
Choose a base branch
from
hasbro17:install-config-pki
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f690580
pki: add PKI configuration field to InstallConfig
hasbro17 fd3945e
tls: refactor TLS cert generation to support configurable key algorithms
hasbro17 8a2c31d
pki: add unit tests for configurable PKI feature
hasbro17 1503bab
docs: add PKI configuration documentation to customization guide
hasbro17 68341be
pki: generate PKI CR manifest when ConfigurablePKI feature gate is en…
hasbro17 b0d099a
agent: provide minimal install-config for runtime cert generation
hasbro17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| package manifests | ||
|
|
||
| import ( | ||
| "context" | ||
| "path" | ||
|
|
||
| "github.com/pkg/errors" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "sigs.k8s.io/yaml" | ||
|
|
||
| configv1alpha1 "github.com/openshift/api/config/v1alpha1" | ||
| features "github.com/openshift/api/features" | ||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/installconfig" | ||
| pkidefaults "github.com/openshift/installer/pkg/types/pki" | ||
| ) | ||
|
|
||
| var pkiCfgFilename = path.Join(manifestDir, "cluster-pki-02-config.yaml") | ||
|
|
||
| // PKIConfiguration generates the PKI custom resource manifest. | ||
| type PKIConfiguration struct { | ||
| FileList []*asset.File | ||
| } | ||
|
|
||
| var _ asset.WritableAsset = (*PKIConfiguration)(nil) | ||
|
|
||
| // Name returns a human friendly name for the asset. | ||
| func (*PKIConfiguration) Name() string { | ||
| return "PKI Config" | ||
| } | ||
|
|
||
| // Dependencies returns all of the dependencies directly needed to generate | ||
| // the asset. | ||
| func (*PKIConfiguration) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &installconfig.InstallConfig{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate generates the PKI custom resource manifest. | ||
| // The manifest is only generated when the ConfigurablePKI feature gate is enabled. | ||
| func (p *PKIConfiguration) Generate(_ context.Context, dependencies asset.Parents) error { | ||
| installConfig := &installconfig.InstallConfig{} | ||
| dependencies.Get(installConfig) | ||
|
|
||
| if !installConfig.Config.Enabled(features.FeatureGateConfigurablePKI) { | ||
| return nil | ||
| } | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| certMgmt := configv1alpha1.PKICertificateManagement{ | ||
| Mode: configv1alpha1.PKICertificateManagementModeDefault, | ||
| } | ||
|
|
||
| if installConfig.Config.PKI != nil { | ||
| profile := pkidefaults.DefaultPKIProfile() | ||
| profile.SignerCertificates = pkidefaults.CertificateConfigToUpstream(installConfig.Config.PKI.SignerCertificates) | ||
|
|
||
| certMgmt = configv1alpha1.PKICertificateManagement{ | ||
| Mode: configv1alpha1.PKICertificateManagementModeCustom, | ||
| Custom: configv1alpha1.CustomPKIPolicy{ | ||
| PKIProfile: profile, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| config := &configv1alpha1.PKI{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| APIVersion: configv1alpha1.SchemeGroupVersion.String(), | ||
| Kind: "PKI", | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "cluster", | ||
| }, | ||
| Spec: configv1alpha1.PKISpec{ | ||
| CertificateManagement: certMgmt, | ||
| }, | ||
| } | ||
|
|
||
| configData, err := yaml.Marshal(config) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "failed to marshal PKI config") | ||
| } | ||
|
|
||
| p.FileList = []*asset.File{ | ||
| { | ||
| Filename: pkiCfgFilename, | ||
| Data: configData, | ||
| }, | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (p *PKIConfiguration) Files() []*asset.File { | ||
| return p.FileList | ||
| } | ||
|
|
||
| // Load returns false since this asset is not written to disk by the installer. | ||
| func (p *PKIConfiguration) Load(f asset.FileFetcher) (bool, error) { | ||
| return false, nil | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enforce the RSA/ECDSA invariants in the schema, not just in Go validation.
This schema only requires
key.algorithm. It still accepts invalid configs thatpkg/types/pki/validation.go:35-79rejects later, e.g.algorithm: RSAwithoutrsa.keySize,algorithm: ECDSAwithoutecdsa.curve, or both sub-blocks set. That makes schema-based validation lie about what the API accepts.Suggested schema shape
properties: key: description: key specifies the cryptographic parameters for the certificate's key pair. properties: algorithm: description: |- algorithm specifies the key generation algorithm. Valid values are "RSA" and "ECDSA". enum: - RSA - ECDSA type: string ecdsa: description: |- ecdsa specifies ECDSA key parameters. Required when algorithm is ECDSA, and forbidden otherwise. properties: curve: description: |- curve specifies the NIST elliptic curve for ECDSA keys. Valid values are "P256", "P384", and "P521". enum: - P256 - P384 - P521 type: string required: - curve type: object rsa: description: |- rsa specifies RSA key parameters. Required when algorithm is RSA, and forbidden otherwise. properties: keySize: description: |- keySize specifies the size of RSA keys in bits. Valid values are multiples of 1024 from 2048 to 8192. format: int32 maximum: 8192 minimum: 2048 multipleOf: 1024 type: integer required: - keySize type: object required: - algorithm type: object + x-kubernetes-validations: + - message: rsa.keySize is required when algorithm is RSA, and rsa must be unset otherwise + rule: 'self.algorithm == ''RSA'' ? has(self.rsa) && has(self.rsa.keySize) && !has(self.ecdsa) : !has(self.rsa)' + - message: ecdsa.curve is required when algorithm is ECDSA, and ecdsa must be unset otherwise + rule: 'self.algorithm == ''ECDSA'' ? has(self.ecdsa) && has(self.ecdsa.curve) && !has(self.rsa) : !has(self.ecdsa)'If this file is generated, please add the equivalent source annotations so regeneration preserves it.
📝 Committable suggestion
🤖 Prompt for AI Agents