reidis-exporter服务需要用到configmap、service、deployment服务
创建存放yaml目录
mkdir /opt/redis-exporter && cd /opt/redis-exporter
编辑yaml配置文件
vi configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:name: redis-confnamespace: monitorlabels:app: redis-exporter
data:redis_passwd.json: |- #填写各redis节点地址端口和密码{"redis://10.1.60.17:6379":"12345678","redis://10.1.60.18:6379":"12345678","redis://10.1.60.19:6379":"12345678"}
vi deployment.yaml
kind: Deployment
apiVersion: apps/v1
metadata:labels:app: redis-exportername: redis-exporternamespace: monitor
spec:replicas: 1revisionHistoryLimit: 10selector:matchLabels:app: redis-exportertemplate:metadata:labels:app: redis-exporterspec:containers:- name: redis-exporterimage: oliver006/redis_exporterimagePullPolicy: IfNotPresentargs:- --redis.password-file=/redis_passwd.jsonvolumeMounts:- mountPath: /etc/localtimename: tz-config- mountPath: /redis_passwd.jsonname: redis-conf-volumesubPath: redis_passwd.json #使用subPath方式挂载配置文件ports:- containerPort: 9121protocol: TCPvolumes:- name: tz-config #挂载时间配置,与宿主机配置时间同步hostPath:path: /usr/share/zoneinfo/PRC- name: redis-conf-volume #通过configmap挂载prometheus配置configMap:name: redis-conf
vi service.yaml
apiVersion: v1
kind: Service
metadata:labels:app: redis-exportername: redis-exporternamespace: monitor
spec:type: NodePortports:- name: httpport: 9121targetPort: 9121nodePort: 30012selector:app: redis-exporter
创建各yaml服务
kubectl apply -f configmap.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
查看redis-exporter pod是否正常运行
kubectl get pod -n monitor