Giter VIP home page Giter VIP logo

digital-ocean-k8s-floating-ip-outbound's Introduction

Introduction

Hello, %username%

As you know, Digital Ocean managed kubernetes service (aka DOKS) doesn't have an option to give you either NAT or static outbound public IP.
Sometimes you man want it, despite your k8s nodes can go up and down, being replaced, etc.

It's possible to send your outbound traffic through the floating IP if you do some tricks mentioned in this article: https://www.digitalocean.com/community/questions/send-outbound-traffic-over-floating-ip

The following tool is a successful attempt to automate this in DOKS.

Requirements

  • You'll need a separate node pool and your workloads requiring known outbound IP pool should have defined affinity/nodeSelector to the nodes from this pool.
  • You'll need unassigned Floating IPs as much as your node amount in a pool

This is how it's achieved. No NAT, unfortunately.

How it works

This tool deploys as a daemonset on all nodes and runs in privileged mode to be able to update route table in host network namespace.

  • The tool checks for a hostname match defined in matchString parameter
  • If hostname of a node doesn't match matchString, the tool will simply freeze in endless loop, reporting hourly that there's no match.
  • If there's a match, it will:
    • Check if there's already assigned floating IP
    • If there's floating IP already assigned, it will loop and check every 5 seconds the state. If you unassign IP from a node, it will reassign a free floating IP from a list.
    • If there's no assigned floating IP, it will:
      • Read IP list from floatingIPs parameter.

        Note
        Because of that, you have to preallocate floating IPs in DO and then put them into floatingIPs parameter.
        This is a protection mechanism to not assign some free Floating IP that you have in DO for other needs, and second reason is that this is a way how we define our outbound IP pool.

      • Check if there are still free unassigned Floating IPs left in DO, comparing it with the floatingIPs.

      • If there's nothing free, then it will tell about it in a log, and of course you simply need to allocate more IPs in DO.
        Note
        There should be as many floating IPs as nodes in the pool that is dedicated for static outbound IPs**

      • If there's free unassgined floating IP, it will simply assign it to self and update route table accordingly, and traffic will flow out of the node with this Floating IP.

      • Label node with do-outbound-floating-ip-enabled and possible values true / false

      • Label node with do-outbound-floating-ip and Floating IP address as a value

digital-ocean-k8s-floating-ip-outbound's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.