zoukankan      html  css  js  c++  java
  • 二、Consul Service Mesh

    一、Consul Connect

    tips: -dev

    1.service definition

    counting.json

    {
      "service": {
        "name": "counting",
        "id": "counting-1",
        "port": 9003,
        "check": {
          "http": "http://localhost:9003/health",
          "method": "GET",
          "interval": "1s",
          "timeout": "1s"
        },
        "connect": {
          "sidecar_service": {}
        }
      }
    }
    

    dashboard.json

    {
      "service": {
        "name": "dashboard",
        "port": 9002,
        "connect": {
          "sidecar_service": {
            "proxy": {
          	  "upstreams": [{
          	    "destination_name": "counting",
          	    "local_bind_port": 5000
          	  }]
          	}
          }
        },
        "check": {
          "id": "dashboard-check",
          "http": "http://localhost:9002/health",
          "method": "GET",
          "interval": "1s",
          "timeout": "1s"
        }
      }
    }
    
    2.service register
    consul services register counting.json
    consul services register dashboard.json
    
    consul catalog services
    
    3.create intention
    consul intention create dashboard counting
    # Created: dashboard => counting(allow)
    
    4.start services
    PORT=9002 COUNTING_SERVICE_URL="http://localhost:5000" ./dashboard-service &
    PORT=9003 ./counting-service &
    
    5.start sidecar proxy
    consul connect proxy -sidecar-for counting-1 > counting-proxy.log &
    consul connect proxy -sidecar-for dashboard > dashboard-proxy.log &
    # we can visit http://localhost:5000 for counting-1 now.
    
    6.test proxy connections
    consul intention create -deny -replace dashboard counting
    consul intention create -allow -replace dashboard counting
    
    7.clean up
    consul intention delete dashboard counting
    consul services deregister counting.json
    consul services deregister dashboard.json
    
  • 相关阅读:
    LINUX 环境变量总结
    make的自动变量和预定义变量
    函数调用约定和堆栈
    如何查看linux命令源代码
    shell脚本中特定符合变量的含义
    【转载】Redhat5和6 YUM源配置的区别
    用路径分析法来编写测试用例
    linux ip 设置
    Mysql 的存储引擎,myisam和innodb的区别。
    一些编译php时的configure 参数
  • 原文地址:https://www.cnblogs.com/Ghostant/p/14635244.html
Copyright © 2011-2022 走看看