Add Sdewan Mwan3Conf CRD and controller 43/2243/5
authorchengli3 <cheng1.li@intel.com>
Wed, 19 Feb 2020 14:30:06 +0000 (22:30 +0800)
committerchengli3 <cheng1.li@intel.com>
Mon, 24 Feb 2020 05:46:39 +0000 (13:46 +0800)
commit33ab8afd32ec31400200e4d26d6df5a0b7475b36
tree2619ab3b30c8786c610037cf614522dbe180e0ee
parent9477b11961a10702cd91e4b4d1cb25515e3bac56
Add Sdewan Mwan3Conf CRD and controller

The sdewan operator is developed under kubebuilder framework

We define two CRDs in this patch: Sdewan and Mwan3Conf

Sdewan defines the CNF base info, which node we should deploy the CNF
on, which network should the CNF use with multus CNI, etc.

The Mwan3Conf defines the mwan3 rules. In the next step, we are going to
develop the firewall and the ipsec functions. Mwan3Conf is validated by
k8s api admission webhook.

For each created Sdewan instance, the controller creates a pod, a
configmap and a service for the instance. The pod runs openswrt which
provides network services, i.e. sdwan, firewall, ipsec etc.

The configmap stores the network interface information and the
entrypoint.sh.
The network interface information has the following format:
```
[
  {
    "name": "ovn-priv-net",
    "isProvider": false,
    "interface": "net0",
    "defaultGateway": false
  }
]
```

The service created by the controller is used for openwrt api access.
We call this svc to apply rules, get openwrt info, restart openwrt
service.

After the openwrt pod ready, the Sdewan controller apply the configured
mwan3 rules.
mwan3 rule details are configured in Mwan3Conf CR, which is referenced
by Sdewan.Spec.Mwan3Conf
Every time the Mwan3Conf instance changes, the controller re-apply the
new rules by calling opwnrt
api. We can also change the rule refernce at the runtime.

Signed-off-by: chengli3 <cheng1.li@intel.com>
Change-Id: Ic6fa4e8c61da5a560d69f749cd40d8f3b9320e81
69 files changed:
.gitignore [new file with mode: 0644]
Dockerfile [new file with mode: 0644]
Makefile [new file with mode: 0644]
PROJECT [new file with mode: 0644]
api/v1alpha1/groupversion_info.go [new file with mode: 0644]
api/v1alpha1/mwan3conf_types.go [new file with mode: 0644]
api/v1alpha1/mwan3conf_webhook.go [new file with mode: 0644]
api/v1alpha1/sdewan_types.go [new file with mode: 0644]
api/v1alpha1/zz_generated.deepcopy.go [new file with mode: 0644]
config/certmanager/certificate.yaml [new file with mode: 0644]
config/certmanager/kustomization.yaml [new file with mode: 0644]
config/certmanager/kustomizeconfig.yaml [new file with mode: 0644]
config/crd/bases/batch.sdewan.akraino.org_mwan3confs.yaml [new file with mode: 0644]
config/crd/bases/batch.sdewan.akraino.org_sdewans.yaml [new file with mode: 0644]
config/crd/kustomization.yaml [new file with mode: 0644]
config/crd/kustomizeconfig.yaml [new file with mode: 0644]
config/crd/patches/cainjection_in_mwan3confs.yaml [new file with mode: 0644]
config/crd/patches/cainjection_in_sdewans.yaml [new file with mode: 0644]
config/crd/patches/webhook_in_mwan3confs.yaml [new file with mode: 0644]
config/crd/patches/webhook_in_sdewans.yaml [new file with mode: 0644]
config/default/kustomization.yaml [new file with mode: 0644]
config/default/manager_auth_proxy_patch.yaml [new file with mode: 0644]
config/default/manager_image_patch.yaml [new file with mode: 0644]
config/default/manager_webhook_patch.yaml [new file with mode: 0644]
config/default/webhookcainjection_patch.yaml [new file with mode: 0644]
config/manager/kustomization.yaml [new file with mode: 0644]
config/manager/manager.yaml [new file with mode: 0644]
config/prometheus/kustomization.yaml [new file with mode: 0644]
config/prometheus/monitor.yaml [new file with mode: 0644]
config/rbac/auth_proxy_role.yaml [new file with mode: 0644]
config/rbac/auth_proxy_role_binding.yaml [new file with mode: 0644]
config/rbac/auth_proxy_service.yaml [new file with mode: 0644]
config/rbac/kustomization.yaml [new file with mode: 0644]
config/rbac/leader_election_role.yaml [new file with mode: 0644]
config/rbac/leader_election_role_binding.yaml [new file with mode: 0644]
config/rbac/mwan3conf_editor_role.yaml [new file with mode: 0644]
config/rbac/mwan3conf_viewer_role.yaml [new file with mode: 0644]
config/rbac/role.yaml [new file with mode: 0644]
config/rbac/role_binding.yaml [new file with mode: 0644]
config/rbac/sdewan_editor_role.yaml [new file with mode: 0644]
config/rbac/sdewan_viewer_role.yaml [new file with mode: 0644]
config/samples/batch_v1alpha1_mwan3conf.yaml [new file with mode: 0644]
config/samples/batch_v1alpha1_sdewan.yaml [new file with mode: 0644]
config/webhook/kustomization.yaml [new file with mode: 0644]
config/webhook/kustomizeconfig.yaml [new file with mode: 0644]
config/webhook/manifests.yaml [new file with mode: 0644]
config/webhook/service.yaml [new file with mode: 0644]
controllers/mwan3conf_controller.go [new file with mode: 0644]
controllers/sdewan_controller.go [new file with mode: 0644]
controllers/suite_test.go [new file with mode: 0644]
deploy/crds/sdewan.akraino.org_mwan3rules_crd.yaml [new file with mode: 0644]
deploy/crds/sdewan.akraino.org_sdewans_crd.yaml [new file with mode: 0644]
deploy/crds/sdewan.akraino.org_v1alpha1_mwan3rule_cr.yaml [new file with mode: 0644]
deploy/crds/sdewan.akraino.org_v1alpha1_sdewan_cr.yaml [new file with mode: 0644]
deploy/operator.yaml [new file with mode: 0644]
deploy/role.yaml [new file with mode: 0644]
deploy/role_binding.yaml [new file with mode: 0644]
deploy/service_account.yaml [new file with mode: 0644]
go.mod [new file with mode: 0644]
go.sum [new file with mode: 0644]
hack/boilerplate.go.txt [new file with mode: 0644]
main.go [new file with mode: 0644]
openwrt/mwan3.go [new file with mode: 0644]
openwrt/openwrtclient.go [new file with mode: 0644]
openwrt/service.go [new file with mode: 0644]
openwrt/utils.go [new file with mode: 0644]
readme.md [new file with mode: 0644]
sdewan-deploy.yaml [new file with mode: 0644]
wrtprovider/wrtprovider.go [new file with mode: 0644]