CentaurusInfra / fornax

Fornax for autonomous and flexible edge computing
Apache License 2.0
8 stars 16 forks source link

Added grpc server #96

Closed jshaofuturewei closed 2 years ago

jshaofuturewei commented 2 years ago

The PR is to use grpc servers to pass vpc and subnet information across clusters

When a vpc is created, for example,

apiVersion: "mizar.com/v1"
kind: Vpc
metadata:
  name: vpc1
spec:
  vni: "2"
  ip: "192.168.0.0"
  prefix: "16"
  status: "Init"
  dividers: 1

It will look up all the gateway neighbor ips and sent its vpc and the local gateway information to its neighbors

root@ip-172-31-6-11:~/go/src/github.com/fornax# kubectl get configmap  cluster-gateway-config -o json
{
    "apiVersion": "v1",
    "data": {
        "gateway_host_ip": "172.31.6.11",
        "gateway_name": "gw0",
        "gateway_neighbors": "gw2=172.31.4.217",
    },

Therefore, we know its vpc name vpc1 and gateway ip 172.31.6.11. The above information will be sent to its neighbor gw0 whose ip is 172.31.4.217

We can verify the information by checking its neighbor configmap information

root@ip-172-31-4-217:~/go/src/github.com/fornax# kubectl get configmap  cluster-gateway-config -o json
{
    "apiVersion": "v1",
    "data": {
        "172.31.6.11": "",
        "gateway_host_ip": "172.31.4.217",
        "gateway_name": "gw2",
        "gateway_neighbors": "gw0=172.31.6.11",
        "gw0": "172.31.6.11,172.31.6.11",
        "vpc1": "172.31.6.11"
    },

The vpc name vpc1 and its gateway host ip 172.31.6.11 is added to configmap in a nearby cluster

Do the same step in ip-172-31-4-217 so that 2 clusters know their vpc name and gateway host ip

root@ip-172-31-6-11:~/go/src/github.com/fornax# kubectl get configmap  cluster-gateway-config -o json
{
    "apiVersion": "v1",
    "data": {
        "gateway_host_ip": "172.31.6.11",
        "gateway_name": "gw0",
        "gateway_neighbors": "gw2=172.31.4.217",
        "vpc1": "172.31.4.217"
    },

The next step is to add a subnet in ip-172-31-6-11

apiVersion: "mizar.com/v1"
kind: Subnet
metadata:
  name: net1
spec:
  vpc: "vpc1"
  vni: "2"
  ip: "192.168.0.0"
  prefix: "24"
  status: "Init"
  bouncers: 1

The new created subnet net1 is a local subnet whose virtual is FALSE

root@ip-172-31-6-11:~/go/src/github.com/fornax# kubectl get subnets
NAME   IP             PREFIX   VNI   VPC    STATUS        VIRTUAL   REMOTEGATEWAYS   BOUNCERS   CREATETIME                   PROVISIONDELAY
net0   20.0.0.0       8        1     vpc0   Provisioned   false                      1          2022-03-28T15:40:10.884670   62.489609
net1   192.168.0.0    24       2     vpc1   Provisioned   false                      1

Check the another cluster ip-172-31-4-217

root@ip-172-31-4-217:~/go/src/github.com/fornax# kubectl get subnets
NAME   IP             PREFIX   VNI   VPC    STATUS        VIRTUAL   REMOTEGATEWAYS   BOUNCERS   CREATETIME                   PROVISIONDELAY
net0   20.0.0.0       8        1     vpc0   Provisioned   false                      1          2022-03-28T16:18:35.968499   62.883197
net1   192.168.0.0    24       2     vpc1   Provisioned   true      <no value>       1

A subnet net1 is created but its Virtual is True.

pdgetrf commented 2 years ago

this is very exciting!