Created
March 18, 2020 05:06
-
-
Save matsub/bff0804c46e5eb88cbd40d03e3d4c902 to your computer and use it in GitHub Desktop.
k8s manifest YAML for redis-sentinel set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: redis-sentinel | |
labels: | |
app: redis-sentinel | |
spec: | |
clusterIP: None | |
ports: | |
- name: redis-sentinel | |
port: 26379 | |
selector: | |
app: redis-sentinel | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: redis-sentinel | |
labels: | |
app: redis-sentinel | |
data: | |
sentinel.conf: | | |
# sentinel config | |
port 26379 | |
sentinel monitor redis redis-0.redis 6379 2 | |
sentinel down-after-milliseconds redis 5000 | |
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: redis-sentinel | |
spec: | |
serviceName: redis-sentinel | |
replicas: 3 | |
selector: | |
matchLabels: | |
app: redis-sentinel | |
template: | |
metadata: | |
labels: | |
app: redis-sentinel | |
spec: | |
containers: | |
- name: redis-sentinel | |
command: ["redis-sentinel", "/etc/redis/sentinel.conf"] | |
image: redis:5.0 | |
ports: | |
- name: redis-sentinel | |
containerPort: 26379 | |
volumeMounts: | |
- name: conf | |
mountPath: /etc/redis | |
resources: | |
requests: | |
cpu: 100m | |
memory: 256Mi | |
readinessProbe: | |
exec: | |
command: | |
- sh | |
- -c | |
- "/usr/local/bin/redis-cli -h $(hostname) -p 26379 ping" | |
initialDelaySeconds: 15 | |
timeoutSeconds: 5 | |
initContainers: | |
- name: copy-shared-config | |
image: redis:5.0 | |
command: | |
- /bin/bash | |
- -c | |
- "cp /mnt/config-map/sentinel.conf /mnt/redis/sentinel.conf" | |
volumeMounts: | |
- name: conf | |
mountPath: /mnt/redis | |
- name: config-map | |
mountPath: /mnt/config-map | |
volumes: | |
- name: config-map | |
configMap: | |
name: redis-sentinel | |
volumeClaimTemplates: | |
- metadata: | |
name: conf | |
spec: | |
accessModes: ["ReadWriteOnce"] | |
resources: | |
requests: | |
storage: 10Mi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: redis | |
labels: | |
app: redis | |
spec: | |
clusterIP: None | |
ports: | |
- name: redis | |
port: 6379 | |
selector: | |
app: redis | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: redis | |
labels: | |
app: redis | |
data: | |
master.conf: | | |
# Apply this config only on the master. | |
slave.conf: | | |
# Apply this config only on slaves. | |
# todo this should be parameterized with the actual hostname | |
slaveof redis-0.redis 6379 | |
shared.conf: | | |
# Redis configuration file example. | |
# ... | |
--- | |
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: redis | |
spec: | |
serviceName: redis | |
replicas: 5 | |
selector: | |
matchLabels: | |
app: redis | |
template: | |
metadata: | |
labels: | |
app: redis | |
spec: | |
containers: | |
- name: redis | |
command: ["redis-server", "/etc/redis/redis.conf"] | |
image: redis:5.0 | |
ports: | |
- name: redis | |
containerPort: 6379 | |
volumeMounts: | |
- name: data | |
mountPath: /data | |
- name: conf | |
mountPath: /etc/redis | |
resources: | |
requests: | |
cpu: 100m | |
memory: 256Mi | |
readinessProbe: | |
exec: | |
command: | |
- sh | |
- -c | |
- "/usr/local/bin/redis-cli -h $(hostname) ping" | |
initialDelaySeconds: 15 | |
timeoutSeconds: 5 | |
initContainers: | |
- name: copy-shared-config | |
image: redis:5.0 | |
command: | |
- /bin/bash | |
- -c | |
- "cp /mnt/config-map/shared.conf /mnt/redis/redis.conf" | |
volumeMounts: | |
- name: conf | |
mountPath: /mnt/redis | |
- name: config-map | |
mountPath: /mnt/config-map | |
- name: copy-ordinal-config | |
image: redis:5.0 | |
command: | |
- /bin/bash | |
- -c | |
- "if [[ `hostname` =~ -0$ ]]; then ROLE=\"master\"; else ROLE=\"slave\"; fi && cat /mnt/config-map/${ROLE}.conf >> /mnt/redis/redis.conf" | |
volumeMounts: | |
- name: conf | |
mountPath: /mnt/redis | |
- name: config-map | |
mountPath: /mnt/config-map | |
volumes: | |
- name: config-map | |
configMap: | |
name: redis | |
volumeClaimTemplates: | |
- metadata: | |
name: data | |
spec: | |
accessModes: ["ReadWriteOnce"] | |
resources: | |
requests: | |
storage: 500Mi | |
- metadata: | |
name: conf | |
spec: | |
accessModes: ["ReadWriteOnce"] | |
resources: | |
requests: | |
storage: 10Mi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment