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
17 changes: 17 additions & 0 deletions data/data/install.openshift.io_installconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4989,6 +4989,23 @@ spec:
- cidr
type: object
type: array
networkObservability:
description: |-
NetworkObservability is an optional field that configures network observability installation
during cluster deployment (day-0).
When omitted, network observability will be installed unless this is a SNO cluster.
properties:
installationPolicy:
description: |-
InstallationPolicy controls whether network observability is installed during cluster deployment.
Valid values are "InstallAndEnable" and "NoAction".
When set to "InstallAndEnable", network observability will be installed and enabled.
When set to "NoAction", nothing will be done regarding network observability.
enum:
- InstallAndEnable
- NoAction
type: string
type: object
networkType:
default: OVNKubernetes
description: |-
Expand Down
27 changes: 18 additions & 9 deletions pkg/asset/manifests/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ func (no *Networking) Generate(_ context.Context, dependencies asset.Parents) er
serviceNet = append(serviceNet, sn.String())
}

networkSpec := configv1.NetworkSpec{
ClusterNetwork: clusterNet,
ServiceNetwork: serviceNet,
NetworkType: netConfig.NetworkType,
// Block all Service.ExternalIPs by default
ExternalIP: &configv1.ExternalIPConfig{
Policy: &configv1.ExternalIPPolicy{},
},
}

// Set networkObservability from the install config
if netConfig.NetworkObservability != nil && netConfig.NetworkObservability.InstallationPolicy != nil {
networkSpec.NetworkObservability = configv1.NetworkObservabilitySpec{
InstallationPolicy: configv1.NetworkObservabilityInstallationPolicy(*netConfig.NetworkObservability.InstallationPolicy),
}
}

no.Config = &configv1.Network{
TypeMeta: metav1.TypeMeta{
APIVersion: configv1.SchemeGroupVersion.String(),
Expand All @@ -79,15 +96,7 @@ func (no *Networking) Generate(_ context.Context, dependencies asset.Parents) er
Name: "cluster",
// not namespaced
},
Spec: configv1.NetworkSpec{
ClusterNetwork: clusterNet,
ServiceNetwork: serviceNet,
NetworkType: netConfig.NetworkType,
// Block all Service.ExternalIPs by default
ExternalIP: &configv1.ExternalIPConfig{
Policy: &configv1.ExternalIPPolicy{},
},
},
Spec: networkSpec,
}

configData, err := yaml.Marshal(no.Config)
Expand Down
1 change: 0 additions & 1 deletion pkg/types/defaults/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func SetInstallConfigDefaults(c *types.InstallConfig) {
},
}
}

if c.Publish == "" {
c.Publish = types.ExternalPublishingStrategy
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/types/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,13 @@ type Networking struct {
// pod network when NetworkType is set to OVNKubernetes.
OVNKubernetesConfig *OVNKubernetesConfig `json:"ovnKubernetesConfig,omitempty"`

// NetworkObservability is an optional field that configures network observability installation
// during cluster deployment (day-0).
// When omitted, network observability will be installed unless this is a SNO cluster.
//
// +optional
NetworkObservability *NetworkObservability `json:"networkObservability,omitempty"`

// Deprecated types, scheduled to be removed

// Deprecated way to configure an IP address pool for machines.
Expand Down Expand Up @@ -797,3 +804,25 @@ func OSImageStreamValues() []OSImageStream {
OSImageStreamRHCOS10,
}
}

// NetworkObservabilityInstallationPolicy is an enumeration of the available network observability installation policies
// Valid values are "InstallAndEnable", "NoAction".
// +kubebuilder:validation:Enum=InstallAndEnable;NoAction
type NetworkObservabilityInstallationPolicy string

const (
// NetworkObservabilityInstallAndEnable means that network observability should be installed and enabled during cluster deployment.
NetworkObservabilityInstallAndEnable NetworkObservabilityInstallationPolicy = "InstallAndEnable"
// NetworkObservabilityNoAction means that nothing will be done regarding network observability.
NetworkObservabilityNoAction NetworkObservabilityInstallationPolicy = "NoAction"
)

// NetworkObservability defines the configuration for network observability installation.
type NetworkObservability struct {
// InstallationPolicy controls whether network observability is installed during cluster deployment.
// Valid values are "InstallAndEnable" and "NoAction".
// When set to "InstallAndEnable", network observability will be installed and enabled.
// When set to "NoAction", nothing will be done regarding network observability.
// +optional
InstallationPolicy *NetworkObservabilityInstallationPolicy `json:"installationPolicy,omitempty"`
}
14 changes: 14 additions & 0 deletions pkg/types/validation/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,20 @@ func validateNetworking(n *types.Networking, fldPath *field.Path) field.ErrorLis
allErrs = append(allErrs, validateClusterNetwork(n, &cn, i, fldPath.Child("clusterNetwork").Index(i))...)
}

if n.NetworkObservability != nil {
if n.NetworkObservability.InstallationPolicy == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("networkObservability", "installationPolicy"), "installationPolicy is required when networkObservability is specified"))
} else {
validPolicies := map[types.NetworkObservabilityInstallationPolicy]bool{
types.NetworkObservabilityInstallAndEnable: true,
types.NetworkObservabilityNoAction: true,
}
if !validPolicies[*n.NetworkObservability.InstallationPolicy] {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("networkObservability", "installationPolicy"), *n.NetworkObservability.InstallationPolicy, []string{string(types.NetworkObservabilityInstallAndEnable), string(types.NetworkObservabilityNoAction)}))
}
}
}

return allErrs
}

Expand Down
63 changes: 63 additions & 0 deletions pkg/types/validation/installconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,69 @@ func TestValidateInstallConfig(t *testing.T) {
}(),
expectedError: `^networking\.networkType: Invalid value: "OpenShiftSDN": networkType OpenShiftSDN is not supported, please use OVNKubernetes$`,
},
{
name: "invalid networkObservability installationPolicy",
installConfig: func() *types.InstallConfig {
c := validInstallConfig()
invalidPolicy := types.NetworkObservabilityInstallationPolicy("test")
c.Networking.NetworkObservability = &types.NetworkObservability{
InstallationPolicy: &invalidPolicy,
}
return c
}(),
expectedError: `^networking\.networkObservability\.installationPolicy: Unsupported value: "test": supported values: "InstallAndEnable", "NoAction"$`,
},
{
name: "missing networkObservability installationPolicy",
installConfig: func() *types.InstallConfig {
c := validInstallConfig()
c.Networking.NetworkObservability = &types.NetworkObservability{}
return c
}(),
expectedError: `^networking\.networkObservability\.installationPolicy: Required value: installationPolicy is required when networkObservability is specified$`,
},
{
name: "blank networkObservability installationPolicy",
installConfig: func() *types.InstallConfig {
c := validInstallConfig()
blankPolicy := types.NetworkObservabilityInstallationPolicy("")
c.Networking.NetworkObservability = &types.NetworkObservability{
InstallationPolicy: &blankPolicy,
}
return c
}(),
expectedError: `^networking\.networkObservability\.installationPolicy: Unsupported value: "": supported values: "InstallAndEnable", "NoAction"$`,
},
{
name: "valid networkObservability InstallAndEnable",
installConfig: func() *types.InstallConfig {
c := validInstallConfig()
policy := types.NetworkObservabilityInstallAndEnable
c.Networking.NetworkObservability = &types.NetworkObservability{
InstallationPolicy: &policy,
}
return c
}(),
},
{
name: "valid networkObservability NoAction",
installConfig: func() *types.InstallConfig {
c := validInstallConfig()
policy := types.NetworkObservabilityNoAction
c.Networking.NetworkObservability = &types.NetworkObservability{
InstallationPolicy: &policy,
}
return c
}(),
},
{
name: "valid networkObservability absent",
installConfig: func() *types.InstallConfig {
c := validInstallConfig()
c.Networking.NetworkObservability = nil
return c
}(),
},
{
name: "missing service network",
installConfig: func() *types.InstallConfig {
Expand Down
26 changes: 26 additions & 0 deletions pkg/types/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.