Skip to content

Commit

Permalink
Merge pull request #67 from nauti-io/fix/cidr-allocate-error
Browse files Browse the repository at this point in the history
Fix cidr allocate error in hub
  • Loading branch information
lmxia authored May 23, 2024
2 parents 1ee328f + 9d4f23a commit b755c4b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ or `Service` CIDR, it's `10.112.0.0/12` by default.
And install nauti-agent in cluster by:

helm install nauti-agent mcs/nauti-agent --namespace nauti-system --create-namespace \
--set hub.hubURL=https://10.115.217.212:6443 --set tunnel.globalcidr=20.112.0.0/12 --set tunnel.cidr=20.114.0.0/16 \
--set cluster.clusterID=cluster1
--set hub.hubURL=https://10.115.217.212:6443 --set cluster.clusterID=cluster1
```


Expand Down Expand Up @@ -132,8 +131,7 @@ helm install nauti-agent mcs/nauti-agent --namespace nauti-system --create-nam
"mcs" has been added to your repositories
$ helm install nauti-agent mcs/nauti-agent --namespace nauti-system --create-namespace \
--set hub.hubURL=https://10.115.217.212:6443 --set tunnel.globalcidr=20.112.0.0/12 \
--set tunnel.cidr=20.114.0.0/16 --set cluster.clusterID=cluster1
--set hub.hubURL=https://10.115.217.212:6443 --set cluster.clusterID=cluster1
```
Add cross cluster DNS config segment, in `coredns` configmap, and restart coredns pods.
```yaml
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/peer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,15 @@ func (p *PeerController) Handle(obj interface{}) (requeueAfter *time.Duration, e
// prepare data...
existingCIDR := make([]string, 0)
noCIDR = true
if peerList, errListPeer := p.peerLister.Peers(namespace).List(labels.Everything()); errListPeer != nil {
if peerList, errListPeer := p.peerLister.Peers(namespace).List(labels.Everything()); errListPeer == nil {
for _, item := range peerList {
if item.Name != "hub" && len(item.Spec.PodCIDR) != 0 {
existingCIDR = append(existingCIDR, item.Spec.PodCIDR[0])
}
}
} else {
klog.Errorf("peers get with %v", err)
return &failedPeriod, err
}
// cidr allocation here.
cachedPeer.Spec.PodCIDR = make([]string, 1)
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/netutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ func Test_findAvailableCIDR(t *testing.T) {
want: "20.115.0.0/16",
wantErr: false,
},
{
name: "namex",
args: args{
networkCIDR: "20.112.0.0/12",
existingPeers: []string{"20.112.0.0/16"},
},
want: "20.113.0.0/16",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit b755c4b

Please sign in to comment.