Assigns Kubernetes nodes to Digitalocean floating IPs
This project is intended to be run as a Kubernetes pod inside a DOKS (DigitalOcean Kubernetes) cluster.
It was inspired by a similar bash controller by @mwthink.
The controller will assign a Kubernetes node to a floating IP using the DigitalOcean API. A Custom Resource Definition called a FloatingIPBinding is
created for each floating IP that should be managed by the controller.
apiVersion: digitalocean.smirlwebs.com/v1beta1
kind: FloatingIPBinding
metadata:
name: main
spec:
floatingIP: 123.10.10.10
nodeSelectorPolicy: Newest
nodeSelector:
matchLabels:
role: ingresFull CRD API docs can be found at docs.crds.dev.
By default the Newest of all nodes is assigned to the floating IP as the
controller watches Nodes as well as FloatingIPBinding. This can be changed
by specifying a nodeSelector and/or a nodeSelectorPolicy in the object.
Currently supported policies are:
Newest(default) - The newest node matching the selectorOldest- The oldest node matching the selectorRandom- A random node matching the selector
The controller can be deployed from this repo with:
IMG=ghcr.io/smirl/digitalocean-floating-ip-controller:v0.1.0 make deployYou must provide the following as environment variables:
DO_TOKEN- DigitalOcean API token
This is taken from a secret called do-floating-ip-controller which must be
added to the cluster.
Please feel free to raise an issue or pull request. Releases automatically build and deploy to a test cluster. The github workflow requires the ServiceAccount to be deployed into the cluster and the token added as a repository secret.
kubectl apply -f serviceaccount.yaml