Skip to content

Commit

Permalink
refactor: disable node alias by default, config option now *enables* it
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed Feb 13, 2024
1 parent cafc851 commit 74b0438
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
19 changes: 8 additions & 11 deletions apis/v1alpha1/topologyspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
expose:
disableAutoExpose: false
disableExpose: true
disableNodeAliasService: false
enableNodeAliasService: false
imagePull:
insecureRegistries:
- 1.2.3.4
Expand Down
2 changes: 1 addition & 1 deletion clabverter/test-fixtures/golden/simple/srl02.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
expose:
disableAutoExpose: false
disableExpose: false
disableNodeAliasService: false
enableNodeAliasService: false
imagePull:
insecureRegistries:
- 1.2.3.4
Expand Down
2 changes: 1 addition & 1 deletion controllers/topology/servicenodealias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions controllers/topology/servicenodealias_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: e2e-clabverter-basic-fpvbjkxl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ spec:
expose:
disableAutoExpose: false
disableExpose: false
disableNodeAliasService: false
imagePull: {}
status:
configs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ spec:
expose:
disableAutoExpose: false
disableExpose: false
disableNodeAliasService: false
imagePull: {}
status:
configs:
Expand Down

0 comments on commit 74b0438

Please sign in to comment.