Skip to content

Commit dedfb47

Browse files
committed
config/v1/types_infrastructure: Add AWS Region
The image registry needs this so it can figure out where to create an S3 bucket for installs with cluster-provisioned infrastructure [1]. We need the registry to be happy after: $ openshift-install create cluster so we don't want to rely on the installer pushing this config in as a day-2 operation. You can extract "what AWS region am I in?" from the cloud provider, but the registry operator is not authorized to do so. With this addition, we provide a way for the cluster creator to declare a default region for new infrastructure. This field is in Status and not Spec, because we're not going to support transitioning clusters between regions by reconciling this. The cluster admin can write it once (in the manifest that goes up with the bootstrap Ignition config), and then it's read-only reality forever. I'd prefer an +optional Region property, because you only need to set it if you want the cluster to provision resources for you. For user-provided infrastructure flows, you could leave this unset. However, the registry needs the region for its S3 client [2], even if it's just to manage data in a user-provided bucket. So folks who leave the property off will have an Available:false registry until they set region or regionEndpoint via the configs.imageregistry.operator.openshift.io custom resource [3,4]. But Adam wanted it required [5], and going from required -> optional later is a non-breaking change while optional -> required would be breaking, so it's required with this commit. I've pushed the type specifier down into platformStatus, deprecating the old property, because discriminator fields need to live inside the struct whose properties they discriminate [6]. It would be nice to be able to drop the old type property and rename platformStatus to platform, but it's too close to API freeze to be able to do that, so we're stuck with the old name. We'll drop the old type in v2, if we ever have a v2 of this type. [1]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/clusterconfig/clusterconfig.go#L44 [2]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/storage/s3/s3.go#L53-L65 [3]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/manifests/00-crd.yaml [4]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/apis/imageregistry/v1/types.go#L179-L184 [5]: #300 (comment) [6]: #300 (comment)
1 parent 10f647f commit dedfb47

1 file changed

Lines changed: 33 additions & 8 deletions

File tree

config/v1/types_infrastructure.go

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ type InfrastructureStatus struct {
3737
// alphanumeric or hyphen characters.
3838
InfrastructureName string `json:"infrastructureName"`
3939

40-
// platform is the underlying infrastructure provider for the cluster. This
41-
// value controls whether infrastructure automation such as service load
42-
// balancers, dynamic volume provisioning, machine creation and deletion, and
43-
// other integrations are enabled. If None, no infrastructure automation is
44-
// enabled. Allowed values are "AWS", "Azure", "BareMetal", "GCP", "Libvirt",
45-
// "OpenStack", "VSphere", and "None". Individual components may not support
46-
// all platforms, and must handle unrecognized platforms as None if they do
47-
// not support that platform.
40+
// platform is the underlying infrastructure provider for the cluster.
41+
//
42+
// Deprecated: Use platformStatus.type instead.
4843
Platform PlatformType `json:"platform,omitempty"`
4944

45+
// platformStatus holds status information specific to the underlying
46+
// infrastructure provider.
47+
// +optional
48+
PlatformStatus *PlatformStatus `json:"platformStatus,omitempty"`
49+
5050
// etcdDiscoveryDomain is the domain used to fetch the SRV records for discovering
5151
// etcd servers and clients.
5252
// For more info: https://github.com/etcd-io/etcd/blob/329be66e8b3f9e2e6af83c123ff89297e49ebd15/Documentation/op-guide/clustering.md#dns-discovery
@@ -93,6 +93,31 @@ const (
9393
VSpherePlatformType PlatformType = "VSphere"
9494
)
9595

96+
// PlatformStatus holds the current status specific to the underlying infrastructure provider
97+
// of the current cluster. Since these are used at status-level for the underlying cluster, it
98+
// is supposed that only one of the status structs is set.
99+
type PlatformStatus struct {
100+
// type is the underlying infrastructure provider for the cluster. This
101+
// value controls whether infrastructure automation such as service load
102+
// balancers, dynamic volume provisioning, machine creation and deletion, and
103+
// other integrations are enabled. If None, no infrastructure automation is
104+
// enabled. Allowed values are "AWS", "Azure", "BareMetal", "GCP", "Libvirt",
105+
// "OpenStack", "VSphere", and "None". Individual components may not support
106+
// all platforms, and must handle unrecognized platforms as None if they do
107+
// not support that platform.
108+
Type PlatformType `json:"type"`
109+
110+
// AWS contains settings specific to the Amazon Web Services infrastructure provider.
111+
// +optional
112+
AWS *AWSPlatformStatus `json:"aws,omitempty"`
113+
}
114+
115+
// AWSPlatformStatus holds the current status of the Amazon Web Services infrastructure provider.
116+
type AWSPlatformStatus struct {
117+
// region holds the default AWS region for new AWS resources created by the cluster.
118+
Region string `json:"region"`
119+
}
120+
96121
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
97122

98123
// InfrastructureList is

0 commit comments

Comments
 (0)