diff --git a/apis/v1alpha1/topologyspec.go b/apis/v1alpha1/topologyspec.go index 1fdaa01c..e00bbcc1 100644 --- a/apis/v1alpha1/topologyspec.go +++ b/apis/v1alpha1/topologyspec.go @@ -69,17 +69,14 @@ type Definition struct { // Expose holds configurations relevant to how clabernetes exposes a topology. type Expose struct { - // DisableNodeAliasService indicates if headless services for each node in a containerlab - // topology should *not* be created. By default, clabernetes creates these headless services for - // each node so that "normal" docker and containerlab service discovery works -- this means you - // can simply resolve "my-neat-node" from within the namespace of a topology like you would in - // docker locally. You may wish to disable this feature though if you have no need of it and - // just don't want the extra services around. Additionally, you may want to disable this feature - // if you are running multiple labs in the same namespace (which is not generally recommended by - // the way!) as you may end up in a situation where a name (i.e. "leaf1") is duplicated in more - // than one topology -- this will cause some problems for clabernetes! - // +optional - DisableNodeAliasService bool `json:"disableNodeAliasService"` + // EnableNodeAliasService indicates if a headless services for each node in a containerlab + // topology should be created. Enabling this feature makes things behave more like "normal" + // clab/docker setup where node "a" can resolve node "b" simply by name. You likely do *not* + // want to enable this if you are running multiple labs in the same namespace as there may be + // issues where a clab node name is present in multiple labs which would cause reconciliation + // issues. + // +optional + EnableNodeAliasService bool `json:"enableNodeAliasService"` // DisableExpose indicates if exposing nodes via LoadBalancer service should be disabled, by // default any mapped ports in a containerlab topology will be exposed. // +optional diff --git a/clabverter/test-fixtures/golden/simple-no-explicit-namespace/srl02.yaml b/clabverter/test-fixtures/golden/simple-no-explicit-namespace/srl02.yaml index af589f44..5710d002 100755 --- a/clabverter/test-fixtures/golden/simple-no-explicit-namespace/srl02.yaml +++ b/clabverter/test-fixtures/golden/simple-no-explicit-namespace/srl02.yaml @@ -67,7 +67,7 @@ spec: expose: disableAutoExpose: false disableExpose: true - disableNodeAliasService: false + enableNodeAliasService: false imagePull: insecureRegistries: - 1.2.3.4 diff --git a/clabverter/test-fixtures/golden/simple/srl02.yaml b/clabverter/test-fixtures/golden/simple/srl02.yaml index 3b08ef48..4c2e2b70 100755 --- a/clabverter/test-fixtures/golden/simple/srl02.yaml +++ b/clabverter/test-fixtures/golden/simple/srl02.yaml @@ -67,7 +67,7 @@ spec: expose: disableAutoExpose: false disableExpose: false - disableNodeAliasService: false + enableNodeAliasService: false imagePull: insecureRegistries: - 1.2.3.4 diff --git a/controllers/topology/servicenodealias.go b/controllers/topology/servicenodealias.go index c929b8f2..7ab079e0 100644 --- a/controllers/topology/servicenodealias.go +++ b/controllers/topology/servicenodealias.go @@ -77,7 +77,7 @@ func (r *ServiceNodeAliasReconciler) Resolve( var allNodes []string - if !owningTopology.Spec.Expose.DisableNodeAliasService { + if owningTopology.Spec.Expose.EnableNodeAliasService { allNodes = make([]string, len(clabernetesConfigs)) idx := 0 diff --git a/controllers/topology/servicenodealias_test.go b/controllers/topology/servicenodealias_test.go index a8ecde05..b0203809 100644 --- a/controllers/topology/servicenodealias_test.go +++ b/controllers/topology/servicenodealias_test.go @@ -39,9 +39,15 @@ func TestResolveServiceNodeResolution(t *testing.T) { expectedExtra: []*k8scorev1.Service{}, }, { - name: "missing-nodes", - owningTopology: &clabernetesapisv1alpha1.Topology{}, - ownedServices: &k8scorev1.ServiceList{}, + name: "missing-nodes", + owningTopology: &clabernetesapisv1alpha1.Topology{ + Spec: clabernetesapisv1alpha1.TopologySpec{ + Expose: clabernetesapisv1alpha1.Expose{ + EnableNodeAliasService: true, + }, + }, + }, + ownedServices: &k8scorev1.ServiceList{}, clabernetesConfigs: map[string]*clabernetesutilcontainerlab.Config{ "node1": nil, "node2": nil, diff --git a/e2e/clabverter/test-fixtures/e2e-clabverter-basic-fpvbjkxl-ns.yaml b/e2e/clabverter/test-fixtures/e2e-clabverter-basic-fpvbjkxl-ns.yaml new file mode 100755 index 00000000..59166925 --- /dev/null +++ b/e2e/clabverter/test-fixtures/e2e-clabverter-basic-fpvbjkxl-ns.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: e2e-clabverter-basic-fpvbjkxl diff --git a/e2e/clabverter/test-fixtures/golden/10-topology.clabverter-basic.yaml b/e2e/clabverter/test-fixtures/golden/10-topology.clabverter-basic.yaml index 812e7637..338cd70f 100755 --- a/e2e/clabverter/test-fixtures/golden/10-topology.clabverter-basic.yaml +++ b/e2e/clabverter/test-fixtures/golden/10-topology.clabverter-basic.yaml @@ -29,7 +29,6 @@ spec: expose: disableAutoExpose: false disableExpose: false - disableNodeAliasService: false imagePull: {} status: configs: diff --git a/e2e/topology/basic/test-fixtures/golden/10-topology.topology-basic.yaml b/e2e/topology/basic/test-fixtures/golden/10-topology.topology-basic.yaml index e7fa4a01..0326dbba 100755 --- a/e2e/topology/basic/test-fixtures/golden/10-topology.topology-basic.yaml +++ b/e2e/topology/basic/test-fixtures/golden/10-topology.topology-basic.yaml @@ -22,7 +22,6 @@ spec: expose: disableAutoExpose: false disableExpose: false - disableNodeAliasService: false imagePull: {} status: configs: