# springCloud-k8s **Repository Path**: Sphere_Docker/springCloud-k8s ## Basic Information - **Project Name**: springCloud-k8s - **Description**: springCloud基于k8s发现服务 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 7 - **Created**: 2020-04-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # springCloud ### kuberbetes 镜像仓库访问权限 ``` kubectl create secret docker-registry docker-registry-key --docker-username=646154945@qq.com --docker-password=[PASSWORD] --docker-email=646154945@qq.com --docker-server=registry.cn-hangzhou.aliyuncs.com -n weilus-cloud ``` ### kubernetes 服务访问权限 ``` kubectl apply -f fabric8-rbac.yaml ``` ### 基础设施 db redis ``` kubectl apply -f pvc-mysql.yaml -f svc-mysql.yaml -f pvc-redis.yaml -f svc-redis.yaml ``` ### kubernetes 集中配置管理 > 1. spring-cloud-starter-kubernetes-config kubernetes configMap配置 > 2. 自动更新配置 ``` kubectl edit configmap gateway -n weilus-cloud kubectl edit configmap flux-call -n weilus-cloud kubectl edit configmap flux-service -n weilus-cloud ``` ### 用户中心 oauth2 ``` kubectl apply -f https://raw.githubusercontent.com/weilus923/springCloud-k8s/master/auth/k8s.yaml ``` #### 用户申请令牌 ``` curl -X POST http://acme:acmesecret@10.96.10.96:8088/oauth/oauth/token \ -d 'grant_type=password&client_id=acme&username=liutaiq&password=123456' ``` #### 受信任的机构申请令牌 ``` curl -X POST http://accc:acccsecret@10.96.10.96:8088/oauth/oauth/token \ -d 'grant_type=client_credentials' ``` #### 授权码申请令牌 > 引导用户授权 ``` http://127.0.0.1:8080/oauth/authorize?client_id=acau&response_type=code&scope=user_info&redirect_uri=http://aa.ccdd ``` > 机构获取授权码; 申请令牌 ``` curl -X POST http://acau:acausecret@10.96.10.96:8088/oauth/oauth/token \ -d 'grant_type=authorization_code&code=pg4Vz2&redirect_uri=http://aa.ccdd' ``` ### 网关 gateway 统一外网入口,限流,负载,降级 ``` kubectl apply -f gateway/k8s.yaml ``` #### 配置路由 ``` kubectl edit configmap gateway -n weilus-cloud ``` ### 熔断 hystrix ``` kubectl apply -f webflux-hystrix/k8s-flux-call.yaml -f webflux-hystrix/k8s-flux-service.yaml 查看路由配置: curl http://10.244.1.130:8088/actuator/gateway/routes 访问flux-call curl http://10.244.1.128:8081/test/sayName curl http://10.244.1.128:8081/test/sayHello 访问flux-service curl -H "Content-Type: application/json" -X POST --data '{"name":"德华"}' http://10.244.1.129:8081/api/sayHello 经网关访问flux-call curl http://10.244.1.131:8088/flux-call/test/sayHello ``` ### 微服务监控 admin spring-boot-admin发现eureka服务并监控; spring-boot-admin集成turbine; 监控熔断器 ### 微服务云端开发 > 1. jenkins pipeline https://github.com/weilus923/jenkins > 2. 微服务维护k8s k8s.yaml 扩容 缩容 滚动更新