1.创建Redis配置
apiVersion: v1 data: redis.conf: |- bind 0.0.0.0 port 6379 requirepass System@123 pidfile /var/run/redis_6379.pid save 900 1 save 300 10 save 60 10000 rdbcompression yes rdbchecksum yes dbfilename dump.rdb appendonly yes appendfilename "appendonly.aof" appendfsync everysec dir /data logfile "/data/redis-6379.log" kind: ConfigMap metadata: name: redis-config namespace: ops-share
2.创建PV/PVC
略
3.创建redis deployment文件
apiVersion: apps/v1 kind: Deployment metadata: name: t1-redis namespace: ops-share spec: replicas: 1 selector: matchLabels: app: t1-redis template: metadata: labels: app: t1-redis spec: containers: - image: redis:6.0.9 command: ["redis-server","/etc/redis/redis.conf"] name: t1-redis ports: - containerPort: 6379 volumeMounts: - name: redis-config mountPath: /etc/redis/redis.conf subPath: redis.conf - name: redis-data mountPath: /data volumes: - name: redis-config configMap: name: redis-config - name: redis-data persistentVolumeClaim: claimName: redis-data
4.创建Redis svc文件
apiVersion: v1 kind: Service metadata: labels: app: t1-redis-svc name: t1-redis-svc namespace: ops-share spec: ports: - name: tcp-redis-6379 port: 6379 protocol: TCP targetPort: 6379 selector: app: t1-redis
标签:name,单机,Redis,redis,t1,6379,k8s,data,metadata From: https://www.cnblogs.com/panwenbin-logs/p/17414990.html