service.yml
apiVersion: v1 kind: Service metadata: name: sentinel labels: app: sentinel spec: type: NodePort ports: - port: 8280 targetPort: 8280 nodePort: 30280 name: web - port: 8719 targetPort: 8719 nodePort: 30719 name: api selector: app: sentinel
cm.yml
apiVersion: v1 kind: ConfigMap metadata: name: sentinel-cm data: sentinel.server.host: "192.168.43.22" #服务器IP地址 sentinel.server.port: "8280" sentinel.auth.username: "sentinel" sentinel.auth.password: "sentinel"
create.s.sentinel.start.sh
#!/usr/bin/env bash DIR=$(cd $(dirname $0); pwd) mkdir -p ${DIR}/sentinel/logs chmod -R 777 ${DIR}/sentinel/logs kubectl create -f ${DIR}/sentinel/cm.yml kubectl create -f ${DIR}/sentinel/service.yml kubectl create -f ${DIR}/sentinel/pod.yml kubectl get pod echo -e "\n\n\n" echo " success"
k8s部署
在网关应用中配置限流规则
引入依赖
<dependency> <groupId>com.alibaba.csp</groupId> <artifactId>sentinel-spring-cloud-gateway-adapter</artifactId> <version>1.8.2</version> </dependency> <dependency> <groupId>com.alibaba.csp</groupId> <artifactId>sentinel-transport-simple-http</artifactId> </dependency>
在配置文件中配置
spring: cloud: sentinel: transport: dashboard: 192.168.43.22:30280 port: 192.168.43.22:30719
定一个资源
该docker镜像没有问题 生成tar包上传镜像库或到其他地方部署
docker image save sentinel-dashboard:1.8.2 -o sentinel-dashboard.1.8.2.tar