Sentinel-dashboard安装(k8s部署)

Sentinel-dashboard安装(k8s部署)

一.拉取镜像并推送到私库

这里选择的是docker hub已经有人制作好的Sentinel镜像

docker pull bladex/sentinel-dashboard:1.8.0
#检查是否拉取成功
docker images | grep bladex/sentinel

#重新给镜像打tag
docker tag bladex/sentinel-dashboard:1.8.0 [你的私人镜像仓库地址]/bladex/sentinel-dashboard:1.8.0
docker pull [你的私人镜像仓库地址]/bladex/sentinel-dashboard:1.8.0

二.准备sentinel statefulset部署配置文件

vi sentinel-statefulset.yaml
#外部web访问服务
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sentinel
  name: sentinel-node
spec:
  type: NodePort
  ports:
    - name: "web"
      port: 8858
      targetPort: 8858
      nodePort: 30280
  selector:
    app: sentinel
---
# 内部访问服务
apiVersion: v1
kind: Service
metadata:
  name: sentinel
  labels:
    app: sentinel
spec:
  type: ClusterIP
  ports:
    - port: 8858
      targetPort: 8858
      name: web
    - port: 8719
      targetPort: 8719
      name: api
  selector:
    app: sentinel
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: sentinel
  namespace: default
  labels:
    app: sentinel
spec:
  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: v1
kind: PersistentVolumeClaim
metadata:
  name: sentinel
  labels:
    app: sentinel
spec:
  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 sentinel
kubectl get services -o wide | grep sentinel

等全部运行好了就通过任意一台k8s主机IP加端口30280访问sentinel,登陆的账号和密码也都是sentinel。当登陆后看到一个初始的sentinel-dashboard项目,部署就成功了。

热门相关:娇妻的淫荡   胸大的后邻家少女   女人配送员   18岁模特丽卡华丽的外出   田埂精灵