Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping Ranges support #18

Merged
merged 17 commits into from Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -28,6 +28,8 @@ script:
- ./hack/build-go.sh
- KUBEBUILDER_ASSETS="$(pwd)/bin" $GOPATH/bin/goveralls -service=travis-ci
- docker build -t dougbtv/whereabouts .
- docker build -t dougbtv/whereabouts-ocp -f Dockerfile.openshift .
- docker images

deploy:
# Push images to Dockerhub on merge to master
Expand All @@ -38,6 +40,7 @@ deploy:
bash -c '
docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS";
docker push dougbtv/whereabouts:latest;
docker push dougbtv/whereabouts-ocp:latest;
echo done'
- provider: script
skip_cleanup: true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.openshift
Expand Up @@ -28,4 +28,4 @@ COPY --from=rhel8 /go/src/github.com/dougbtv/whereabouts/bin/whereabouts /usr/sr
LABEL io.k8s.display-name="Whereabouts CNI" \
io.k8s.description="This is a component of OpenShift Container Platform and provides a cluster-wide IPAM CNI plugin." \
io.openshift.tags="openshift" \
maintainer="CTO Networking <nfvpe-container@redhat.com>"
maintainer="CTO Networking <nfvpe-container@redhat.com>"
15 changes: 11 additions & 4 deletions README.md
Expand Up @@ -42,7 +42,7 @@ You can install this plugin with a Daemonset, using:

```
git clone https://github.com/dougbtv/whereabouts && cd whereabouts
kubectl apply -f ./doc/daemonset-install.yaml -f ./doc/whereabouts.cni.cncf.io_ippools.yaml
kubectl apply -f ./doc/daemonset-install.yaml -f ./doc/whereabouts.cni.cncf.io_ippools.yaml -f ./doc/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml
```

*NOTE*: This daemonset is for use with Kubernetes version 1.16 and later. It may also be useful with previous versions, however you'll need to change the `apiVersion` of the daemonset in the provided yaml, [see the deprecation notice](https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/).
Expand Down Expand Up @@ -178,6 +178,14 @@ There are two optional parameters for logging, they are:
* `log_file`: A file path to a logfile to log to.
* `log_level`: Set the logging verbosity, from most to least: `debug`,`error`,`panic`

### Overlapping Ranges

The overlapping ranges feature is enabled by default, and will not allow an IP address to be re-assigned across two different ranges which overlap. However, this can be disabled.

* `enable_overlapping_ranges`: *(boolean)* Checks to see if an IP has been allocated across another range before assigning it (defaults to `true`).

Please note: This feature is only implemented for the Kubernetes storage backend.

## Flatfile configuration

There is one option for flat file configuration:
Expand Down Expand Up @@ -271,9 +279,8 @@ The typeface used in the logo is [AZONIX](https://www.dafont.com/azonix.font), b

## Known limitations

* If you specify overlapping ranges -- you're almost certain to have collisions, so if you specify one config with `192.168.0.0/16` and another with `192.168.0.0/24`, you'll have collisions.
- This could be fixed with an admission controller.
- And admission controller could also prevent you from starting a pod in a given range if you were out of addresses within that range.
* A hard system crash on a node might leave behind stranded IP allocations, so if you have a trashing system, this might exhaust IPs.
- Potentially we need an operator to ensure data is clean, even if just at some kind of interval (e.g. with a cron job)
* There's probably a lot of comparison of IP addresses that could be optimized, lots of string conversion.
* The etcd method has a number of limitations, in that it uses an all ASCII methodology. If this was binary, it could probably store more and have more efficient IP address comparison.
* Unlikely to work in Canada, apparently it would have to be "where aboots?" for Canadians to be able to operate it.
4 changes: 2 additions & 2 deletions cmd/whereabouts.go
Expand Up @@ -41,7 +41,7 @@ func cmdAdd(args *skel.CmdArgs) error {
newip, err := storage.IPManagement(types.Allocate, *ipamConf, args.ContainerID)
if err != nil {
logging.Errorf("Error assigning IP: %s", err)
return fmt.Errorf("Error assigning IP: %s", err)
return fmt.Errorf("Error assigning IP: %w", err)
}

// Determine if v4 or v6.
Expand Down Expand Up @@ -75,7 +75,7 @@ func cmdDel(args *skel.CmdArgs) error {
return err
}
logging.Debugf("DEL - IPAM configuration successfully read: %+v", filterConf(*ipamConf))
logging.Debugf("ContainerID: %v", args.ContainerID)
logging.Debugf("Beginning delete for ContainerID: %v", args.ContainerID)

_, err = storage.IPManagement(types.Deallocate, *ipamConf, args.ContainerID)
if err != nil {
Expand Down