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

相关内容

热门资讯

20名“高考状元”选择学医!此... 2026年香港高考的24名“状元”中,有20人明确表示将留港攻读医科。多年来,香港最顶尖的“学霸们”...
“抢人大战”,风向有变? 各地一场“抢老人”的大战,已然徐徐拉开大幕。最近,有着人口净流出压力的吉林,计划拿出3亿元发展旅居康...
石家庄一家不限量的爱心素食面馆... 7月24日正午时分,记者来到位于石家庄市新华区东明家居西二环店北门旁的“素面”小店,不大的店面里坐满...
中材科技申请风电叶片外补强辅助... 国家知识产权局信息显示,中材科技(伊吾)风电叶片有限公司申请一项名为“风电叶片外补强辅助固化装置”的...
为人工智能治理提供重要公共产品 图为2026世界人工智能大会暨人工智能全球治理高级别会议举办期间,在世博展览馆灵心巧手展位,参观者观...
泽连斯基称俄对乌多地发动大规模... 当地时间25日,乌克兰总统泽连斯基通报称,俄军于当日凌晨对乌克兰多地发动大规模空袭,使用2枚导弹、近...
不怕没水!武汉科学家找到水稻身... 干旱来了,水稻启动"抗旱模式",可一启动就长不大、结得少——这是困扰育种界几十年的老难题。7月23日...
多款手机涨价超1000元,大存... 今年暑期消费旺季,国内智能手机市场迎来一轮显著的价格上调。第一财经记者走访深圳多家品牌门店发现,以v...
SpaceX上市后星舰首飞:首... 界面新闻实习记者 | 李响 在经历多次波折后,SpaceX公司的星舰(Starship)终于完成了...
博世洗衣机强制解锁 博世洗衣机强制解锁的方法可能因型号和具体情况而异。以下是一些常见的方法:1. 按住电源键:有些博世洗...