k8s部署redis单实例数据存节点配置configmap.yaml
apiVersion: v1 kind: ConfigMap metadata: name: redis-conf namespace: workredis data: redis.conf: | bind 0.0.0.0 port 6379 requirepass test2021aaa pidfile .pid appendonly yes cluster-config-file nodes-6379.conf pidfile /data/testdata/redis/log/redis-6379.pid cluster-config-file /data/testdata/redis/conf/redis.conf dir /data/testdata/redis/data/ logfile "/data/testdata/redis/log/redis-6379.log" cluster-node-timeout 5000 protected-mode no
k8s部署redis单实例配置StatefulSet.yaml
apiVersion: apps/v1 kind: StatefulSet metadata: name: redis namespace: workredis spec: replicas: 1 serviceName: redis selector: matchLabels: name: redis template: metadata: labels: name: redis spec: initContainers: - name: init-redis image: busybox command: ['sh', '-c', 'mkdir -p /data/testdata/redis/log/;mkdir -p /data/testdata/redis/conf/;mkdir -p /data/testdata/redis/data/'] volumeMounts: - name: data mountPath: /data/testdata/redis/ containers: - name: redis image: redis:6.2.5-alpine3.14 imagePullPolicy: IfNotPresent command: - sh - -c - "exec redis-server /data/testdata/redis/conf/redis.conf" ports: - containerPort: 6379 name: redis protocol: TCP volumeMounts: - name: redis-config mountPath: /data/testdata/redis/conf/ - name: data mountPath: /data/testdata/redis/ volumes: - name: redis-config configMap: name: redis-conf - name: data hostPath: path: /data/testdata/redis/ nodeSelector: type5: test2-node
k8s部署redis单实例配置StatefulSet.yaml
kind: Service apiVersion: v1 metadata: labels: name: redis name: redis namespace: workredis spec: type: NodePort ports: - name: redis port: 6379 targetPort: 6379 nodePort: 36366 selector: name: redis