Git Product home page Git Product logo

routecontrolservice's Introduction

RouteControlService

服务管理

配置

程序的包含如下主要配置,位于appsettings.json中:

Dbms: mysql # 活动的connectionstring配置
MYSQL_IP: localhost # mysql的主机,需要开放3306
MYSQL_UID: mcsdbg # mysql用户名
MYSQL_PWD: MyWceQc-cFgPynao # mysql密码
LISTER_PORT: 80 # 工作端口

可以直接使用环境变量来覆盖这些配置。

构建

可以在k8s节点上直接构建和部署。

make install

实现思路

要利用ISTIO重定向pod间的路由,需要以下步骤:

  1. 利用label对pod们进行标记
  2. 利用ISTIO的DestinationRule,将目标pod标记为某一subset
  3. 获取ISTIO的VService,对目标pod所属的Service路由规则进行改写
    1. 增加/查找条目,sourceLabels和endPoint(http.uri.exact/prefix)匹配的情况
    2. 修改destination.subset

因此,一条路由规则是一个元组: (Namespace:str,DesService:str,SrcPods:PodId[],DesPods:PodId[],EndpointControl[])

为了方便起见,我们给它起一个友好的名字,扩展元组为 (Namespace:str,DesService:str,FriendlyName:str,SrcPods:PodId[],DesPods:PodId[],EndpointControl[]), 记作record RouteRule 然后,我们规定(Namespace:str,DesService:str,FriendlyName:str)可以唯一确定这样的一个元组,记作record RouteRuleId

从而实现以下功能:

  • 传入精确的DesServiceNamespace,可以模糊匹配/不传入FriendlyName,查询所有匹配条件的规则
  • 传入完整的record RouteRule,实现路由规则的增加/修改
  • 传入精确完整的record RouteRuleId,实现路由规则的删除
  • 传入精确的DesServiceNamespace,模糊匹配/不传入FriendlyName,实现批量删除

局限性:

  1. 假定用户不会手动修改ISTIO资源
  2. 假定这些路由规则间不存在冲突,可以正常工作

目录结构

├─📂IstioEntities ISTIO资源实体模型定义,一般无需修改,请[参阅官方文档](https://istio.io/latest/zh/docs/reference/config/networking/virtual-service/)
├─📂RouteControlling Bean和Service
│	├─🗒️IRouteController.cs 包含路由控制Service接口和一个假实现
│	├─🗒️RouteController.cs 包含路由控制Service的真实现
│	└─🗒️RouteRule.cs Bean
├─📂Properties
│   └─🗒️launchSettings.json 启动配置│
├─📂TestData 接口测试数据json
│
├─🗒️application.yaml 主要配置文件
├─🗒️appsettings.json 基本配置文件
├─🗒️appsettings.Development.json 基本配置文件(dev)
├─🗒️Dockerfile (自动生成)
├─🗒️MResponse.cs MResponse
├─🗒️Program.cs 程序入口(最小API),包含**请求处理、Bean定义和依赖注入**
├─🗒️README.md 本文件
├─🗒️RouteControlService.csproj 项目文件(自动生成),包含**依赖项**
├─🗒️RouteControlService.sln 解决方案文件(自动生成)
├─🗒️deploy.yaml 部署配置文件
└─🗒️Makefile 构建脚本

routecontrolservice's People

Contributors

ferdinandsu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.