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

IP ranges cleanup #118

Merged
merged 16 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ RUN ./hack/build-go.sh
FROM alpine:latest
LABEL org.opencontainers.image.source https://github.com/k8snetworkplumbingwg/whereabouts
COPY --from=0 /go/src/github.com/dougbtv/whereabouts/bin/whereabouts .
COPY --from=0 /go/src/github.com/dougbtv/whereabouts/bin/ip-reconciler .
COPY script/install-cni.sh .
CMD ["/install-cni.sh"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ 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 -f ./doc/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml
kubectl apply \
-f ./doc/daemonset-install.yaml \
-f ./doc/whereabouts.cni.cncf.io_ippools.yaml \
-f ./doc/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml \
-f doc/ip-reconciler-job.yaml
```

The daemonset installation requires Kubernetes Version 1.16 or later.
Expand Down
8 changes: 8 additions & 0 deletions cmd/reconciler/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

const (
kubeconfigNotFound = iota + 1
couldNotStartOrphanedIPMonitor
failedToReconcileIPPools
failedToReconcileClusterWideIPs
)
44 changes: 44 additions & 0 deletions cmd/reconciler/ip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
"context"
"flag"
"github.com/dougbtv/whereabouts/pkg/storage"
"os"

"github.com/dougbtv/whereabouts/pkg/logging"
"github.com/dougbtv/whereabouts/pkg/reconciler"
)

func main() {
kubeConfigFile := flag.String("kubeconfig", "", "the path to the Kubernetes configuration file")
flag.Parse()

if *kubeConfigFile == "" {
_ = logging.Errorf("must specify the kubernetes config file, via the '-kubeconfig' flag")
os.Exit(kubeconfigNotFound)
}

ctx, cancel := context.WithTimeout(context.Background(), storage.RequestTimeout)
defer cancel()
ipReconcileLoop, err := reconciler.NewReconcileLooper(*kubeConfigFile, ctx)
if err != nil {
_ = logging.Errorf("failed to create the reconcile looper: %v", err)
os.Exit(couldNotStartOrphanedIPMonitor)
}

cleanedUpIps, err := ipReconcileLoop.ReconcileIPPools()
if err != nil {
_ = logging.Errorf("failed to clean up IP for allocations: %v", err)
os.Exit(failedToReconcileIPPools)
}
if len(cleanedUpIps) > 0 {
logging.Debugf("successfully cleanup IPs: %+v", cleanedUpIps)
} else {
logging.Debugf("no IP addresses to cleanup")
}

if err := ipReconcileLoop.ReconcileOverlappingIPAddresses(); err != nil {
os.Exit(failedToReconcileClusterWideIPs)
}
}
Loading