CoSky-Mirror就像一个镜子放在Nacos、CoSky中间,构建一个统一的服务发现平台。
ExamplesServiceConsumer--RPC-->ServiceProviderExamples安装GradleKotlinDSL
valcoskyVersion="1.2.10";implementation("me.ahoo.cosky:spring-cloud-starter-cosky-config:${coskyVersion}")implementation("me.ahoo.cosky:spring-cloud-starter-cosky-discovery:${coskyVersion}")implementation("org.springframework.cloud:spring-cloud-starter-loadbalancer:3.0.3")Maven<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="https://maven.apache.org/POM/4.0.0"xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="https://maven.apache.org/POM/4.0.0https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><artifactId>demo</artifactId><properties><cosky.version>1.2.10</cosky.version></properties><dependencies><dependency><groupId>me.ahoo.cosky</groupId><artifactId>spring-cloud-starter-cosky-config</artifactId><version>${cosky.version}</version></dependency><dependency><groupId>me.ahoo.cosky</groupId><artifactId>spring-cloud-starter-cosky-discovery</artifactId><version>${cosky.version}</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId><version>3.0.3</version></dependency></dependencies></project>bootstrap.yaml(Spring-Cloud-Config)spring:application:name:${service.name:cosky-rest-api}cloud:cosky:namespace:${cosky.namespace:cosky-{system}}config:config-id:${spring.application.name}.yamlredis:mode:${cosky.redis.mode:standalone}url:${cosky.redis.uri:redis://localhost:6379}logging:file:name:logs/${spring.application.name}.logREST-APIServer(Optional)安装REST-APIServer方式一:下载可执行文件下载 rest-api-server
解压 cosky-rest-api-1.2.10.tar
cdcosky-rest-api-1.2.10#工作目录:cosky-rest-api-1.2.10bin/cosky-rest-api--server.port=8080--cosky.redis.uri=redis://localhost:6379方式二:在Docker中运行dockerpullahoowang/cosky-rest-api:1.2.10dockerrun--namecosky-rest-api-d-p8080:8080--linkredis-eCOSKY_REDIS_URI=redis://redis:6379ahoowang/cosky-rest-api:1.2.10方式三:在Kubernetes中运行apiVersion:apps/v1kind:Deploymentmetadata:name:cosky-rest-apilabels:app:cosky-rest-apispec:replicas:1selector:matchLabels:app:cosky-rest-apitemplate:metadata:labels:app:cosky-rest-apispec:containers:-env:-name:COSKY_REDIS_MODEvalue:standalone-name:COSKY_REDIS_URIvalue:redis://redis-uri:6379image:ahoowang/cosky-rest-api:1.2.10name:cosky-rest-apiports:-containerPort:8080protocol:TCPresources:limits:cpu:"1"memory:1280Mirequests:cpu:250mmemory:1024MivolumeMounts:-mountPath:/etc/localtimename:volume-localtimevolumes:-hostPath:path:/etc/localtimetype:""name:volume-localtime---apiVersion:v1kind:Servicemetadata:name:cosky-rest-apilabels:app:cosky-rest-apispec:selector:app:cosky-rest-apiports:-name:restport:80protocol:TCPtargetPort:8080Dashboardhttps://localhost:8080/dashboard
服务依赖拓扑基于角色的访问控制(RBAC)cosky:保留用户名,超级用户,拥有最高权限。应用首次启动时会初始化超级用户(cosky)的密码,并打印在控制台。忘记密码也不用担心,可以通过配置 enforce-init-super-user:true,CoSky 会帮助你重新初始化密码并打印在控制台。----------------******CoSky-initsuperuser:[cosky]password:[6TrmOux4Oj]******----------------admin:保留角色,超级管理员角色,拥有所有权限,一个用户可以绑定多个角色,一个角色可以绑定多个资源操作权限。权限控制粒度为命名空间,读写操作角色权限添加角色
用户管理添加用户
审计日志命名空间管理配置管理编辑配置
回滚配置
从Nacos导入配置
服务管理编辑服务实例信息
REST-APIhttps://localhost:8080/swagger-ui/index.html#/
Namespace
/v1/namespacesGET/v1/namespaces/{namespace}PUTGET/v1/namespaces/currentGET/v1/namespaces/current/{namespace}PUTConfig
/v1/namespaces/{namespace}/configsGET/v1/namespaces/{namespace}/configs/{configId}GETPUTDELETE/v1/namespaces/{namespace}/configs/{configId}/versionsGET/v1/namespaces/{namespace}/configs/{configId}/versions/{version}GET/v1/namespaces/{namespace}/configs/{configId}/to/{targetVersion}PUTService/v1/namespaces/{namespace}/services/GET/v1/namespaces/{namespace}/services/{serviceId}/instancesGETPUT/v1/namespaces/{namespace}/services/{serviceId}/instances/{instanceId}DELETE/v1/namespaces/{namespace}/services/{serviceId}/instances/{instanceId}/metadataPUT/v1/namespaces/{namespace}/services/{serviceId}/lbGETJMH-Benchmark基准测试运行环境:笔记本开发机(MacBookPro(M1))所有基准测试都在开发笔记本上执行。Redis部署环境也在该笔记本开发机上。ConfigServicegradlecosky-config:jmh#orjava-jarcosky-config/build/libs/cosky-config-1.2.10-jmh.jar-bmthrpt-t25-wi1-rfjson-f1BenchmarkModeCntScoreErrorUnitsConsistencyRedisConfigServiceBenchmark.getConfigthrpt256733987.827ops/sRedisConfigServiceBenchmark.getConfigthrpt241787.679ops/sRedisConfigServiceBenchmark.setConfigthrpt140461.112ops/sServiceDiscoverygradlecosky-discovery:jmh#orjava-jarcosky-discovery/build/libs/cosky-discovery-1.2.10-jmh.jar-bmthrpt-t25-wi1-rfjson-f1BenchmarkModeCntScoreErrorUnitsConsistencyRedisServiceDiscoveryBenchmark.getInstancesthrpt76621729.048ops/sConsistencyRedisServiceDiscoveryBenchmark.getServicesthrpt455760632.346ops/sRedisServiceDiscoveryBenchmark.getInstancesthrpt226909.985ops/sRedisServiceDiscoveryBenchmark.getServicesthrpt304979.150ops/sRedisServiceRegistryBenchmark.deregisterthrpt255305.648ops/sRedisServiceRegistryBenchmark.registerthrpt110664.160ops/sRedisServiceRegistryBenchmark.renewthrpt210960.325ops/s
评论