-
Notifications
You must be signed in to change notification settings - Fork 1.5k
METAL-1105: support specifying CA to verify BMC connections #10072
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a502e90
feat: support specifying bmc verify ca
zouy414 6d3497d
Change BMC CA logic to use assets
dtantsur d0bcd09
Refactor BMC CA injection to make it a bootstrap asset
dtantsur 6f362cf
Simplify check on BMCVerifyCA in template
dtantsur 2cb7563
Merge branch 'main' into bmc-ca
zaneb 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
dtantsur marked this conversation as resolved.
Show resolved
Hide resolved
|
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,95 @@ | ||
| package manifests | ||
|
|
||
| import ( | ||
| "context" | ||
| "path" | ||
|
|
||
| "github.com/pkg/errors" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "sigs.k8s.io/yaml" | ||
|
|
||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/tls" | ||
| ) | ||
|
|
||
| var ( | ||
| bmcVerifyCAConfigMapFileName = path.Join("manifests", "bmc-verify-ca-configmap.yaml") | ||
| ) | ||
|
|
||
| const ( | ||
| bmcVerifyCAConfigMapName = "bmc-verify-ca" | ||
| bmcVerifyCAConfigMapNamespace = "openshift-machine-api" | ||
| bmcVerifyCAConfigMapDataKey = "verify_ca.crt" | ||
| ) | ||
|
|
||
| // BMCVerifyCAConfigMap generates the bmc-verify-ca ConfigMap. | ||
| type BMCVerifyCAConfigMap struct { | ||
| ConfigMap *corev1.ConfigMap | ||
| File *asset.File | ||
| } | ||
|
|
||
| var _ asset.WritableAsset = (*BMCVerifyCAConfigMap)(nil) | ||
|
|
||
| // Name returns a human friendly name for the asset. | ||
| func (*BMCVerifyCAConfigMap) Name() string { | ||
| return "BMC Verify CA ConfigMap" | ||
| } | ||
|
|
||
| // Dependencies returns all of the dependencies directly needed to generate | ||
| // the asset. | ||
| func (*BMCVerifyCAConfigMap) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &tls.BMCVerifyCA{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate generates the BMC Verify CA ConfigMap. | ||
| func (bvc *BMCVerifyCAConfigMap) Generate(_ context.Context, dependencies asset.Parents) error { | ||
| bmcVerifyCA := &tls.BMCVerifyCA{} | ||
| dependencies.Get(bmcVerifyCA) | ||
|
|
||
| // Only generate the ConfigMap if BMCVerifyCA has content | ||
| files := bmcVerifyCA.Files() | ||
| if len(files) == 0 { | ||
| return nil | ||
| } | ||
|
|
||
| cm := &corev1.ConfigMap{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| APIVersion: corev1.SchemeGroupVersion.String(), | ||
| Kind: "ConfigMap", | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Namespace: bmcVerifyCAConfigMapNamespace, | ||
| Name: bmcVerifyCAConfigMapName, | ||
| }, | ||
| Data: map[string]string{ | ||
| bmcVerifyCAConfigMapDataKey: string(files[0].Data), | ||
| }, | ||
| } | ||
|
|
||
| cmData, err := yaml.Marshal(cm) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "failed to create %s manifest", bvc.Name()) | ||
| } | ||
| bvc.ConfigMap = cm | ||
| bvc.File = &asset.File{ | ||
| Filename: bmcVerifyCAConfigMapFileName, | ||
| Data: cmData, | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (bvc *BMCVerifyCAConfigMap) Files() []*asset.File { | ||
| if bvc.File != nil { | ||
| return []*asset.File{bvc.File} | ||
| } | ||
| return []*asset.File{} | ||
| } | ||
|
|
||
| // Load loads the already-rendered files back from disk. | ||
| func (bvc *BMCVerifyCAConfigMap) Load(f asset.FileFetcher) (bool, error) { | ||
| return false, nil | ||
| } |
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,65 @@ | ||
| package tls | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/installconfig" | ||
| "github.com/openshift/installer/pkg/types/baremetal" | ||
| ) | ||
|
|
||
| // BMCVerifyCA is the asset for the user-provided BMC verify CA certificate file. | ||
| // This CA certificate is used to verify BMC TLS certificates. | ||
| type BMCVerifyCA struct { | ||
| File *asset.File | ||
| } | ||
|
|
||
| var _ asset.WritableAsset = (*BMCVerifyCA)(nil) | ||
|
|
||
| // Name returns the human-friendly name of the asset. | ||
| func (*BMCVerifyCA) Name() string { | ||
| return "BMC Verify CA Certificate" | ||
| } | ||
|
|
||
| // Dependencies returns the dependency of the asset. | ||
| func (*BMCVerifyCA) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &installconfig.InstallConfig{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate generates the BMC verify CA file from the install config. | ||
| func (a *BMCVerifyCA) Generate(_ context.Context, dependencies asset.Parents) error { | ||
| installConfig := &installconfig.InstallConfig{} | ||
| dependencies.Get(installConfig) | ||
|
|
||
| // Only generate the file for baremetal platform with BMCVerifyCA configured | ||
| if installConfig.Config.Platform.Name() != baremetal.Name { | ||
| return nil | ||
| } | ||
|
|
||
| if installConfig.Config.Platform.BareMetal == nil || installConfig.Config.Platform.BareMetal.BMCVerifyCA == "" { | ||
| return nil | ||
| } | ||
|
|
||
| // Create the file at rootDir/bmc-ca/verify_ca.crt (rootDir = /opt/openshift) | ||
| a.File = &asset.File{ | ||
| Filename: "bmc-ca/verify_ca.crt", | ||
| Data: []byte(installConfig.Config.Platform.BareMetal.BMCVerifyCA), | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (a *BMCVerifyCA) Files() []*asset.File { | ||
| if a.File != nil { | ||
| return []*asset.File{a.File} | ||
| } | ||
| return []*asset.File{} | ||
| } | ||
|
|
||
| // Load loads the already-generated files back from disk. | ||
| func (a *BMCVerifyCA) Load(f asset.FileFetcher) (bool, error) { | ||
| return false, nil | ||
| } |
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
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.
nit: unintentional whitespace change?