Skip to content

Commit 428f44a

Browse files
committed
Allow overriding OVN-Kubernetes configuration
This change introduces a mechanism to provide hidden or experimental configuration to OVN-Kubernetes through a ConfigMap. This provides a flexible way to enable advanced or experimental OVN-Kubernetes features without modifying the CNO API. A new ConfigMap 'ovn-kubernetes-config-overrides', is now read by the operator during the bootstrap process. The key-value data from this ConfigMap is passed down to the OVN-K components. As an initial implementation, this is used to support the flag 'udn-isolation-mode' which is to enable user to select the UDN isolation mode between 'loose' and 'strict'. If unset, the default mode is 'strict'. Signed-off-by: Peng Liu <[email protected]>
1 parent bf88d53 commit 428f44a

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

bindata/network/ovn-kubernetes/common/008-script-lib.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ data:
490490
local metrics_port=$2
491491
local ovn_metrics_port=$3
492492

493+
# Ensure ovn_udn_isolation_mode_flag is always defined
494+
ovn_udn_isolation_mode_flag=
495+
493496
if [[ $# -ne 3 ]]; then
494497
echo "Expected three arguments but got $#"
495498
exit 1
@@ -605,6 +608,10 @@ data:
605608
sysctl -w net.ipv6.conf.all.forwarding=0
606609
fi
607610

611+
if [[ "{{.UDNIsolationMode}}" != "" ]]; then
612+
ovn_udn_isolation_mode_flag="--udn-isolation-mode={{.UDNIsolationMode}}"
613+
fi
614+
608615
NETWORK_NODE_IDENTITY_ENABLE=
609616
if [[ "{{.NETWORK_NODE_IDENTITY_ENABLE}}" == "true" ]]; then
610617
NETWORK_NODE_IDENTITY_ENABLE="
@@ -673,6 +680,7 @@ data:
673680
--acl-logging-rate-limit "{{.OVNPolicyAuditRateLimit}}" \
674681
${gw_interface_flag} \
675682
${ip_forwarding_flag} \
683+
${ovn_udn_isolation_mode_flag} \
676684
${NETWORK_NODE_IDENTITY_ENABLE} \
677685
${ovn_v4_join_subnet_opt} \
678686
${ovn_v6_join_subnet_opt} \

pkg/bootstrap/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ type OVNConfigBoostrapResult struct {
3232
SmartNicModeLabel string
3333
SmartNicModeNodes []string
3434
MgmtPortResourceName string
35+
// ConfigOverrides contains the overrides for the OVN Kubernetes configuration
36+
// This is used to set the hidden OVN Kubernetes configuration in the cluster
37+
// It is a map of key-value pairs where the key is the configuration option and the
38+
// value is the configuration value.
39+
ConfigOverrides map[string]string
3540
}
3641

3742
// OVNUpdateStatus contains the status of existing daemonset

pkg/network/ovn_kubernetes.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ const OVN_NODE_IDENTITY_CERT_DURATION = "24h"
6868
const OVN_EGRESSIP_HEALTHCHECK_PORT = "9107"
6969

7070
const (
71-
OVSFlowsConfigMapName = "ovs-flows-config"
71+
OVSFlowsConfigMapName = "ovs-flows-config"
72+
OVNKubernetesConfigOverridesCMName = "ovn-kubernetes-config-overrides"
73+
7274
OVSFlowsConfigNamespace = names.APPLIED_NAMESPACE
7375
defaultV4InternalSubnet = "100.64.0.0/16"
7476
defaultV6InternalSubnet = "fd98::/64"
@@ -180,6 +182,10 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
180182
data.Data["NETWORK_NODE_IDENTITY_ENABLE"] = bootstrapResult.Infra.NetworkNodeIdentityEnabled
181183
data.Data["NodeIdentityCertDuration"] = OVN_NODE_IDENTITY_CERT_DURATION
182184
data.Data["IsNetworkTypeLiveMigration"] = false
185+
data.Data["UDNIsolationMode"] = ""
186+
if mode, ok := bootstrapResult.OVN.OVNKubernetesConfig.ConfigOverrides["udn-isolation-mode"]; ok {
187+
data.Data["UDNIsolationMode"] = mode
188+
}
183189

184190
if conf.Migration != nil {
185191
if conf.Migration.MTU != nil && conf.Migration.Mode != operv1.LiveNetworkMigrationMode {
@@ -866,6 +872,11 @@ func bootstrapOVNConfig(conf *operv1.Network, kubeClient cnoclient.Client, hc *h
866872
return nil, fmt.Errorf("Node %s has multiple hardware offload labels.", nodeName)
867873
}
868874

875+
ovnConfigResult.ConfigOverrides, err = getOVNKubernetesConfigOverrides(kubeClient)
876+
if err != nil {
877+
return nil, fmt.Errorf("Could not get OVN Kubernetes config overrides: %w", err)
878+
}
879+
869880
klog.Infof("OVN configuration is now %+v", ovnConfigResult)
870881

871882
ovnConfigResult.DisableUDPAggregation = getDisableUDPAggregation(kubeClient.ClientFor("").CRClient())
@@ -1972,3 +1983,21 @@ func GetMasqueradeSubnet(conf *operv1.OVNKubernetesConfig) (v4Subnet, v6Subnet s
19721983
}
19731984
return
19741985
}
1986+
1987+
// getOVNKubernetesConfigOverrides retrieves OVN Kubernetes configuration overrides from the
1988+
// openshift-network-operator/ovn-kubernetes-config-overrides configmap.
1989+
// If the configmap exists, it returns the data as a map.
1990+
// If the configmap does not exist, it returns nil, indicating that no overrides are set
1991+
// and no error.
1992+
// If there is an error retrieving the configmap, it returns an error.
1993+
func getOVNKubernetesConfigOverrides(client cnoclient.Client) (map[string]string, error) {
1994+
configMap := &corev1.ConfigMap{}
1995+
if err := client.Default().CRClient().Get(context.TODO(),
1996+
types.NamespacedName{Name: OVNKubernetesConfigOverridesCMName, Namespace: names.APPLIED_NAMESPACE}, configMap); err != nil {
1997+
if apierrors.IsNotFound(err) {
1998+
return nil, nil
1999+
}
2000+
return nil, fmt.Errorf("unable to retrieve config from configmap %v: %s", OVNKubernetesConfigOverridesCMName, err)
2001+
}
2002+
return configMap.Data, nil
2003+
}

0 commit comments

Comments
 (0)