1. Basic cluster environment k8s
[root@kubemaster01 prometheus]# kubectl get node NAME STATUS ROLES AGE VERSION 192.168.249.51 Ready <none> 63d v1.12.3 192.168.249.52 Ready <none> 63d v1.12.3 192.168.249.53 Ready <none> 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. Download 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. Set the dynamic 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 settings are stored 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: Apps: nfs-client-commissions strategy: type: Recreate template: metadata: labels: Apps: nfs-client-commissions 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 Remarks nfs is deployed in advance (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. Modify prometheus memory address (prometheus-statefulset.yaml)
4. The prometheus the svc releases on nodeport
5. Deploy
kubectl apply -f prometheus-rbac.yaml prometheus-configmap.yaml prometheus-statefulset.yaml prometheus-service.yaml
6. Access
7.