Skip to content
Closed
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
16 changes: 16 additions & 0 deletions pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
igntypes "github.com/coreos/ignition/config/v2_2/types"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/vincent-petithory/dataurl"

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/ignition"
Expand Down Expand Up @@ -113,6 +114,21 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error {
igntypes.PasswdUser{Name: "core", SSHAuthorizedKeys: []igntypes.SSHAuthorizedKey{igntypes.SSHAuthorizedKey(installConfig.Config.Admin.SSHKey)}},
)

authorities := installConfig.Config.DefaultCertificateAuthorities
if len(authorities) > 0 {
certificateAuthorities := make([]igntypes.CaReference, 0, len(authorities))
for _, certificateAuthority := range authorities {
certificateAuthorities = append(certificateAuthorities, igntypes.CaReference{
Source: dataurl.EncodeBytes([]byte(certificateAuthority)),
})
}
a.Config.Ignition.Security = igntypes.Security{
TLS: igntypes.TLS{
CertificateAuthorities: certificateAuthorities,
},
}
}

data, err := json.Marshal(a.Config)
if err != nil {
return errors.Wrap(err, "failed to Marshal Ignition config")
Expand Down
18 changes: 15 additions & 3 deletions pkg/asset/ignition/machine/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ import (
// pointerIgnitionConfig generates a config which references the remote config
// served by the machine config server.
func pointerIgnitionConfig(installConfig *types.InstallConfig, rootCA []byte, role string, query string) *ignition.Config {
certificateAuthorities := []ignition.CaReference{{
Source: dataurl.EncodeBytes(rootCA),
}}

authorities := []string{} // FIXME: set from installConfig.Machines[*].CertificateAuthorities
if len(authorities) == 0 {
authorities = installConfig.DefaultCertificateAuthorities
}
for _, certificateAuthority := range authorities {
certificateAuthorities = append(certificateAuthorities, ignition.CaReference{
Source: dataurl.EncodeBytes([]byte(certificateAuthority)),
})
}

return &ignition.Config{
Ignition: ignition.Ignition{
Version: ignition.MaxVersion.String(),
Expand All @@ -30,9 +44,7 @@ func pointerIgnitionConfig(installConfig *types.InstallConfig, rootCA []byte, ro
},
Security: ignition.Security{
TLS: ignition.TLS{
CertificateAuthorities: []ignition.CaReference{{
Source: dataurl.EncodeBytes(rootCA),
}},
CertificateAuthorities: certificateAuthorities,
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/asset/installconfig/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package installconfig

import (
"net"
"os"

"github.com/apparentlymart/go-cidr/cidr"
"github.com/ghodss/yaml"
Expand Down Expand Up @@ -108,6 +109,11 @@ func (a *InstallConfig) Generate(parents asset.Parents) error {
panic("unknown platform type")
}

certificateAuthority := os.Getenv("_FIXME_OPENSHIFT_INSTALL_CERTIFICATE_AUTHORITY")
if certificateAuthority != "" {
a.Config.DefaultCertificateAuthorities = []string{certificateAuthority}
}

a.Config.Machines = []types.MachinePool{
{
Name: "master",
Expand Down
6 changes: 6 additions & 0 deletions pkg/types/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ type InstallConfig struct {
// Machines is the list of MachinePools that need to be installed.
Machines []MachinePool `json:"machines"`

// DefaultCertificateAuthorities is the default slice of additional
// PEM-encoded certificated to add to machines (in addition to the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: certificated -> certificates

// system authorities) when MachinePool.CertificateAuthorities is
// empty.
DefaultCertificateAuthorities []string `json:"defaultCertificateAuthorities,omitempty"`

// Platform is the configuration for the specific platform upon which to
// perform the installation.
Platform `json:"platform"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/types/machinepools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ type MachinePool struct {

// Platform is configuration for machine pool specific to the platfrom.
Platform MachinePoolPlatform `json:"platform"`

// CertificateAuthorities is a slice of additional PEM-encoded
// certificates to add to machines (in addition to the system
// authorities).
CertificateAuthorities []string `json:"certificateAuthorities,omitempty"`
}

// MachinePoolPlatform is the platform-specific configuration for a machine
Expand Down