-
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
Changes from 4 commits
a502e90
6d3497d
d0bcd09
6f362cf
2cb7563
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,7 @@ func (a *Common) Dependencies() []asset.Asset { | |
| &tls.RootCA{}, | ||
| &tls.ServiceAccountKeyPair{}, | ||
| &tls.IronicTLSCert{}, | ||
| &tls.BMCVerifyCA{}, | ||
| &releaseimage.Image{}, | ||
| new(rhcos.Image), | ||
| } | ||
|
|
@@ -671,6 +672,7 @@ func (a *Common) addParentFiles(dependencies asset.Parents) { | |
| &tls.ServiceAccountKeyPair{}, | ||
| &tls.JournalCertKey{}, | ||
| &tls.IronicTLSCert{}, | ||
| &tls.BMCVerifyCA{}, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you already have Then you wouldn't need the BMCVerifyCA asset at all, and its one line of code could be rolled straight into the BMCVerifyCAConfigMap asset.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I need to digest this. I guess one issue is that we'll get an empty file by default, which may confuse Ironic. Can I make a file creation conditional?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You already made mounting the volume conditional. |
||
| } { | ||
| dependencies.Get(asset) | ||
|
|
||
|
|
||
dtantsur marked this conversation as resolved.
Show resolved
Hide resolved
|
| 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 | ||
| } |
| 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 | ||
| } |
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?