prometheus08-k8s部署prometheus
admin
2023-03-02 01:02:35
0

1.基础环境有k8s集群

[root@kubemaster01 prometheus]# kubectl  get node 
NAME             STATUS   ROLES    AGE   VERSION
192.168.249.51   Ready       63d   v1.12.3
192.168.249.52   Ready       63d   v1.12.3
192.168.249.53   Ready       63d   v1.12.3
You have new mail in /var/spool/mail/root
[root@kubemaster01 prometheus]# kubectl  get cs
NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok                  
controller-manager   Healthy   ok                  
etcd-1               Healthy   {"health":"true"}   
etcd-2               Healthy   {"health":"true"}   
etcd-0               Healthy   {"health":"true"}   
[root@kubemaster01 prometheus]#

2.下载prometheus yaml

for file in  prometheus-configmap.yaml prometheus-rbac.yaml prometheus-service.yaml prometheus-statefulset.yaml ;do wget https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/prometheus/$file;done

3.设置动态storageclass

 3.1.kubectl apply  -f rbac.yml

kind: ServiceAccount
apiVersion: v1
metadata:
  name: nfs-client-provisioner
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    namespace: default
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    namespace: default
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io

3.2 设置存储deployment.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: nfs-client-provisioner
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nfs-client-provisioner
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: quay.io/external_storage/nfs-client-provisioner:latest
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: fuseim.pri/ifs
            - name: NFS_SERVER
              value: 192.168.249.54
            - name: NFS_PATH
              value: /data/k8s/prometheus
      volumes:
        - name: nfs-client-root
          nfs:
            server: 192.168.249.54
            path: /data/k8s/prometheus

3.4  kubectl apply  -f class.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
  archiveOnDelete: "false"

3.5 备注说明 nfs 是提前部署好的(ip:192.168.249.54)

[root@es prometheus]# cat /etc/exports
/data/k8s/prometheus  192.168.249.0/24(rw,sync,no_root_squash)
[root@es prometheus]#

4.修改prometheus的存储地址(prometheus-statefulset.yaml)

prometheus08-k8s部署prometheus

4.把 prometheus的svc 发布改为nodeport

prometheus08-k8s部署prometheus

5.部署

kubectl  apply -f prometheus-rbac.yaml   prometheus-configmap.yaml  prometheus-statefulset.yaml  prometheus-service.yaml

6. 访问

prometheus08-k8s部署prometheus

7.

prometheus08-k8s部署prometheus

相关内容

热门资讯

邮轮暴发汉坦病毒疫情,世卫确认... 据凤凰卫视报道,大西洋邮轮“洪迪厄斯”号暴发汉坦病毒疫情,世界卫生组识5月7日证实,船上共有5宗确诊...
内蒙古赤峰两村半个多世纪的土地... 澎湃新闻记者 王选辉争议土地大北叉沟。本文图均为 受访者 提供备受社会关注的“赤峰两村半个多世纪的土...
冥王星5月8日开启逆行 持续约... 被“逐出”太阳系大行星序列的冥王星5月8日将结束顺行,开启为期约5个月的逆行。这也是2026年冥王星...
夸大AI功能被起诉 苹果2.5... 当地时间5月5日,因夸大AI系统“苹果智能”(Apple Intelligence)的能力,误导数百...
学习机直播乱象调查:主播打北大... 极目新闻记者 刘闪 何佳仪打开短视频平台,各类学习机测评直播间随处可见。一些自诩自己是“老师”的主播...
即日起,郑州“错峰加油”有优惠... 进入5月,又到了郑州臭氧污染频发的季节,记者从郑州市生态环境局移动源污染监管处了解到,为减少臭氧污染...
汗水写热爱 篮球致青春 成人组1VS1比赛。河南日报全媒体记者 黄晖 摄“非常高兴能够参加这种全民赛事,也希望以后能够有更多...
荷兰六六民主党全国办公室遭爆炸... 荷兰警方7日说,荷兰执政党之一的六六民主党位于海牙的全国办公室当晚遭爆炸物袭击,造成建筑受损,无人受...
樱花树油烟机总是开不了怎么回事 电源问题。先检查电源是否未插上或是否电,若没有,将它重新插好,等待来电后测试,检查开不了机的问题是否...
燃气灶打火后一会就灭是什么原因 原因可能是电池没有电了,所以一开始能够打着火,但是燃烧了一会儿又熄灭了,这种情况下可以尝试更换一节新...