CentaurusInfra / fornax

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

Added config map reporter to synchronize config gateway #93

Closed jshaofuturewei closed 2 years ago

jshaofuturewei commented 2 years ago

The PR is to synchronize a cluster gateway host ips as neighbors with its registered cluster.

Each cluster might have a gateway. We need all the clusters know their neighbor for vpc broadcast. Therefore, we update the cluster gateway config map from

apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-gateway-config
  namespace: default
data:
  gateway_host_ip: 1.0.0.2

To

apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-gateway-config
  namespace: default
data:
  gateway_host_ip: 1.0.0.2
  gateway_neighbors: 1.0.0.1, 1.0.0.3, ...

In order to make it automatically, when a cluster is registered as sub edgecluster in fornax, we create a config map reporter to synchronize its configured gateway host ip to the cluster it registers. Please check the following user senarios.

  1. Set up two fornax clusters node-a and node-c
  2. Start cloudhub in node-a
  3. Start edgehub in node-c
  4. Verify that node-c is registered as sub edge cluster in node-a
    root@node-a:~/go/src/github.com/fornax# kubectl get edgeclusters
    NAME     LASTHEARBEAT   HEALTHSTATUS   SUBEDGECLUSTERS   RECEIVED_MISSIONS       MATCHED_MISSIONS
    node-c   3s             healthy                          ["deployment-to-all"]   ["deployment-to-all"]

    5 Apply the following cluster gateway map to a cluster node-a

    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: cluster-gateway-config
    namespace: default
    data:
    gateway_host_ip: 1.0.0.2

    6 Apply the following cluster gateway map to a cluster node-c

    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: cluster-gateway-config
    namespace: default
    data:
    gateway_host_ip: 1.0.0.1
  5. Check the node-a cloudcore.logs and find the following sync messages
    I0318 18:44:31.363701    2435 upstream.go:188] dispatch message content: {Header:{ID:e57e85c2-3213-4427-8735-039f76f99ca7 ParentID: Timestamp:1647629071349 ResourceVersion: Sync:false} Router:{Source:clusterd Group:meta Operation:update Resource:node/node-c/default/configmap/node-c} Content:map[data:map[gateway_host_ip:1.0.0.1] metadata:map[clusterName:node-c creationTimestamp:<nil>]]}
  6. Verify that the node-c gateway 1.0,0.1 is added to node-a configmap as neighbors
    kubectl get configmap cluster-gateway-config -o=jsonpath='{.data}'
    {"gateway_host_ip":"1.0.0.2","gateway_neighbors":"1.0.0.1"}
pdgetrf commented 2 years ago

also, seems the TEST is failing. I've click the re-run and let's see how it goes this time.

pdgetrf commented 2 years ago

also, seems the TEST is failing. I've click the re-run and let's see how it goes this time.

tests have just passed.

pdgetrf commented 2 years ago

thanks for the quick update. there's some lint errors.

pdgetrf commented 2 years ago

@jshaofuturewei one little comment about mixing upper and lower case log messages. not a big issue. I'm okay merging it as is or if you prefer to fix it, that's okay too.

jshaofuturewei commented 2 years ago

@jshaofuturewei one little comment about mixing upper and lower case log messages. not a big issue. I'm okay merging it as is or if you prefer to fix it, that's okay too.

Most of messages are copied from existing codes. I have updated them to lowercases noew.

pdgetrf commented 2 years ago

@jshaofuturewei one little comment about mixing upper and lower case log messages. not a big issue. I'm okay merging it as is or if you prefer to fix it, that's okay too.

Most of messages are copied from existing codes. I have updated them to lowercases noew.

alright. thanks. I'll merge it if there's no more update after the CI runs.