Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee My腾云code My51cto

Happy_EveryDay

可以平凡 不可以平庸 无爱则无忧,无欲则无求,无怒而无敌,无怨才是佛。所有烦恼,都是放不下的执著 开源技群 328035181 MyGitee

博客园 首页 新随笔 管理

一、k8s节点及nacos库

master:192.168.91.166

node2:192.168.91.167

node3:192.168.91.168

 

image

 

K8s 集群:1 主 2 节点(k8s-master:192.168.91.166、node2:167、node3:168)
Nacos 镜像:swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nacos/nacos-server:latest
Nacos 库存:192.168.91.165  ry-config   

image

 

 

image

 

 

二、创建sentinel-dashboard集群

1、创建命名空间

 kubectl create namespace sentinel-dashboard-cluster

 2、创建sentinel-dashboard  deployment

2.1 ##创建deployment

kubectl apply -f sentinel-dashboard-deployment.yaml

####查看 

kubectl get pod  -n sentinel-dashboard-cluster

image

 

 

 

image

 

image

 

 

 

 

 

 

 

 

2.2 sentinel-dashboard-deployment.yaml内容

cat << 'EOF' > sentinel-dashboard-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sentinel-dashboard
namespace: sentinel-dashboard-cluster
spec:
replicas: 3
selector:
matchLabels:
app: sentinel-dashboard
template:
metadata:
labels:
app: sentinel-dashboard
spec:
containers:
- name: sentinel-dashboard
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/bladex/sentinel-dashboard:1.8.9
ports:
- containerPort: 8858
env:
- name: NACOS_ADDR
value: "nacos-headless.nacos-cluster.svc.cluster.local:8848"
- name: NACOS_USERNAME
value: "nacos"
- name: NACOS_PASSWORD
value: "nacos"
- name: NACOS_GROUP_ID
value: "DEFAULT_GROUP"
- name: NACOS_NAMESPACE
value: ""
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /
port: 8858
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 8858
initialDelaySeconds: 20
periodSeconds: 5
EOF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3、创建service

3.1

##创建service
kubectl apply -f sentinel-dashboard-service.yaml

####查看 

kubectl get svc -n sentinel-dashboard-cluster

 

image

 

image

 

 

 

 

 

 

 

 

 

3.2 ssentinel-dashboard-service.yaml内容

cat << 'EOF' > sentinel-dashboard-service.yaml
apiVersion: v1
kind: Service
metadata:
name: sentinel-dashboard-svc
namespace: sentinel-dashboard-cluster
spec:
type: ClusterIP
selector:
app: sentinel-dashboard
ports:
- port: 8858
targetPort: 8858
EOF

 

 

 

 

 

 

 

 

 

 

 

4、创建ingress

注:【三、创建ingress‑nginx‑controller 控制器组件

4.1

##创建ingress
kubectl apply -f sentinel-dashboard-ingress.yaml

####查看 

kubectl get ingress -n sentinel-dashboard-cluster

image

 

image

 

image

 

 

4.2 ssentinel-dashboard-ingress.yaml内容

cat << 'EOF' > sentinel-dashboard-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: sentinel-dashboard-ingress
namespace: sentinel-dashboard-cluster
annotations:

# 开启cookie会话保持,绑定浏览器到同一个pod,解决登录401
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "SENTINEL_SESSION"
nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
spec:
ingressClassName: nginx
rules:
- host: sentinel.192.168.91.166.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sentinel-dashboard-svc
port:
number: 8858
- host: sentinel.192.168.91.167.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sentinel-dashboard-svc
port:
number: 8858
- host: sentinel.192.168.91.168.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sentinel-dashboard-svc
port:
number: 8858
EOF

 

 

 

 

 

 

 

三、创建ingress‑nginx‑controller 控制器组件

1、wget https://gitee.com/mirrors/ingress-nginx/raw/main/deploy/static/provider/cloud/deploy.yaml

 

2、mv deploy.yaml文件名改成 ingress-nginx-deploy.yaml

 

image

 

3、vi  ingress-nginx-deploy.yaml文件的image调整https://docker.aityp.com/有效地址

  

image

 

4、创建ingress‑nginx‑controller

kubectl apply -f ingress-nginx-deploy.yaml

image

###部署完成检查

kubectl get pods -n ingress-nginx

 

查看 ingress‑nginx 的

service kubectl get svc -n ingress-nginx

image

 ###编辑 service 修改类型

kubectl edit svc ingress-nginx-controller -n ingress-nginx
找到
spec:
type: LoadBalancer
修改为
spec:
type: NodePort

image

 

image

 

 

 

image

 

image

 ####查看 pod 分布 

kubectl get pods -n ingress-nginx -o wide

 

image

 

 

 

 

 

 

四、sentinel-dashboard访问

http://sentinel.192.168.91.166.nip.io:31784/#/login
http://sentinel.192.168.91.167.nip.io:31784/#/login
http://sentinel.192.168.91.168.nip.io:31784/#/login

###查看 pod 分布

image

 

http://sentinel.192.168.91.167.nip.io:31784/#/dashboard/metric/sentinel-dashboard

image

 

 

 

 

posted on 2026-08-15 16:30  2026cn  阅读(2)  评论(0)    收藏  举报