Edgemesh test env config guide

    • Refer to Usage to prepare KubeEdge environment, make sure “docker0” exists
    • Then follow [EdgeMesh guide](#EdgeMesh test guide) to deploy Service

    model

    1. a headless service (a service with selector but ClusterIP is None)
    2. one or more pods’ labels match the headless service’s selector
    3. to request a server, use: :
      1. get the service’s name and namespace from domain name
      2. query all the backend pods from MetaManager by service’s namespace and name
      3. LoadBalance returns the real backend containers’ hostIP and hostPort

    ../_images/endtoend-test-flow.jpgflow

    1. client requests to server by server’s domain name
    2. DNS being hijacked to EdgeMesh by iptables rules, then a fake ip returned
    3. request hijacked to EdgeMesh by iptables rules
    4. EdgeMesh resolves request, gets domain name, protocol, request and so on
    5. EdgeMesh load balances:
      1. query backend pods of the service from MetaManager
      2. choose a backend based on strategy
    6. EdgeMesh transports request to server, wait for server’s response and then sends response back to client

    Assume we have two edge nodes in ready state, we call them edge node “a” and “b”

    Copy the deployment.yaml from the above link in cloud host, and run

    1. $ kubectl create -f deployment.yaml
    2. deployment.apps/nginx-deployment created

    Check the pod is up and is running state, as we could see the pod is running on edge node b

    1. $ kubectl get deployments
    2. NAME READY UP-TO-DATE AVAILABLE AGE
    3. nginx-deployment 1/1 1 1 63s

    Now create a service for the sample deployment

    Check the service and endpoints

    1. $ kubectl get service
    2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    3. nginx-svc ClusterIP None <none> 12345/TCP 77m

    To request a server, use url like this: <service_name>.<service_namespace>.svc.<cluster>:<port>

    1. $ curl http://nginx-svc.default.svc.cluster.local:12345
    2. <!DOCTYPE html>
    3. <head>
    4. <title>Welcome to nginx!</title>
    5. <style>
    6. width: 35em;
    7. margin: 0 auto;
    8. font-family: Tahoma, Verdana, Arial, sans-serif;
    9. }
    10. </style>
    11. </head>
    12. <body>
    13. <p>If you see this page, the nginx web server is successfully installed and
    14. working. Further configuration is required.</p>
    15. <p>For online documentation and support please refer to
    16. <a href="http://nginx.org/">nginx.org</a>.<br/>
    17. Commercial support is available at
    18. <a href="http://nginx.com/">nginx.com</a>.</p>
    19. <p><em>Thank you for using nginx.</em></p>
    20. </body>
    21. </html>
    • If you ever used EdgeMesh of old version, check your iptables rules. It might affect your test result.