目录
- Sentinel-dashboard安装(k8s部署)
- 一.拉取镜像并推送到私库
- 二.准备sentinel statefulset部署配置文件
- 三.部署并访问sentinel
Sentinel-dashboard安装(k8s部署)一.拉取镜像并推送到私库
这里选择的是docker hub已经有人制作好的Sentinel镜像
docker pull bladex/sentinel-dashboard:1.8.0#检查是否拉取成功docker images | grep bladex/sentinel
#重新给镜像打tagdocker tag bladex/sentinel-dashboard:1.8.0 [你的私人镜像仓库地址]/bladex/sentinel-dashboard:1.8.0docker pull [你的私人镜像仓库地址]/bladex/sentinel-dashboard:1.8.0
二.准备sentinel statefulset部署配置文件
vi sentinel-statefulset.yaml
#外部web访问服务apiVersion: v1kind: Servicemetadata: labels: app: sentinel name: sentinel-nodespec: type: NodePort ports: - name: "web" port: 8858 targetPort: 8858 nodePort: 30280 selector: app: sentinel---# 内部访问服务apiVersion: v1kind: Servicemetadata: name: sentinel labels: app: sentinelspec: type: ClusterIP ports: - port: 8858 targetPort: 8858 name: web - port: 8719 targetPort: 8719 name: api selector: app: sentinel---apiVersion: apps/v1kind: StatefulSetmetadata: name: sentinel namespace: default labels: app: sentinelspec: serviceName: sentinel replicas: 1 selector: matchLabels: app: sentinel template: metadata: labels: app: sentinel spec: containers: - name: sentinel image: x454262h22.qicp.vip:86/common/bladex/sentinel-dashboard:1.8.0 imagePullPolicy: IfNotPresent resources: limits: cpu: 450m memory: 1536Mi requests: cpu: 400m memory: 1536Mi env: - name: TZ value: Asia/Shanghai - name: JAVA_OPT_EXT value: -Dserver.servlet.session.timeout=7200 - name: SERVER_HOST value: -Dcsp.sentinel.dashboard.server=sentinel:8858 - name: SERVER_PORT value: -Dserver.port=8858 - name: SERVER_API value: -Dcsp.sentinel.api.port=8719 ports: - containerPort: 8858 - containerPort: 8719 volumeMounts: - name: vol-log mountPath: /opt/logs volumes: - name: vol-log persistentVolumeClaim: claimName: sentinel imagePullSecrets: - name: regsecret
因为该配置使用了PVC,所以要新增一个PVC配置文件(此篇文章有搭建NFSStorageClasses 的教程)
vi sentinel-pvc.yaml
apiVersion: v1kind: PersistentVolumeClaimmetadata: name: sentinel labels: app: sentinelspec: accessModes: - ReadWriteOnce storageClassName: "nfs-storage" resources: requests: storage: 10Gi
此处要保证K8s集群已经建立NFS的StorageClasses
三.部署并访问sentinel
#执行pvc的yaml文件kubectl apply -f sentinel-pvc.yaml#查看是否创建成功kubectl get pvc -o wide
#执行statefulset的yml文件kubectl apply -f sentinel-statefulset.yaml#检查是否部署成功kubectl get pod -o wide | grep sentinelkubectl get services -o wide | grep sentinel
等全部运行好了就通过任意一台k8s主机IP加端口30280访问sentinel,登陆的账号和密码也都是sentinel。当登陆后看到一个初始的sentinel-dashboard项目,部署就成功了。