```
---
apiVersion: v1
kind: Namespace
metadata:
name: cssp-cloud-component
---
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
namespace: cssp-cloud-component
data:
update-node.sh: |
#!/bin/sh
REDIS_NODES="/data/nodes.conf"
sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${MY_POD_IP}/" ${REDIS_NODES}
exec "$@"
redis.conf: |+
port 7001
protected-mode no
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
#cluster-announce-ip ${MY_POD_IP}
#cluster-announce-port 7001
#cluster-announce-bus-port 17001
logfile "/data/redis.log"
---
```
```
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: redis-cluster
name: redis-cluster
namespace: default-component
spec:
replicas: 2
selector:
matchLabels:
app: redis-cluster
serviceName: redis-cluster
template:
metadata:
labels:
app: redis-cluster
spec:
containers:
- command:
["/bin/bash", "/usr/local/etc/redis/
update-node.sh", "redis-server", "/usr/local/etc/redis/redis.conf"]
#args:
# - /usr/local/etc/redis/redis.conf
# - --cluster-announce-ip
# - "$(MY_POD_IP)"
env:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: TZ
value: Asia/Shanghai
image: 'redis:6.0.10'
imagePullPolicy: IfNotPresent
name: redis
ports:
- containerPort: 7001
hostPort: 7001
name: redis-port
protocol: TCP
volumeMounts:
- mountPath: /data
name: redis-cluster-data
subPath: data
readOnly: false
- mountPath: /usr/local/etc/redis
name: redis-config
readOnly: false
dnsPolicy: ClusterFirst
volumes:
- name: redis-config
configMap:
name: redis-config
volumeClaimTemplates:
- metadata:
name: redis-cluster-data
namespace: default-component
spec:
storageClassName: "default-storage-class"
accessModes: ["ReadWriteMany"]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
labels:
app: redis-cluster
name: redis-cluster
namespace: default-component
spec:
ports:
- name: redis-port
port: 7001
protocol: TCP
targetPort: 7001
selector:
app: redis-cluster
type: ClusterIP
clusterIP: None
```
@
dier 其实没有敏感信息,就是部署 redis 集群时碰到的莫名其妙的错误...上面就是全部的脚本