Background:
Refer to Kubernetes 1.20.5 above to build Sentinel. We want to build a service to test how the Sentinel service behaves. Certainly other services without integration also got a demo, refer to: https://blog.csdn.net/liuhuiteng/article/details/107399979.
Sentinel – Alibaba-Sentinel-Rate – Database Server Test
1. Maven builds the test JAR package
With reference tohttps://gitee.com/didispace/SpringCloud-Learning/tree/master/4-Finchley/alibaba-sentinel-rate-limiting
Change the connection to Setinel Dashboard to the service IP and port 8858 of Setinel in Kubernetes cluster.
Maven packages the JAR package.
2. Build the image image
In fact, idea can be directly typed out image image. We’ll study that later. Reuse the Dockerfile that used to do the other springboot. cat Dockerfile
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD app.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Note: I changed the name of the jar package to app.jar in my MV… It is also possible to customize…… in the pom. XML file
Docker build - t ccr.ccs.tencentyun.com/XXXX/testjava:0.3. Docker push ccr.ccs.tencentyun.com/XXXXX/testjava:0.3
3. Deploy test services
cat alibaba-sentinel-rate-limiting.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: test spec: replicas: 1 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 selector: matchLabels: app: test template: metadata: labels: app: test spec: containers: - name: The test image: ccr.ccs.tencentyun.com/XXXX/testjava:0.3 ports: - containerPort: 8001 resources: requests: the memory: "256M" cpu: "250m" limits: memory: "512M" cpu: "500m" imagePullSecrets: - name: tencent --- apiVersion: v1 kind: Service metadata: name: test labels: app: test spec: ports: - port: 8001 protocol: TCP targetPort: 8001 selector: app: test
Note: The service is named test……
kubectl apply -f alibaba-sentinel-rate-limiting.yaml -n nacos
4. Visit the Alibaba-Sentinel-Rate – speed library service and observe the Sentinel Dashboard
Visit the Alibaba-Sentinel-Rate-memory service and your internal tests will be exposed without Ingress. Direct internal CLUSERIP access
$kubectl get SVC NAME TYPE cluster-ip external-ip PORT(S) AGE mysql ClusterIP 172.254.43.125 <none> 3306/TCP None < None > 8848/TCP,7848/TCP 2D8H Sentinel ClusterIP 172.254.163.115 < None > 8858/TCP,8719/TCP 26H test ClusterIP 172.254.143.171 <none BB0 8001/TCP 3h5m
Kubernetes server cluster internal curl 172.254.143.171:8001 / hello curl up ten times… Go to https://sentinel.saynaihe.com/ to observe
Test the setinel function
1. Flow control rules
Yeah, I visited it, but it’s a record of real-time monitoring
Do a random flow control threshold test and set QPS to 1
Well, here’s the effect. Ha ha ha ha
Well, there are failures.
But the weird thing is that mine is supposed to be a test and it’s not configured to store anything. There is no constant real-time monitoring….. I don’t know if the storage is not configured.
2. Rules for demotion
I don’t test the rules for relegation. simple
3. Hot
4. System rules
5. Authorization rules
6. Cluster flow control
List of machines. Well, I’m going to change the pod into two and try to see if I understand that so it’s going to become two, right?
Go back to the Kubectl scale –help
kubectl scale deployment/test --replicas=2 -n nacos
For me the basic effect has been achieved… Keep studying the rest