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-conf
namespace: monitor
labels:
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-exporter
name: redis-exporter
namespace: monitor
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: redis-exporter
template:
metadata:
labels:
app: redis-exporter
spec:
containers:
- name: redis-exporter
image: oliver006/redis_exporter
imagePullPolicy: IfNotPresent
args:
- --redis.password-file=/redis_passwd.json
volumeMounts:
- mountPath: /etc/localtime
name: tz-config
- mountPath: /redis_passwd.json
name: redis-conf-volume
subPath: redis_passwd.json #使用subPath方式挂载配置文件
ports:
- containerPort: 9121
protocol: TCP
volumes:
- 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-exporter
name: redis-exporter
namespace: monitor
spec:
type: NodePort
ports:
- name: http
port: 9121
targetPort: 9121
nodePort: 30012
selector:
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文章来源:https://www.toymoban.com/news/detail-818497.html
文章来源地址https://www.toymoban.com/news/detail-818497.html
到了这里,关于redis-exporter监控部署(k8s内)tensuns专用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!