Giter Site home page Giter Site logo

k8s-network-config-operator's Introduction

K8s network operator

Alt text

This is a network configuration operator very similar to https://github.com/burnyd/k8sNetworkgNMIOperator that it is not exactly the same where that operator uses openconfig to do all of the pushing of configuration. This operator uses eAPI to push the configuration.

This should not be seen as production ready but rather as a means of demo of what is possible with network automation and kubernetes.

goEAPI is pretty simplistic and easy to use. Plenty of general examples can be found here within this gist

This is build on the Kubernetes operator framework which is really amazing for providing scaffolding to create kubernetes operators.

Here is a CRD as an example state for a description of a network device. Today this is built using EOS but anything could be substituted with enough work and a Go module related to a device.

apiVersion: network.networkconfigoperator/v1
kind: NetDevs
metadata:
  name: ceos1
  namespace: networkconfig
spec:
  username: admin
  password: admin
  host: 172.20.20.2
  transport: http
  port: 80
  networkos: eos
  runningconfig:  |+
    transceiver qsfp default-mode 4x10G
    !
    service routing protocols model multi-agent
    !
    hostname ceos1
    !
    spanning-tree mode mstp
    !
    no aaa root

The general idea is that a user can use their current tooling(salt, ansible etc) render a config a long with the rest of the kubernetes yaml manifest or even talk directly to the kube api and create this cr based off of tooling.

I truncated this so it is east to view. Just an example of keys within the data structure.

apiVersion: network.networkconfigoperator/v1 # The API for the CRD
kind: NetDevs # The CR
metadata:
  name: ceos1 # Field for the name of the device.
  namespace: networkconfig # This is necessary as this needs to run within this name space
spec:
  username: admin # Username this can be either plain text or as a k8s secret.
  password: admin # Password this can be either plain text or as a k8s secret.
  host: 172.20.20.2 # IP address of the device
  transport: http # Transport http,https or ssh.
  port: 80 # Port of the device.
  networkos: eos # Network OS eos is supported today but can add functionality for anything else.
  runningconfig: # String of the network configuration.

Demo

Create a kind cluster unless you already have access to a kubernetes cluster:

kind create cluster

Apply everything needed for the operator to run inside of the cluster with kustomize this will install the CRD, service account and rbac information.

kubectl apply -k manifests/.

Edit the configuration files or create your own. For this demo they are located inside of manifests/ceos

kubectl apply -f manifests/ceos/.

You should see two devices if you are following the demo

➜  network-config-operator git:(master) ✗ kubectl get netdevs -n networkconfig
NAME    AGE
ceos1   7m7s
ceos2   7m7s
2022-01-26T02:52:38.298Z        INFO    Checking on Device 192.168.4.244
2022-01-26T02:52:38.372Z        INFO    Switch config matches CR
2022-01-26T02:52:38.383Z        INFO    Starting to check on the device
2022-01-26T02:52:38.383Z        INFO    Device is EOS
2022-01-26T02:52:38.383Z        INFO    Checking on Device 192.168.4.244
2022-01-26T02:52:38.452Z        INFO    Switch config matches CR

Tested versions

  • Kubernetes 1.22.2
  • cEOS 4.26.1F
  • Operator framework v3
  • go 1.16

k8s-network-config-operator's People

Contributors

burnyd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

k8s-network-config-operator's Issues

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.