Skip to content

Commit 5dab91f

Browse files
Merge pull request openshift#7547 from rna-afk/azure_public_and_private
CORS-2854: azure: Allow users to set visibility to components
2 parents d451cf8 + 364a473 commit 5dab91f

File tree

9 files changed

+97
-5
lines changed

9 files changed

+97
-5
lines changed

data/data/install.openshift.io_installconfigs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,28 @@ spec:
21822182
description: Deprecated name for NetworkType
21832183
type: string
21842184
type: object
2185+
operatorPublishingStrategy:
2186+
description: OperatorPublishingStrategy controls the visibility of ingress
2187+
and apiserver. Defaults to public.
2188+
properties:
2189+
apiserver:
2190+
default: External
2191+
description: APIServer sets the visibility of the load balancers servicing
2192+
the APIserver.
2193+
enum:
2194+
- ""
2195+
- External
2196+
- Internal
2197+
type: string
2198+
ingress:
2199+
default: External
2200+
description: Ingress sets the visibility of the created dns resources.
2201+
enum:
2202+
- ""
2203+
- External
2204+
- Internal
2205+
type: string
2206+
type: object
21852207
platform:
21862208
description: Platform is the configuration for the specific platform upon
21872209
which to perform the installation.

pkg/asset/cluster/tfvars.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
402402
managedKeys.UserAssignedIdentityKey = installConfig.Config.Azure.CustomerManagedKey.UserAssignedIdentityKey
403403
}
404404

405+
lbPrivate := false
406+
if installConfig.Config.OperatorPublishingStrategy != nil {
407+
lbPrivate = installConfig.Config.OperatorPublishingStrategy.APIServer == "Internal"
408+
}
409+
405410
data, err := azuretfvars.TFVars(
406411
azuretfvars.TFVarsSources{
407412
Auth: auth,
@@ -423,6 +428,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
423428
InfrastructureName: clusterID.InfraID,
424429
KeyVault: managedKeys.KeyVault,
425430
UserAssignedIdentityKey: managedKeys.UserAssignedIdentityKey,
431+
LBPrivate: lbPrivate,
426432
},
427433
)
428434
if err != nil {

pkg/asset/manifests/dns.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ func (d *DNS) Generate(dependencies asset.Parents) error {
135135
return err
136136
}
137137

138-
if installConfig.Config.Publish == types.ExternalPublishingStrategy {
138+
if installConfig.Config.Publish == types.ExternalPublishingStrategy ||
139+
(installConfig.Config.Publish == types.MixedPublishingStrategy && installConfig.Config.OperatorPublishingStrategy.Ingress != "Internal") {
139140
//currently, this guesses the azure resource IDs from known parameter.
140141
config.Spec.PublicZone = &configv1.DNSZone{
141142
ID: dnsConfig.GetDNSZoneID(installConfig.Config.Azure.BaseDomainResourceGroupName, installConfig.Config.BaseDomain),

pkg/asset/manifests/ingress.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ func (ing *Ingress) generateClusterConfig(config *types.InstallConfig) ([]byte,
136136

137137
func (ing *Ingress) generateDefaultIngressController(config *types.InstallConfig) ([]byte, error) {
138138
switch config.Publish {
139+
case types.MixedPublishingStrategy:
140+
if config.OperatorPublishingStrategy.Ingress != "Internal" {
141+
break
142+
}
143+
fallthrough
139144
case types.InternalPublishingStrategy:
140145
obj := &operatorv1.IngressController{
141146
TypeMeta: metav1.TypeMeta{
@@ -156,9 +161,8 @@ func (ing *Ingress) generateDefaultIngressController(config *types.InstallConfig
156161
},
157162
}
158163
return yaml.Marshal(obj)
159-
default:
160-
return nil, nil
161164
}
165+
return nil, nil
162166
}
163167

164168
// Files returns the files generated by the asset.

pkg/explain/printer_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func Test_PrintFields(t *testing.T) {
8484
networking <object>
8585
Networking is the configuration for the pod network provider in the cluster.
8686
87+
operatorPublishingStrategy <object>
88+
OperatorPublishingStrategy controls the visibility of ingress and apiserver. Defaults to public.
89+
8790
platform <object> -required-
8891
Platform is the configuration for the specific platform upon which to perform the installation.
8992

pkg/tfvars/azure/azure.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type TFVarsSources struct {
9696
InfrastructureName string
9797
KeyVault azure.KeyVault
9898
UserAssignedIdentityKey string
99+
LBPrivate bool
99100
}
100101

101102
// TFVars generates Azure-specific Terraform variables launching the cluster.
@@ -170,7 +171,7 @@ func TFVars(sources TFVarsSources) ([]byte, error) {
170171
VolumeSize: masterConfig.OSDisk.DiskSizeGB,
171172
ImageURL: sources.ImageURL,
172173
ImageRelease: sources.ImageRelease,
173-
Private: sources.Publish == types.InternalPublishingStrategy,
174+
Private: sources.Publish == types.InternalPublishingStrategy || sources.LBPrivate,
174175
OutboundType: string(sources.OutboundType),
175176
ResourceGroupName: sources.ResourceGroupName,
176177
BaseDomainResourceGroupName: sources.BaseDomainResourceGroupName,

pkg/types/azure/validation/platform.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func ValidatePlatform(p *azure.Platform, publish types.PublishingStrategy, fldPa
6161
if p.Region == "" {
6262
allErrs = append(allErrs, field.Required(fldPath.Child("region"), "region should be set to one of the supported Azure regions"))
6363
}
64-
if !p.IsARO() && publish == types.ExternalPublishingStrategy {
64+
if !p.IsARO() && publish != types.InternalPublishingStrategy {
6565
if p.BaseDomainResourceGroupName == "" {
6666
allErrs = append(allErrs, field.Required(fldPath.Child("baseDomainResourceGroupName"), "baseDomainResourceGroupName is the resource group name where the azure dns zone is deployed"))
6767
}

pkg/types/installconfig.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ const (
7171
ExternalPublishingStrategy PublishingStrategy = "External"
7272
// InternalPublishingStrategy exposes the endpoints for the cluster to the private network only.
7373
InternalPublishingStrategy PublishingStrategy = "Internal"
74+
// MixedPublishingStrategy allows for the api server and the ingress to be configured individually for exposure to
75+
// private network or Internet.
76+
MixedPublishingStrategy PublishingStrategy = "Mixed"
7477
)
7578

7679
// PolicyType is for usage polices that are applied to additionalTrustBundle.
@@ -155,6 +158,9 @@ type InstallConfig struct {
155158
// +optional
156159
Publish PublishingStrategy `json:"publish,omitempty"`
157160

161+
// OperatorPublishingStrategy controls the visibility of ingress and apiserver. Defaults to public.
162+
OperatorPublishingStrategy *OperatorPublishingStrategy `json:"operatorPublishingStrategy,omitempty"`
163+
158164
// FIPS configures https://www.nist.gov/itl/fips-general-information
159165
//
160166
// +kubebuilder:default=false
@@ -313,6 +319,22 @@ type Platform struct {
313319
Nutanix *nutanix.Platform `json:"nutanix,omitempty"`
314320
}
315321

322+
// OperatorPublishingStrategy is used to control the visibility of the components which can be used to have a mix of public
323+
// and private resources.
324+
type OperatorPublishingStrategy struct {
325+
// Ingress sets the visibility of the created dns resources.
326+
// +kubebuilder:validation:Enum="";External;Internal
327+
// +kubebuilder:default=External
328+
// +optional
329+
Ingress string `json:"ingress,omitempty"`
330+
331+
// APIServer sets the visibility of the load balancers servicing the APIserver.
332+
// +kubebuilder:validation:Enum="";External;Internal
333+
// +kubebuilder:default=External
334+
// +optional
335+
APIServer string `json:"apiserver,omitempty"`
336+
}
337+
316338
// Name returns a string representation of the platform (e.g. "aws" if
317339
// AWS is non-nil). It returns an empty string if no platform is
318340
// configured.

pkg/types/validation/installconfig.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,38 @@ func ValidateInstallConfig(c *types.InstallConfig, usingAgentMethod bool) field.
156156
}
157157
}
158158

159+
if c.Publish == types.MixedPublishingStrategy {
160+
switch platformName := c.Platform.Name(); platformName {
161+
case azure.Name:
162+
default:
163+
allErrs = append(allErrs, field.Invalid(field.NewPath("publish"), c.Publish, fmt.Sprintf("mixed publish strategy is not supported on %q platform", platformName)))
164+
}
165+
if c.OperatorPublishingStrategy == nil {
166+
allErrs = append(allErrs, field.Invalid(field.NewPath("publish"), c.Publish, "please specify the operator publishing strategy for mixed publish strategy"))
167+
}
168+
} else if c.OperatorPublishingStrategy != nil {
169+
allErrs = append(allErrs, field.Invalid(field.NewPath("operatorPublishingStrategy"), c.Publish, "operator publishing strategy is only allowed with mixed publishing strategy installs"))
170+
}
171+
172+
if c.OperatorPublishingStrategy != nil {
173+
acceptedValues := sets.New[string]("Internal", "External")
174+
if c.OperatorPublishingStrategy.APIServer == "" {
175+
c.OperatorPublishingStrategy.APIServer = "External"
176+
}
177+
if c.OperatorPublishingStrategy.Ingress == "" {
178+
c.OperatorPublishingStrategy.Ingress = "External"
179+
}
180+
if !acceptedValues.Has(c.OperatorPublishingStrategy.APIServer) {
181+
allErrs = append(allErrs, field.NotSupported(field.NewPath("apiserver"), c.OperatorPublishingStrategy.APIServer, sets.List(acceptedValues)))
182+
}
183+
if !acceptedValues.Has(c.OperatorPublishingStrategy.Ingress) {
184+
allErrs = append(allErrs, field.NotSupported(field.NewPath("ingress"), c.OperatorPublishingStrategy.Ingress, sets.List(acceptedValues)))
185+
}
186+
if c.OperatorPublishingStrategy.APIServer == "Internal" && c.OperatorPublishingStrategy.Ingress == "Internal" {
187+
allErrs = append(allErrs, field.Invalid(field.NewPath("publish"), c.OperatorPublishingStrategy.APIServer, "cannot set both fields to internal in a mixed cluster, use publish internal instead"))
188+
}
189+
}
190+
159191
if c.Capabilities != nil {
160192
if c.Capabilities.BaselineCapabilitySet == configv1.ClusterVersionCapabilitySetNone {
161193
enabledCaps := sets.New[configv1.ClusterVersionCapability](c.Capabilities.AdditionalEnabledCapabilities...)
@@ -898,6 +930,7 @@ var (
898930
validPublishingStrategies = map[types.PublishingStrategy]struct{}{
899931
types.ExternalPublishingStrategy: {},
900932
types.InternalPublishingStrategy: {},
933+
types.MixedPublishingStrategy: {},
901934
}
902935

903936
validPublishingStrategyValues = func() []string {

0 commit comments

Comments
 (0)