Skip to content
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

OCPBUGS-20582: enable cloud controller manager type to be defined #7457

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/data/install.openshift.io_installconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3017,6 +3017,14 @@ spec:
description: External is the configuration used when installing on
an external cloud provider.
properties:
cloudControllerManager:
default: ""
description: CloudControllerManager when set to external, this
property will enable an external cloud provider.
enum:
- ""
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between "" and None. Can there be just 2 enum values "" and "External"? Internally, "" is mapped to None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that makes sense, will make that change.

- External
type: string
platformName:
default: Unknown
description: PlatformName holds the arbitrary string representing
Expand Down
16 changes: 14 additions & 2 deletions pkg/asset/manifests/external/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package external
import (
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/types/external"
)

// GetInfraPlatformSpec constructs ExternalPlatformSpec for the infrastructure spec.
Expand All @@ -15,10 +16,21 @@ func GetInfraPlatformSpec(ic *installconfig.InstallConfig) *configv1.ExternalPla
}

// GetInfraPlatformStatus constructs ExternalPlatformSpec for the infrastructure spec.
func GetInfraPlatformStatus() *configv1.ExternalPlatformStatus {
func GetInfraPlatformStatus(ic *installconfig.InstallConfig) *configv1.ExternalPlatformStatus {
icPlatformSpec := ic.Config.External

var ccmState configv1.CloudControllerManagerState

switch icPlatformSpec.CloudControllerManager {
case external.CloudControllerManagerTypeExternal:
ccmState = configv1.CloudControllerManagerExternal
default:
ccmState = configv1.CloudControllerManagerNone
}

return &configv1.ExternalPlatformStatus{
CloudControllerManager: configv1.CloudControllerManagerStatus{
State: configv1.CloudControllerManagerExternal,
State: ccmState,
},
}
}
2 changes: 1 addition & 1 deletion pkg/asset/manifests/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (i *Infrastructure) Generate(dependencies asset.Parents) error {
case external.Name:
config.Spec.PlatformSpec.Type = configv1.ExternalPlatformType
config.Spec.PlatformSpec.External = externalinfra.GetInfraPlatformSpec(installConfig)
config.Status.PlatformStatus.External = externalinfra.GetInfraPlatformStatus()
config.Status.PlatformStatus.External = externalinfra.GetInfraPlatformStatus(installConfig)
case none.Name:
config.Spec.PlatformSpec.Type = configv1.NonePlatformType
case openstack.Name:
Expand Down
1 change: 1 addition & 0 deletions pkg/types/external/defaults/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import "github.com/openshift/installer/pkg/types/external"
// SetPlatformDefaults sets the defaults for the platform.
func SetPlatformDefaults(p *external.Platform) {
p.PlatformName = "Unknown"
p.CloudControllerManager = external.CloudControllerManagerTypeNone
}
18 changes: 18 additions & 0 deletions pkg/types/external/platform.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package external

// CloudControllerManager describes the type of cloud controller manager to be enabled.
type CloudControllerManager string

const (
// CloudControllerManagerTypeExternal specifies that an external cloud provider is to be configured.
CloudControllerManagerTypeExternal = "External"

// CloudControllerManagerTypeNone specifies that no cloud provider is to be configured.
CloudControllerManagerTypeNone = ""
)

// Platform stores configuration related to external cloud providers.
type Platform struct {
// PlatformName holds the arbitrary string representing the infrastructure provider name, expected to be set at the installation time.
Expand All @@ -9,4 +20,11 @@ type Platform struct {
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Unknown' || self == oldSelf",message="platform name cannot be changed once set"
// +optional
PlatformName string `json:"platformName,omitempty"`

// CloudControllerManager when set to external, this property will enable an external cloud provider.
// +kubebuilder:default:=""
// +default=""
// +kubebuilder:validation:Enum="";External
// +optional
CloudControllerManager CloudControllerManager `json:"cloudControllerManager,omitempty"`
}